RSB  0.7.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rsb::Informer< T > Class Template Reference

A informer to publish data of a specified type expressed through the template parameter. More...

#include <Informer.h>

Inheritance diagram for rsb::Informer< T >:
Inheritance graph
Collaboration diagram for rsb::Informer< T >:
Collaboration graph

Public Types

typedef boost::shared_ptr
< Informer< T > > 
Ptr
 Shared pointer type for this informer.
typedef boost::shared_ptr< T > DataPtr
 Shared pointer type for the default data published by this informer.

Public Member Functions

 Informer (const std::vector< transport::OutConnectorPtr > &connectors, const Scope &scope, const ParticipantConfig &config, const std::string &type=detail::TypeName< T >()())
 Constructs a new informer.
virtual ~Informer ()
std::string getClassName () const
EventPtr createEvent () const
 Creates a new Event instance filled with the scope from this informer.
EventPtr publish (boost::shared_ptr< T > data)
 Publishes data to the Informer's scope.
template<class T1 >
EventPtr publish (boost::shared_ptr< T1 > data, std::string type=rsc::runtime::typeName(typeid(T1)))
 Published data in the channel in which the informer participates.
EventPtr publish (EventPtr event)
 Publishes the event to the Informer's scope with the ability to define additional meta data.
- Public Member Functions inherited from rsb::InformerBase
 InformerBase (const std::vector< transport::OutConnectorPtr > &connectors, const Scope &scope, const ParticipantConfig &config, const std::string &defaultType)
virtual ~InformerBase ()
void printContents (std::ostream &stream) const
std::string getType () const
 Return the event payload type of this Informer.
void setQualityOfSerivceSpecs (const QualityOfServiceSpec &specs)
 Defines the desired quality of service settings for this informers.
template<class T1 >
EventPtr uncheckedPublish (boost::shared_ptr< T1 > data, const std::string &type=rsc::runtime::typeName< T1 >())
EventPtr publish (VoidPtr data, const std::string &type)
 Publishes data to the Informer's scope.
EventPtr uncheckedPublish (VoidPtr data, const std::string &type)
- Public Member Functions inherited from rsb::Participant
virtual ~Participant ()
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 Attributes

rsc::logging::LoggerPtr logger

Additional Inherited Members

- Protected Member Functions inherited from rsb::InformerBase
void checkedPublish (EventPtr event)
void uncheckedPublish (EventPtr event)
boost::uint32_t nextSequenceNumber ()
- Protected Attributes inherited from rsb::InformerBase
std::string defaultType
eventprocessing::OutRouteConfiguratorPtr configurator
boost::uint32_t currentSequenceNumber

Detailed Description

template<class T>
class rsb::Informer< T >

A informer to publish data of a specified type expressed through the template parameter.

All data in RSB is maintained as shared pointers to avoid unnecessary copy operations. Typedefs simplify the use of the pointer types.

The basic usage pattern is explained with this example code:

Informer<string>::Ptr informer = Factory::getInstance().createInformer<string>(Scope("/example/informer"));
Informer<string>::DataPtr s(new string("blub"));
informer->publish(s);
Author
swrede
Template Parameters
TData type to send by this informer.

Definition at line 227 of file Informer.h.

Member Typedef Documentation

template<class T>
typedef boost::shared_ptr<T> rsb::Informer< T >::DataPtr

Shared pointer type for the default data published by this informer.

Definition at line 238 of file Informer.h.

template<class T>
typedef boost::shared_ptr<Informer<T> > rsb::Informer< T >::Ptr

Shared pointer type for this informer.

Definition at line 233 of file Informer.h.

Constructor & Destructor Documentation

template<class T>
rsb::Informer< T >::Informer ( const std::vector< transport::OutConnectorPtr > &  connectors,
const Scope scope,
const ParticipantConfig config,
const std::string &  type = detail::TypeName<T>()() 
)
inline

Constructs a new informer.

Parameters
connectorsA list of connectors the informer should use to connect to the bus
scopethe scope under which the data are published
configthe config that was used to setup this informer
typestring describing the type of data sent by this informer. The empty string indicates that data of arbitrary type can be sent through this informer.
Note
This constructor is exposed for unit tests and such. Use Factory::createInformer instead of calling this directly.

Definition at line 254 of file Informer.h.

template<class T>
virtual rsb::Informer< T >::~Informer ( )
inlinevirtual

Definition at line 261 of file Informer.h.

Member Function Documentation

template<class T>
EventPtr rsb::Informer< T >::createEvent ( ) const
inlinevirtual

Creates a new Event instance filled with the scope from this informer.

Returns
new Event instance with scope set

Moreover, this version also sets the type according to the template parameter of Informer.

Returns
new Event with scope and type set.

Reimplemented from rsb::InformerBase.

Definition at line 276 of file Informer.h.

Referenced by rsb::Informer< void >::createEvent().

Here is the caller graph for this function:

template<class T>
std::string rsb::Informer< T >::getClassName ( ) const
inline

Definition at line 264 of file Informer.h.

template<class T>
EventPtr rsb::Informer< T >::publish ( boost::shared_ptr< T >  data)
inline

Publishes data to the Informer's scope.

Parameters
dataPointer to the data to send.
Returns
A boost::shared_ptr to the rsb::Event object that has been implicitly created.

Definition at line 289 of file Informer.h.

Referenced by rsb::patterns::RemoteServer::callAsync(), and rsb::Informer< void >::publish().

Here is the caller graph for this function:

template<class T>
template<class T1 >
EventPtr rsb::Informer< T >::publish ( boost::shared_ptr< T1 >  data,
std::string  type = rsc::runtime::typeName(typeid(T1)) 
)
inline

Published data in the channel in which the informer participates.

Template Parameters
T1The type of data. The value of this parameter is used infer the value of type.
Parameters
dataPointer to the data that should be sent. Arbitrary pointer types are accepted at compile time, but may lead to type or conversion errors at runtime.
typeA string indicating the type of data. I.e. "std::string" for std::string objects. If omitted, the type of data is inferred from T1.
Returns
A boost::shared_ptr to the rsb::Event object that has been implicitly created.
Exceptions
std::invalid_argumentIf T1 or type is incompatible with the actual type of the informer.

Reimplemented from rsb::InformerBase.

Definition at line 295 of file Informer.h.

template<class T>
EventPtr rsb::Informer< T >::publish ( EventPtr  event)
inline

Publishes the event to the Informer's scope with the ability to define additional meta data.

Parameters
eventThe event to publish.
Returns
modified event.
Exceptions
std::invalid_argumentIf the type of the payload of event is incompatible with the actual type of the informer or if the scope of event is not a subscope of the scope of the informer.

Reimplemented from rsb::InformerBase.

Definition at line 300 of file Informer.h.

Member Data Documentation

template<class T>
rsc::logging::LoggerPtr rsb::Informer< T >::logger
private

Definition at line 304 of file Informer.h.


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