Chains a dynamic number of simple filters together. Allows retrieval of filters by index after they are added.
More...
|
void | add (const MConstPtr &msg) |
| Add a message to the start of this chain. More...
|
|
void | add (const EventType &evt) |
|
template<class F > |
size_t | addFilter (F *filter) |
| Add a filter to this chain, by bare pointer. Returns the index of that filter in the chain. More...
|
|
template<class F > |
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. More...
|
|
| Chain () |
| Default constructor. More...
|
|
template<typename F > |
| Chain (F &f) |
| Constructor with filter. Calls connectInput(f) More...
|
|
template<class F > |
void | connectInput (F &f) |
| Connect this filter's input to another filter's output. More...
|
|
template<typename F > |
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 the size of the chain. NOT type-safe. More...
|
|
template<typename F > |
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 the size of the chain. NOT type-safe. More...
|
|
virtual | ~ChainBase () |
|
const std::string & | getName () |
| Get the name of this filter. For debugging use. More...
|
|
template<typename C > |
Connection | registerCallback (const C &callback) |
| Register a callback to be called when this filter has passed. More...
|
|
template<typename P > |
Connection | registerCallback (const boost::function< void(P)> &callback) |
| Register a callback to be called when this filter has passed. More...
|
|
template<typename P > |
Connection | registerCallback (void(*callback)(P)) |
| Register a callback to be called when this filter has passed. More...
|
|
template<typename T , typename P > |
Connection | registerCallback (void(T::*callback)(P), T *t) |
| Register a callback to be called when this filter has passed. More...
|
|
void | setName (const std::string &name) |
| Set the name of this filter. For debugging use. More...
|
|
template<typename M>
class message_filters::Chain< M >
Chains a dynamic number of simple filters together. Allows retrieval of filters by index after they are added.
The Chain filter provides a container for simple filters. It allows you to store an N-long set of filters inside a single structure, making it much easier to manage them.
Adding filters to the chain is done by adding shared_ptrs of them to the filter. They are automatically connected to each other and the output of the last filter in the chain is forwarded to the callback you've registered with Chain::registerCallback
Example:
void myCallback(const MsgConstPtr& msg)
{
}
Chain<Msg> c;
c.addFilter(boost::make_shared<PassThrough<Msg> >());
c.addFilter(boost::make_shared<PassThrough<Msg> >());
c.registerCallback(myCallback);
It is also possible to pass bare pointers in, which will not be automatically deleted when Chain is destructed:
Chain<Msg> c;
PassThrough<Msg> p;
c.addFilter(&p);
c.registerCallback(myCallback);
Definition at line 111 of file chain.h.