Yagl::MessageReceiver Class Reference

#include <messagereceiver.h>

List of all members.

Public Member Functions

 MessageReceiver ()
virtual ~MessageReceiver ()
 Destructor note that the all stored messages that have not been popped yet will be deleted.
void pushMessage (Message &message)
 pushes a message to the message queue
MessagepopMessage ()
 pops the first message in the queue
virtual void receivedMessage ()
 called when a message has arrived

Protected Member Functions

 MessageReceiver (const MessageReceiver &receiver)

Protected Attributes

std::list< Message * > messages_
 messages stored and not popped yet
Mutex message_list_lock_
 lock to make access to messages_ threadsafe


Detailed Description

MessageReceiver this class provides a mechanism similar to BiDirectionalConnectionReceiver. it gives the user to asynchroniously store and retrieve Messages in the form of a queue. this is especially usefull in concurrent programming situations. within the Yagl networking library it is used as a communications channel between the receiving thread of a BiDirectionalConnection and the main programming that wants to retrieve all incoming messages on that connection. This class is of course threadsafe

See also:
BiDirectionalConnection::receive()


Constructor & Destructor Documentation

Yagl::MessageReceiver::MessageReceiver const MessageReceiver receiver  )  [protected]
 

copy constructor hidden

Yagl::MessageReceiver::MessageReceiver  ) 
 

Constructor


Member Function Documentation

Message* Yagl::MessageReceiver::popMessage  ) 
 

pops the first message in the queue

this method will pop the first message in the queue and return a pointer to it. the calling method has to destroy ( delete ) the message itself or memory leaks will occur.

Returns:
a Message pointer

void Yagl::MessageReceiver::pushMessage Message message  ) 
 

pushes a message to the message queue

this will add the given message to the queue. a deep copy is performed and the passed message is untouched.

Parameters:
message the message to add to the queue

virtual void Yagl::MessageReceiver::receivedMessage  )  [virtual]
 

called when a message has arrived

this message is intended to be overwritten if a notification is wanted in case a message arrives. simply overwrite this to process incoming messages


The documentation for this class was generated from the following file:
Generated on Tue Jan 10 15:42:38 2006 for YAGL - yet another gameprogramming library by  doxygen 1.4.5