RSB  0.19.0
rsb::Event Class Reference

Basic message that is exchanged between informers and listeners. More...

#include <Event.h>

Inheritance diagram for rsb::Event:
Inheritance graph
Collaboration diagram for rsb::Event:
Collaboration graph

Classes

class  Impl
 

Public Member Functions

 Event ()
 
 Event (const Event &event)
 
 Event (ScopePtr scope, boost::shared_ptr< void > payload, const std::string &type, const std::string &method="")
 Constructor. More...
 
 Event (Scope scope, boost::shared_ptr< void > payload, const std::string &type, const std::string &method="")
 
virtual ~Event ()
 
std::string getClassName () const
 
void printContents (std::ostream &stream) const
 
 DEPRECATED (boost::uint64_t getSequenceNumber() const)
 Returns the sequence which indicates the position of the event in the stream of events published by a single informer. More...
 
EventId getId () const
 Returns the id of this event. More...
 
void setId (const rsc::misc::UUID &senderId, const boost::uint32_t &sequenceNumber)
 Sets all information necessary to generate an id for this event. More...
 
 DEPRECATED (EventId getEventId() const)
 Returns the id of this event. More...
 
 DEPRECATED (void setEventId(const rsc::misc::UUID &senderId, const boost::uint32_t &sequenceNumber))
 Sets all information necessary to generate an id for this event. More...
 
std::string getType () const
 
void setType (const std::string &type)
 
VoidPtr getData ()
 
void setData (VoidPtr d)
 
std::string getMethod () const
 Returns the method associated with this event. More...
 
void setMethod (const std::string &method)
 Sets the method associated with this event. More...
 
scope access

There are two ways of getting and setting scopes for events.

One uses copies of Scopes, which may be expensive and one uses ScopePtr s to avoid the copy operation. Setting the scope with one method makes it also available using the copy getter and vice versa.

ScopePtr getScopePtr () const
 
Scope getScope () const
 
void setScopePtr (ScopePtr scope)
 
void setScope (const Scope &scope)
 
cause handling

Events are often caused by other events, which e.g.

means that their contained payload was calculated on the payload of one or more other events.

To express these relations each event contains a set of EventIds that express the direct causes of the event. This means, transitive event causes are not modeled.

Cause handling is inspired by the ideas proposed in: David Luckham, The Power of Events, Addison-Wessley, 2007

bool addCause (const EventId &id)
 Adds the id of one event to the causes of this event. More...
 
bool removeCause (const EventId &id)
 Removes a causing event from the set of causes for this event. More...
 
bool isCause (const EventId &id) const
 Tells whether the id of one event is already marked as a cause of this event. More...
 
std::set< EventIdgetCauses () const
 Returns all causing events marked so far. More...
 
meta-data access
MetaData getMetaData () const
 Returns a copy of the current meta-data state of this event. More...
 
MetaDatamutableMetaData ()
 Returns an in-place mutable version of the event's meta-data. More...
 
void setMetaData (const MetaData &metaData)
 Replaces the event's meta-data with a new instance. More...
 

Private Attributes

boost::scoped_ptr< Impld
 

Detailed Description

Basic message that is exchanged between informers and listeners.

It is a combination of metadata and the actual data to publish / subscribe as payload.

Author
swrede

Definition at line 60 of file Event.h.

Constructor & Destructor Documentation

rsb::Event::Event ( )

Definition at line 62 of file Event.cpp.

References d.

rsb::Event::Event ( const Event event)

Definition at line 67 of file Event.cpp.

rsb::Event::Event ( ScopePtr  scope,
boost::shared_ptr< void >  payload,
const std::string &  type,
const std::string &  method = "" 
)

Constructor.

Parameters
scopescope of the event
payloadpayload of the event
typetype identifier to serialize / deserialize the event payload
methoda method that is represented by this event. Am empty string specifies an undecided method.

Definition at line 72 of file Event.cpp.

References d.

rsb::Event::Event ( Scope  scope,
boost::shared_ptr< void >  payload,
const std::string &  type,
const std::string &  method = "" 
)

Definition at line 81 of file Event.cpp.

References d.

rsb::Event::~Event ( )
virtual

Definition at line 90 of file Event.cpp.

Member Function Documentation

bool rsb::Event::addCause ( const EventId id)

Adds the id of one event to the causes of this event.

If the set of causing events already contained the given id, this call has no effect.

Parameters
idthe id of a causing event
Returns
true if the causes was added, false if it already existed

Definition at line 175 of file Event.cpp.

References d.

