Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Tools/MessageQueue/OutMessage.cpp

Go to the documentation of this file.

    00001 /**
    00002 * @file OutMessage.cpp
    00003 *
    00004 * Implementation of class OutMessage, OutBinaryMessage, OutTextMessage,
    00005 * OutConfigMessage and OutMessageQueue.
    00006 *
    00007 * @author Martin Lötzsch
    00008 */
    00009
    00010 #include "OutMessage.h"
    00011 #include "Tools/Process.h"
    00012
    00013 OutMessageQueue::OutMessageQueue()
    00014 : queue(0)
    00015 {
    00016 }
    00017
    00018 void OutMessageQueue::open(MessageQueueBase* q)
    00019 {
    00020   if (queue == 0) queue = q;
    00021 }
    00022
    00023 void OutMessageQueue::writeToStream(const void* p,int size)
    00024 {
    00025   if (queue != 0) queue->write(p,size);
    00026 }
    00027
    00028 OutBinaryMessage::OutBinaryMessage(MessageQueueBase* q)
    00029 {
    00030   open(q);
    00031 }
    00032
    00033 OutTextMessage::OutTextMessage(MessageQueueBase* q)
    00034 {
    00035   open(q);
    00036 }
    00037
    00038 OutTextRawMessage::OutTextRawMessage(MessageQueueBase* q)
    00039 {
    00040   open(q);
    00041 }
    00042
    00043 OutMessage::OutMessage(MessageQueueBase& queue)
    00044 : queue(queue), bin(&queue), text(&queue), textRaw(&queue),
    00045 teamColorForNewMessages(Player::undefinedTeamColor),
    00046 playerNumberForNewMessages(Player::undefinedPlayerNumber)
    00047 {
    00048 }
    00049
    00050 void OutMessage::finishMessage(MessageID id)
    00051 {
    00052 #ifdef NEWDEBUGGING
    00053   queue.finishMessage(id,Process::getFrameNumber(),
    00054     teamColorForNewMessages,playerNumberForNewMessages);
    00055 #else
    00056   queue.finishMessage(id,SystemCall::getCurrentSystemTime(),
    00057     teamColorForNewMessages,playerNumberForNewMessages);
    00058 #endif
    00059
    00060 }
    00061
    00062 void OutMessage::finishMessage(MessageID id, unsigned long timeStamp,
    00063                                Player::teamColor teamColor,
    00064                                Player::playerNumber playerNumber,
    00065                                bool messageWasSentFromAPhysicalRobot)
    00066 {
    00067   queue.finishMessage(id, timeStamp,teamColor,
    00068     playerNumber,messageWasSentFromAPhysicalRobot);
    00069 }