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

A Reader receives events published by a informers by participating in a channel with a suitable scope. More...

#include <Reader.h>

Inheritance diagram for rsb::Reader:
Inheritance graph
Collaboration diagram for rsb::Reader:
Collaboration graph

Public Member Functions

 Reader (const std::vector< transport::InPullConnectorPtr > &connectors, const Scope &scope, const ParticipantConfig &config)
 Constructs a new reader object assigned to scope.
EventPtr read (bool block=true)
 Reads one event from the bus.
- 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

std::string getClassName () const

Private Attributes

rsc::logging::LoggerPtr logger
eventprocessing::InRouteConfiguratorPtr configurator

Additional Inherited Members

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

Detailed Description

A Reader receives events published by a informers by participating in a channel with a suitable scope.

In contrast to the Listener participant, a Reader receives events using a pull-style interface: the read method has to be explicitly in order to receive events. This method may then block (depending on the block parameter) until an event becomes available. The received event, if any, is returned to the caller. There are no context swichtes or queuing involved.

Usage example:

ReaderPtr reader = Factory::getInstance().createReader(Scope("/example/informer"));
reader->read();
Author
jmoringe

Definition at line 61 of file Reader.h.

Constructor & Destructor Documentation

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

Constructs a new reader object assigned to scope.

The reader connects to the bus using the supplied connectors.

Parameters
connectorsa list of connectors that the reader 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::createReader instead of calling this directly.

Definition at line 41 of file Reader.cpp.

References configurator.

Member Function Documentation

string rsb::Reader::getClassName ( ) const
private

Definition at line 60 of file Reader.cpp.

EventPtr rsb::Reader::read ( bool  block = true)

Reads one event from the bus.

If block is true, blocks until an event is available. If block is false and no event is available, an empty EventPtr is returned.

Parameters
blockControls whether the call should block and wait for an event if no event is immediately available.
Returns
A boost::shared_ptr to the received event or an empty boost::shared_ptr if no event was available and block was false.
Exceptions
RSBErrorwhen a communication error occurs while receiving or decoding the event.

Definition at line 53 of file Reader.cpp.

References configurator.

Member Data Documentation

eventprocessing::InRouteConfiguratorPtr rsb::Reader::configurator
private

Definition at line 96 of file Reader.h.

Referenced by read(), and Reader().

rsc::logging::LoggerPtr rsb::Reader::logger
private

Definition at line 94 of file Reader.h.


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