#include <MessageQueue.h>
Inheritance diagram for MessageQueue:
Public Member Functions | |
MessageQueue () | |
Default constructor. | |
void | setSize (int size) |
Sets the size of memory which is allocated for the queue. | |
int | getStreamedSize () |
Returns the size of memory which is needed to write the queue to a stream. | |
void | setPlayerForNewMessages (const Player &player) |
Specifies a team color and a player number that is atached to every new message. | |
void | handleSpecificMessages (MessageID id, MessageHandler &handler) |
Calls a given MessageHandler for all messages of a kind in the queue. | |
void | handleAllMessages (MessageHandler &handler) |
Calls a given MessageHandler for all messages in the queue. | |
void | copyAllMessages (MessageQueue &other) |
Copies all messages from this queue to another queue. | |
void | moveAllMessages (MessageQueue &other) |
Moves all messages from this queue to another queue. | |
void | removeRepetitions () |
Deletes all older messages from the queue if a newer message of same type is already in the queue. | |
void | clear () |
Removes all messages from the queue. | |
bool | isEmpty () const |
Returns if the queue contains no messages. | |
Public Attributes | |
InMessage | in |
An interface for reading messages from the queue. | |
OutMessage | out |
An interface for writing messages to the queue. | |
Protected Member Functions | |
void | copyMessage (int message, MessageQueue &other) |
Copies a single message to another queue. | |
Protected Attributes | |
MessageQueueBase | queue |
the system dependend message queue base which is responsible for the data storage | |
Friends | |
In & | operator>> (In &stream, MessageQueue &messageQueue) |
Gives the stream operator access to protected members. | |
Out & | operator<< (Out &stream, const MessageQueue &messageQueue) |
Gives the stream operator access to protected members. |
It can be used to collect very different types of messages for exchange between different threads, processes or systems.
MessageQueue myQueue; myQueue.setSize(100000); // set the size of data that can be stored in the queue Image image1; myQueue.out.bin << image1; // write the binary message myQueue.out.finishMessage(idImage); // finish the message, set the type id of the message // // ... copy the queue between processes, systems // if (myQueue.in.getMessageID() == idImage) // check for the type of the next message { Image image2; myQueue.in.bin >> image2; // read the image from the queue }
Definition at line 43 of file MessageQueue.h.
Constructor & Destructor Documentation
|
Default constructor.
Definition at line 12 of file MessageQueue.cpp. References ASSERT, and idJPEGImage. |
|
Sets the size of memory which is allocated for the queue. Ignored on the Win32 platform (dynamic allocation).
Definition at line 18 of file MessageQueue.cpp. References MessageQueueBase::setSize(). Referenced by Cognition::Cognition(), Debug::Debug(), Logger::Logger(), and Motion::Motion(). |
Here is the call graph for this function:
|
Returns the size of memory which is needed to write the queue to a stream.
Definition at line 141 of file MessageQueue.cpp. References InMessage::getMessageSize(), MessageQueueBase::getNumberOfMessages(), in, and MessageQueueBase::setSelectedMessageForReading(). |
Here is the call graph for this function:
|
Specifies a team color and a player number that is atached to every new message. If not set, Player::undefinedTeamColor and Player::undefinedPlayerNumber is used. Definition at line 23 of file MessageQueue.cpp. References Player::getPlayerNumber(), Player::getTeamColor(), out, OutMessage::playerNumberForNewMessages, and OutMessage::teamColorForNewMessages. Referenced by Process::processMain(). |
Here is the call graph for this function:
|
Calls a given MessageHandler for all messages of a kind in the queue. Note that the messages still remain in the queue and have to be removed manually with clear().
Definition at line 29 of file MessageQueue.cpp. References InMessage::config, InMessage::getMessageID(), MessageQueueBase::getNumberOfMessages(), MessageHandler::handleMessage(), in, InText::reset(), MessageQueueBase::setSelectedMessageForReading(), and InMessage::text. |
Here is the call graph for this function:
|
Calls a given MessageHandler for all messages in the queue. Note that the messages still remain in the queue and have to be removed manually with clear().
Definition at line 43 of file MessageQueue.cpp. References InMessage::config, MessageQueueBase::getNumberOfMessages(), MessageHandler::handleMessage(), in, InText::reset(), MessageQueueBase::setSelectedMessageForReading(), and InMessage::text. Referenced by Logger::init(), Debug::init(), Logger::main(), and Process::processMain(). |
Here is the call graph for this function:
|
Copies all messages from this queue to another queue.
Definition at line 54 of file MessageQueue.cpp. References copyMessage(), and MessageQueueBase::getNumberOfMessages(). Referenced by moveAllMessages(). |
Here is the call graph for this function:
|
Moves all messages from this queue to another queue.
Definition at line 62 of file MessageQueue.cpp. References clear(), and copyAllMessages(). |
Here is the call graph for this function:
|
Deletes all older messages from the queue if a newer message of same type is already in the queue. This method should not be called during message handling. Definition at line 106 of file MessageQueue.h. References MessageQueueBase::removeRepetitions(). Referenced by Logger::main(), and Debug::main(). |
Here is the call graph for this function:
|
Removes all messages from the queue.
Definition at line 68 of file MessageQueue.cpp. References MessageQueueBase::clear(). Referenced by LogPlayer::_new(), Logger::init(), Logger::main(), Debug::main(), moveAllMessages(), LogPlayer::open(), and Process::processMain(). |
Here is the call graph for this function:
|
Returns if the queue contains no messages.
Definition at line 73 of file MessageQueue.cpp. References MessageQueueBase::getNumberOfMessages(). Referenced by Logger::main(), and Debug::main(). |
Here is the call graph for this function:
|
Copies a single message to another queue.
Definition at line 78 of file MessageQueue.cpp. References OutMessage::bin, OutMessage::finishMessage(), MessageQueueBase::getData(), MessageQueueBase::getMessageID(), MessageQueueBase::getMessageSize(), MessageQueueBase::getMessageWasSentFromAPhysicalRobot(), MessageQueueBase::getPlayerNumber(), MessageQueueBase::getTeamColor(), MessageQueueBase::getTimeStamp(), out, MessageQueueBase::setSelectedMessageForReading(), and OutStream< OutMessageQueue, OutBinary >::write(). Referenced by copyAllMessages(), LogPlayer::jumpFrame(), LogPlayer::onIdle(), LogPlayer::stepBackward(), LogPlayer::stepForward(), and LogPlayer::stepRepeat(). |
Here is the call graph for this function:
|
Gives the stream operator access to protected members.
Definition at line 104 of file MessageQueue.cpp. |
|
Gives the stream operator access to protected members.
Definition at line 153 of file MessageQueue.cpp. |
|
the system dependend message queue base which is responsible for the data storage
Definition at line 47 of file MessageQueue.h. Referenced by operator<<(). |
|
An interface for reading messages from the queue.
Definition at line 51 of file MessageQueue.h. Referenced by getStreamedSize(), handleAllMessages(), handleSpecificMessages(), and operator<<(). |
|
An interface for writing messages to the queue.
Definition at line 54 of file MessageQueue.h. Referenced by copyMessage(), operator>>(), and setPlayerForNewMessages(). |