rsb::Event::DEPRECATED ( boost::uint64_t getSequenceNumber()  const)

Returns the sequence which indicates the position of the event in the stream of events published by a single informer.

Returns
sequence number of the event.
Deprecated:
Use getId instead
rsb::Event::DEPRECATED ( EventId getEventId()  const)

Returns the id of this event.

The id is not defined until the event is sent by an informer.

Returns
id of the event
Exceptions
rsc::misc::IllegalStateExceptionif there cannot be an id because the event was not sent so far.
Deprecated:
Use getId instead for consistent naming across implementations
rsb::Event::DEPRECATED ( void   setEventIdconst rsc::misc::UUID &senderId, const boost::uint32_t &sequenceNumber)

Sets all information necessary to generate an id for this event.

Parameters
senderIdid of the sender of this event
sequenceNumberthe unique number per sender this event was sent with
set< EventId > rsb::Event::getCauses ( ) const

Returns all causing events marked so far.

Returns
set of causing event ids. Modifications to this set do not affect this event as it is a copy.

Definition at line 187 of file Event.cpp.

References d.

string rsb::Event::getClassName ( ) const

Definition at line 93 of file Event.cpp.

VoidPtr rsb::Event::getData ( )

Definition at line 163 of file Event.cpp.

References d.

EventId rsb::Event::getId ( ) const

Returns the id of this event.

The id is not defined until the event is sent by an informer.

Returns
id of the event
Exceptions
rsc::misc::IllegalStateExceptionif there cannot be an id because the event was not sent so far.

Definition at line 118 of file Event.cpp.

References d.

Referenced by printContents().

Here is the caller graph for this function:

MetaData rsb::Event::getMetaData ( ) const

Returns a copy of the current meta-data state of this event.

Returns
copy of event's meta-data

Definition at line 199 of file Event.cpp.

References d.

string rsb::Event::getMethod ( ) const

Returns the method associated with this event.

An empty string indicates an unspecified method.

Returns
method name or empty string

Definition at line 191 of file Event.cpp.

References d.

Scope rsb::Event::getScope ( ) const

Definition at line 155 of file Event.cpp.

References d.

ScopePtr rsb::Event::getScopePtr ( ) const

Definition at line 151 of file Event.cpp.

References d.

string rsb::Event::getType ( ) const

Definition at line 167 of file Event.cpp.

References d.

bool rsb::Event::isCause ( const EventId id) const

Tells whether the id of one event is already marked as a cause of this event.

Parameters
idid of the event to test causality for
Returns
true if id is marked as a cause for this event, else false

Definition at line 183 of file Event.cpp.

References d.

MetaData & rsb::Event::mutableMetaData ( )

Returns an in-place mutable version of the event's meta-data.

Returns
meta-data reference to modify

Definition at line 203 of file Event.cpp.

References d.

void rsb::Event::printContents ( std::ostream &  stream) const

Definition at line 97 of file Event.cpp.

References d, getId(), and rsb::EventId::getSequenceNumber().

Here is the call graph for this function:

bool rsb::Event::removeCause ( const EventId id)

Removes a causing event from the set of causes for this event.

If the id was not contained in this set, the call has no effect.

Parameters
idof the causing event
Returns
true if an event with this id was removed from the causes, else false

Definition at line 179 of file Event.cpp.

References d.

void rsb::Event::setData ( VoidPtr  d)

Definition at line 159 of file Event.cpp.

References d.

void rsb::Event::setId ( const rsc::misc::UUID &  senderId,
const boost::uint32_t &  sequenceNumber 
)

Sets all information necessary to generate an id for this event.

Parameters
senderIdid of the sender of this event
sequenceNumberthe unique number per sender this event was sent with

Definition at line 130 of file Event.cpp.

References d.

void rsb::Event::setMetaData ( const MetaData metaData)

Replaces the event's meta-data with a new instance.

Parameters
metaDatanew meta-data to set

Definition at line 207 of file Event.cpp.

References d.

void rsb::Event::setMethod ( const std::string &  method)

Sets the method associated with this event.

Parameters
methodmethod name or empty string for unspecified method.

Definition at line 195 of file Event.cpp.

References d.

void rsb::Event::setScope ( const Scope scope)

Definition at line 147 of file Event.cpp.

References d.

void rsb::Event::setScopePtr ( ScopePtr  scope)

Definition at line 143 of file Event.cpp.

References d.

void rsb::Event::setType ( const std::string &  type)

Definition at line 171 of file Event.cpp.

References d.

Member Data Documentation


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