RSB  0.7.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rsb::Listener Class Reference

A Listener receives events published by rsb::Informer objects by participating in a channel with a suitable scope. More...

#include <Listener.h>

Inheritance diagram for rsb::Listener:
Inheritance graph
Collaboration diagram for rsb::Listener:
Collaboration graph

Classes

class  Impl

Public Member Functions

 Listener (const std::vector< transport::InPushConnectorPtr > &connectors, const Scope &scope, const ParticipantConfig &config)
 Constructs a new Listener assigned to the specified scope.
virtual ~Listener ()
std::string getClassName () const
void addFilter (filter::FilterPtr filter)
 Adds a filter that will be applied after some time (but not immediately after this call) for all handlers.
void removeFilter (filter::FilterPtr filter)
 Removes a previously installed filter if it is present by pointer comparison some time after this call.
virtual void addHandler (HandlerPtr h, bool wait=true)
 Adds a rsb::Handler to the Listener.
void removeHandler (HandlerPtr h, bool wait=true)
 Removes a Handler instance to process newly received events.
- Public Member Functions inherited from rsb::Participant
virtual ~Participant ()
void printContents (std::ostream &stream) const
rsc::misc::UUID getId () const
 Returns the unique id of the participant.
ScopePtr getScope () const
 Returns the scope of this participant.
ParticipantConfig getConfig () const
 Returns a copy of the participant's configuration.

Private Member Functions

void initialize (const std::vector< transport::InPushConnectorPtr > &connectors, const Scope &scope, const ParticipantConfig &config)

Private Attributes

boost::scoped_ptr< Impld

Additional Inherited Members

- Protected Member Functions inherited from rsb::Participant
 Participant (const Scope &scope, const ParticipantConfig &config)

Detailed Description

A Listener receives events published by rsb::Informer objects by participating in a channel with a suitable scope.

Handler objects have to be added to the listener to actually process received events. These events can be filtered for all handlers by adding Filter instances to this class. Filter form a conjunction.

Usage example:

ListenerPtr listener = Factory::getInstance().createListener(Scope("/example/informer"));
boost::shared_ptr<MyDataHandler> dh(new MyDataHandler());
listener->addHandler(dh);
Author
swrede
Todo:
use templates in subscriptions only? (however, they need the event info)

Definition at line 80 of file Listener.h.

Constructor & Destructor Documentation

rsb::Listener::Listener ( const std::vector< transport::InPushConnectorPtr > &  connectors,
const Scope scope,
const ParticipantConfig config 
)

Constructs a new Listener assigned to the specified scope.

The Listener connects to the bus using the supplied connectors.

Parameters
connectorsa list of connectors that the listener should use to communicate with the bus.
scopethe scope where the data is received from.
configthe configuration that was used to setup this listener
Note
This constructor is exposed for unit tests and such. Use Factory::createListener instead of calling this directly.

Definition at line 47 of file Listener.cpp.

References d, and initialize().

Here is the call graph for this function:

rsb::Listener::~Listener ( )
virtual

Definition at line 55 of file Listener.cpp.

Member Function Documentation

void rsb::Listener::addFilter ( filter::FilterPtr  filter)

Adds a filter that will be applied after some time (but not immediately after this call) for all handlers.

Parameters
filterfilter to add

Definition at line 83 of file Listener.cpp.

References d.

void rsb::Listener::addHandler ( HandlerPtr  h,
bool  wait = true 
)
virtual

Adds a rsb::Handler to the Listener.

Events which match the restrictions described by the associated filters are passed to all handlers.

Parameters
ha pointer to the Handler.
waitif set to true, this method will return only after the handler has completely been installed and will receive the next available message. Otherwise it may return earlier.

Definition at line 75 of file Listener.cpp.

References d.

string rsb::Listener::getClassName ( ) const

Definition at line 58 of file Listener.cpp.

void rsb::Listener::initialize ( const std::vector< transport::InPushConnectorPtr > &  connectors,
const Scope scope,
const ParticipantConfig config 
)
private

Definition at line 62 of file Listener.cpp.

References d, and rsb::Participant::getConfig().

Referenced by Listener().

Here is the call graph for this function:

Here is the caller graph for this function:

void rsb::Listener::removeFilter ( filter::FilterPtr  filter)

Removes a previously installed filter if it is present by pointer comparison some time after this call.

Parameters
filterfilter to remove if present

Definition at line 87 of file Listener.cpp.

References d.

void rsb::Listener::removeHandler ( HandlerPtr  h,
bool  wait = true 
)

Removes a Handler instance to process newly received events.

Parameters
hhandler to remove if present (comparison based on pointer)
waitif set to true, this method will return only after the handler has been completely removed from the event processing and will not be called anymore from this listener.

Definition at line 79 of file Listener.cpp.

References d.

Member Data Documentation

boost::scoped_ptr<Impl> rsb::Listener::d
private

Definition at line 142 of file Listener.h.

Referenced by addFilter(), addHandler(), initialize(), Listener(), removeFilter(), and removeHandler().


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