35 #ifndef MESSAGE_FILTERS_CHAIN_H 36 #define MESSAGE_FILTERS_CHAIN_H 68 return boost::static_pointer_cast<F>(filter);
147 return addFilter(ptr);
157 info.
add_func = boost::bind((
void(F::*)(
const EventType&))&F::add, filter.get(), _1);
159 info.
passthrough = boost::make_shared<PassThrough<M> >();
161 last_filter_connection_.disconnect();
164 if (!filters_.empty())
166 filter->connectInput(*filters_.back().passthrough);
169 uint32_t count = filters_.size();
170 filters_.push_back(info);
184 if (index >= filters_.size())
189 return boost::static_pointer_cast<F>(filters_[index].filter);
198 incoming_connection_.disconnect();
205 void add(
const MConstPtr& msg)
210 void add(
const EventType& evt)
212 if (!filters_.empty())
214 filters_[0].add_func(evt);
221 if (index >= filters_.size())
226 return filters_[index].filter;
237 this->signalMessage(evt);
255 #endif // MESSAGE_FILTERS_CHAIN_H boost::shared_ptr< ChainBase > ChainBasePtr
boost::shared_ptr< M const > MConstPtr
void connectInput(F &f)
Connect this filter's input to another filter's output.
void incomingCB(const EventType &evt)
void add(const MConstPtr &msg)
Add a message to the start of this chain.
void add(const EventType &evt)
Connection incoming_connection_
boost::function< void(const EventType &)> add_func
Connection last_filter_connection_
void operator()(void const *) const
boost::shared_ptr< F > getFilter(size_t index) const
Retrieve a filter from this chain by index. Returns an empty shared_ptr if the index is greater than ...
ros::MessageEvent< M const > EventType
virtual boost::shared_ptr< void > getFilterForIndex(size_t index) const =0
Chain()
Default constructor.
virtual boost::shared_ptr< void > getFilterForIndex(size_t index) const
Chains a dynamic number of simple filters together. Allows retrieval of filters by index after they a...
boost::shared_ptr< PassThrough< M > > passthrough
Chain(F &f)
Constructor with filter. Calls connectInput(f)
Convenience base-class for simple filters which output a single message.
size_t addFilter(F *filter)
Add a filter to this chain, by bare pointer. Returns the index of that filter in the chain...
boost::function< void(const EventType &)> EventCallback
void lastFilterCB(const EventType &evt)
std::vector< FilterInfo > V_FilterInfo
Base class for Chain, allows you to store multiple chains in the same container. Provides filter retr...
Encapsulates a connection from one filter to another (or to a user-specified callback) ...
boost::shared_ptr< F > getFilter(size_t index) const
Retrieve a filter from this chain by index. Returns an empty shared_ptr if the index is greater than ...
boost::shared_ptr< void > filter
size_t addFilter(const boost::shared_ptr< F > &filter)
Add a filter to this chain, by shared_ptr. Returns the index of that filter in the chain...