Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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>

Inheritance diagram for message_filters::Chain< M >:
Inheritance graph
[legend]

Classes

struct  FilterInfo
 
struct  NullDeleter
 

Public Types

typedef ros::MessageEvent< M const > EventType
 
typedef boost::shared_ptr< M const > MConstPtr
 
- Public Types inherited from message_filters::SimpleFilter< M >
typedef boost::function< void(const MConstPtr &)> Callback
 
typedef boost::function< void(const EventType &)> EventCallback
 
typedef ros::MessageEvent< M const > EventType
 
typedef boost::shared_ptr< M const > MConstPtr
 

Public Member Functions

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...
 
- Public Member Functions inherited from message_filters::ChainBase
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 ()
 
- Public Member Functions inherited from message_filters::SimpleFilter< M >
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...
 

Protected Member Functions

virtual boost::shared_ptr< void > getFilterForIndex (size_t index) const
 
- Protected Member Functions inherited from message_filters::SimpleFilter< M >
void signalMessage (const MConstPtr &msg)
 Call all registered callbacks, passing them the specified message. More...
 
void signalMessage (const ros::MessageEvent< M const > &event)
 Call all registered callbacks, passing them the specified message. More...
 

Private Types

typedef std::vector< FilterInfoV_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::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.

Member Typedef Documentation

template<typename M>
typedef ros::MessageEvent<M const> message_filters::Chain< M >::EventType

Definition at line 115 of file chain.h.

template<typename M>
typedef boost::shared_ptr<M const> message_filters::Chain< M >::MConstPtr

Definition at line 114 of file chain.h.

template<typename M>
typedef std::vector<FilterInfo> message_filters::Chain< M >::V_FilterInfo
private

Definition at line 246 of file chain.h.

Constructor & Destructor Documentation

template<typename M>
message_filters::Chain< M >::Chain ( )
inline

Default constructor.

Definition at line 120 of file chain.h.

template<typename M>
template<typename F >
message_filters::Chain< M >::Chain ( F &  f)
inline

Constructor with filter. Calls connectInput(f)

Definition at line 128 of file chain.h.

Member Function Documentation

template<typename M>
void message_filters::Chain< M >::add ( const MConstPtr msg)
inline

Add a message to the start of this chain.

Definition at line 205 of file chain.h.

template<typename M>
void message_filters::Chain< M >::add ( const EventType evt)
inline

Definition at line 210 of file chain.h.

template<typename M>
template<class F >
size_t message_filters::Chain< M >::addFilter ( F *  filter)
inline

Add a filter to this chain, by bare pointer. Returns the index of that filter in the chain.

Definition at line 144 of file chain.h.

template<typename M>
template<class F >
size_t message_filters::Chain< M >::addFilter ( const boost::shared_ptr< F > &  filter)
inline

Add a filter to this chain, by shared_ptr. Returns the index of that filter in the chain.

Definition at line 154 of file chain.h.

template<typename M>
template<class F >
void message_filters::Chain< M >::connectInput ( F &  f)
inline

Connect this filter's input to another filter's output.

Definition at line 196 of file chain.h.

template<typename M>
template<typename F >
boost::shared_ptr<F> message_filters::Chain< M >::getFilter ( size_t  index) const
inline

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
indexThe index of the filter (returned by addFilter())

Definition at line 182 of file chain.h.

template<typename M>
virtual boost::shared_ptr<void> message_filters::Chain< M >::getFilterForIndex ( size_t  index) const
inlineprotectedvirtual

Implements message_filters::ChainBase.

Definition at line 219 of file chain.h.

template<typename M>
void message_filters::Chain< M >::incomingCB ( const EventType evt)
inlineprivate

Definition at line 230 of file chain.h.

template<typename M>
void message_filters::Chain< M >::lastFilterCB ( const EventType evt)
inlineprivate

Definition at line 235 of file chain.h.

Member Data Documentation

template<typename M>
V_FilterInfo message_filters::Chain< M >::filters_
private

Definition at line 248 of file chain.h.

template<typename M>
Connection message_filters::Chain< M >::incoming_connection_
private

Definition at line 250 of file chain.h.

template<typename M>
Connection message_filters::Chain< M >::last_filter_connection_
private

Definition at line 251 of file chain.h.


The documentation for this class was generated from the following file:


message_filters
Author(s): Josh Faust, Vijay Pradeep, Dirk Thomas
autogenerated on Mon Nov 2 2020 03:52:42