RSB  0.7.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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.
 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)
 DEPRECATED (rsc::misc::UUID getId() const)
 Returns a UUID for the event.
EventId getEventId () const
 Returns the id of this event.
void setEventId (const rsc::misc::UUID &senderId, const boost::uint32_t &sequenceNumber)
 Sets all information necessary to generate an id for this event.
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.
void setMethod (const std::string &method)
 Sets the method associated with this event.
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.
bool removeCause (const EventId &id)
 Removes a causing event from the set of causes for this event.
bool isCause (const EventId &id) const
 Tells whether the id of one event is already marked as a cause of this event.
std::set< EventIdgetCauses () const
 Returns all causing events marked so far.
meta-data access
MetaData getMetaData () const
 Returns a copy of the current meta-data state of this event.
MetaDatamutableMetaData ()
 Returns an in-place mutable version of the event's meta-data.
void setMetaData (const MetaData &metaData)
 Replaces the event's meta-data with a new instance.

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 61 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 168 of file Event.cpp.

References d.

rsb::Event::DEPRECATED ( boost::uint64_t getSequenceNumber()  const)
Deprecated:
use getEventId instead to access the sequence number.
rsb::Event::DEPRECATED ( rsc::misc::UUID getId()  const)

Returns a UUID for the event.

This is now generated using the sending participant and a sequence ID. Hence, it is not defined before the event is sent.

Returns
UUID of the event
Exceptions
rsc::misc::IllegalStateExceptionif there cannot be an id because the event was not sent so far.
Deprecated:
Use getEventId instead. This operation is expensive as it generates a UUID.
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 180 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 156 of file Event.cpp.

References d.

EventId rsb::Event::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.

Definition at line 122 of file Event.cpp.

References d.

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 192 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 184 of file Event.cpp.

References d.

Scope rsb::Event::getScope ( ) const

Definition at line 148 of file Event.cpp.

References d.

ScopePtr rsb::Event::getScopePtr ( ) const

Definition at line 144 of file Event.cpp.

References d.

string rsb::Event::getType ( ) const

Definition at line 160 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 176 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 196 of file Event.cpp.

References d.

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

Definition at line 97 of file Event.cpp.

References d.

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 172 of file Event.cpp.

References d.

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

Definition at line 152 of file Event.cpp.

References d.

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

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

The senderId will also be set in the meta data of the 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 200 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 188 of file Event.cpp.

References d.

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

Definition at line 140 of file Event.cpp.

References d.

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

Definition at line 136 of file Event.cpp.

References d.

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

Definition at line 164 of file Event.cpp.

References d.

Member Data Documentation


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