i6engine  1.0
i6e::core::MessageSubscriber Class Reference

Interface for every class that wants to subscribe to the messaging system. More...

#include <D:/Projekte/i6engine/libs/i6engine-core/include/i6engine/core/messaging/MessageSubscriber.h>

Public Member Functions

 MessageSubscriber ()
 Standard constructor. More...
 
virtual ~MessageSubscriber ()
 Destructor. More...
 
void receiveMessage (const Message::Ptr &msg)
 This method is called from the MessagingController. It stores incoming messages in a local buffer. More...
 
virtual void processMessages ()
 This method goes through the local message buffer and calls the appropriate method of the receiver. More...
 
void notifyNewID (const int64_t id)
 This method notifies the MessagingController that Messages waiting for this id can now be delivered. More...
 
void buffer (const ReceivedMessagePtr &msg)
 Calls deliverMessageInternal if the message should be delivered now, buffers it if not. More...
 
void reset ()
 todo More...
 
void addMethod (uint16_t msgType, const boost::function< void(const Message::Ptr &)> &ptrMessageMethod)
 adds a method for given message type where messages shall be delivered More...
 
void removeMethod (uint16_t msgType)
 removes method for given message type More...
 

Protected Member Functions

void swapMessageBuffer ()
 This method will swap the double message buffer. For synchronization reasons. More...
 
bool updateBuffer ()
 This method delivers all waiting Messages that can now be delivered. More...
 
virtual void deliverMessageInternal (const ReceivedMessagePtr &msg)
 This method really delivers the Message without buffering it anymore. More...
 

Protected Attributes

boost::mutex _objMessageVectorMutex
 
MessageVector _objMessageVectorA
 
MessageVector _objMessageVectorB
 
MessageVector_objActiveMessageVector
 
MessageVector_objInActiveMessageVector
 
std::map< uint16_t, boost::function< void(const Message::Ptr &)> > _ptrMessageMethod
 

Detailed Description

Interface for every class that wants to subscribe to the messaging system.

All instances of the classes SubSystem and GOComponent inherit from this class.

Note
MessageSubscriber.h defines the types:
  • MessageVector is an alias for std::vector<ReceivedMessage>
Have a look at here for an overview of typedef's in namespace i6engine.

Definition at line 76 of file MessageSubscriber.h.

Constructor & Destructor Documentation

i6e::core::MessageSubscriber::MessageSubscriber ( )
inline

Standard constructor.

Definition at line 81 of file MessageSubscriber.h.

virtual i6e::core::MessageSubscriber::~MessageSubscriber ( )
inlinevirtual

Destructor.

Definition at line 87 of file MessageSubscriber.h.

Member Function Documentation

void i6e::core::MessageSubscriber::addMethod ( uint16_t  msgType,
const boost::function< void(const Message::Ptr &)> &  ptrMessageMethod 
)
inline

adds a method for given message type where messages shall be delivered

Definition at line 123 of file MessageSubscriber.h.

void i6e::core::MessageSubscriber::buffer ( const ReceivedMessagePtr msg)

Calls deliverMessageInternal if the message should be delivered now, buffers it if not.

Parameters
msgMessage to be be delivered.
virtual void i6e::core::MessageSubscriber::deliverMessageInternal ( const ReceivedMessagePtr msg)
protectedvirtual

This method really delivers the Message without buffering it anymore.

Parameters
msgMessage to be delivered.
void i6e::core::MessageSubscriber::notifyNewID ( const int64_t  id)

This method notifies the MessagingController that Messages waiting for this id can now be delivered.

Parameters
idThe new id.
virtual void i6e::core::MessageSubscriber::processMessages ( )
virtual

This method goes through the local message buffer and calls the appropriate method of the receiver.

It is called prior to a tick in the main loop of every subsystem. This class must not be called explicitely. Subject to future refactoring to private scope.

Reimplemented in i6e::core::ModuleController.

void i6e::core::MessageSubscriber::receiveMessage ( const Message::Ptr msg)

This method is called from the MessagingController. It stores incoming messages in a local buffer.

Parameters
objMessageThe message to be stored in the buffer.
void i6e::core::MessageSubscriber::removeMethod ( uint16_t  msgType)
inline

removes method for given message type

Definition at line 130 of file MessageSubscriber.h.

void i6e::core::MessageSubscriber::reset ( )

todo

void i6e::core::MessageSubscriber::swapMessageBuffer ( )
protected

This method will swap the double message buffer. For synchronization reasons.

bool i6e::core::MessageSubscriber::updateBuffer ( )
protected

This method delivers all waiting Messages that can now be delivered.

Member Data Documentation

MessageVector* i6e::core::MessageSubscriber::_objActiveMessageVector
protected

Definition at line 159 of file MessageSubscriber.h.

MessageVector* i6e::core::MessageSubscriber::_objInActiveMessageVector
protected

Definition at line 160 of file MessageSubscriber.h.

MessageVector i6e::core::MessageSubscriber::_objMessageVectorA
protected

Definition at line 157 of file MessageSubscriber.h.

MessageVector i6e::core::MessageSubscriber::_objMessageVectorB
protected

Definition at line 158 of file MessageSubscriber.h.

boost::mutex i6e::core::MessageSubscriber::_objMessageVectorMutex
protected

Definition at line 156 of file MessageSubscriber.h.

std::map<uint16_t, boost::function<void(const Message::Ptr &)> > i6e::core::MessageSubscriber::_ptrMessageMethod
protected

Definition at line 162 of file MessageSubscriber.h.


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