message_filters::Chain< M > Class Template Reference
Chains a dynamic number of simple filters together. Allows retrieval of filters by index after they are added.
More...
#include <chain.h>
List of all members.
Classes |
struct | FilterInfo |
struct | NullDeleter |
Public Types |
typedef ros::MessageEvent< M
const > | EventType |
typedef boost::shared_ptr< M
const > | MConstPtr |
Public Member Functions |
void | add (const EventType &evt) |
void | add (const MConstPtr &msg) |
| Add a message to the start of this chain.
|
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.
|
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.
|
template<typename F > |
| Chain (F &f) |
| Constructor with filter. Calls connectInput(f).
|
| Chain () |
| Default constructor.
|
template<class F > |
void | connectInput (F &f) |
| Connect this filter's input to another filter's output.
|
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.
|
Protected Member Functions |
virtual boost::shared_ptr< void > | getFilterForIndex (size_t index) const |
Private Types |
typedef std::vector< FilterInfo > | V_FilterInfo |
Private Member Functions |
void | incomingCB (const EventType &evt) |
void | lastFilterCB (const EventType &evt) |
Private Attributes |
V_FilterInfo | filters_ |
Connection | incoming_connection_ |
Connection | last_filter_connection_ |
Detailed Description
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::shared_ptr<PassThrough<Msg> >(new PassThrough<Msg>));
c.addFilter(boost::shared_ptr<PassThrough<Msg> >(new 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 107 of file chain.h.
Member Typedef Documentation
Constructor & Destructor Documentation
Default constructor.
Definition at line 116 of file chain.h.
template<typename M>
template<typename F >
Constructor with filter. Calls connectInput(f).
Definition at line 124 of file chain.h.
Member Function Documentation
Add a message to the start of this chain.
Definition at line 201 of file chain.h.
template<typename M>
template<class F >
Add a filter to this chain, by shared_ptr. Returns the index of that filter in the chain.
Definition at line 150 of file chain.h.
template<typename M>
template<class F >
Add a filter to this chain, by bare pointer. Returns the index of that filter in the chain.
Definition at line 140 of file chain.h.
template<typename M>
template<class F >
Connect this filter's input to another filter's output.
Definition at line 192 of file chain.h.
template<typename M>
template<typename F >
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.
- Parameters:
-
| F | [template] The type of the filter |
| index | The index of the filter (returned by addFilter()) |
Reimplemented from message_filters::ChainBase.
Definition at line 178 of file chain.h.
template<typename M>
virtual boost::shared_ptr<void> message_filters::Chain< M >::getFilterForIndex |
( |
size_t |
index |
) |
const [inline, protected, virtual] |
Member Data Documentation
The documentation for this class was generated from the following file: