RSB  0.19.0
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. More...
 
virtual std::string getKind () const
 Return the kind of the participant. More...
 
virtual const std::set< std::string > getTransportURLs () const
 TODO. More...
 
EventPtr read (bool block=true)
 Reads one event from the bus. More...
 
- 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. More...
 
ScopePtr getScope () const
 Returns the scope of this participant. More...
 
ParticipantConfig getConfig () const
 Returns a copy of the participant's configuration. More...
 

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 = getFactory().createReader(Scope("/example/informer"));
reader->read();
Author
jmoringe

Definition at line 62 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, and rsb::ParticipantConfig::getQualityOfServiceSpec().

Here is the call graph for this function:

Member Function Documentation

std::string rsb::Reader::getKind ( ) const
virtual

Return the kind of the participant.

Examples include "informer", "listener" and "reader".

Returns
a string describing the kind of the participant.

Implements rsb::Participant.

Definition at line 56 of file Reader.cpp.

const std::set< std::string > rsb::Reader::getTransportURLs ( ) const
virtual

TODO.

Implements rsb::Participant.

Definition at line 60 of file Reader.cpp.

References configurator.

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 64 of file Reader.cpp.

References configurator.

Member Data Documentation

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

Definition at line 103 of file Reader.h.

Referenced by getTransportURLs(), read(), and Reader().

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

Definition at line 101 of file Reader.h.


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