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

MessageQueueBase Class Reference

The platform dependend base of class MessageQueue. More...

#include <MessageQueueBase.h>

List of all members.

Public Member Functions

 MessageQueueBase ()
 Constructor.

 ~MessageQueueBase ()
 Destructor.

void setSize (int size)
 Sets the size of the queue.

void clear ()
 Removes all messages from the queue.

int getNumberOfMessages () const
 Returns the number of the messages in the queue.

virtual void write (const void *p, int size)
 The function adds a number of bytes to the last message in the queue.

void finishMessage (MessageID id, unsigned long timeStamp, Player::teamColor teamColor, Player::playerNumber playerNumber, bool messageWasSentFromAPhysicalRobot=true)
 Finishes the last message in the queue.

bool eof () const
 Returns if the the currently selected message for reading was read completely.

void read (void *p, int size)
 Reads a number of bytes from the currently selected message for reading.

const char * getData () const
 Gives the MessageQueue direct read access to the selected message for reading.

MessageID getMessageID () const
 Returns the message id of the currently selected message for reading.

unsigned long getTimeStamp (int message)
 Returns the time stamp of a message.

unsigned long getTimeStamp () const
 Returns the time stamp of the currently selected message for reading.

int getMessageSize () const
 Returns the message size of the currently selected message for reading.

Player::teamColor getTeamColor () const
 returns the team color of the robot that sent the currently selected message for reading.

Player::playerNumber getPlayerNumber () const
 returns the player number of the robot that sent the currently selected message for reading.

bool getMessageWasSentFromAPhysicalRobot () const
 returns whether the currently selected message for reading was sent from a physical robot

void resetReadPosition ()
 Returns the read position of the currently selected message for reading so that the message can be read again.

void setSelectedMessageForReading (int message)
void removeRepetitions ()
 Deletes all older messages from the queue if a newer message of same type is already in the queue.


Private Attributes

char * buf
 the buffer on that the queue works

int selectedMessageForReadingPosition
 the position of the message that is selected for reading

int numOfMessages
 the number of stored messages

int queueSize
 the queue size

int nextMessagePosition
 the position where the next message starts (in bytes)

int nextMessageSize
 the current size of the next message

bool writingOfLastMessageFailed
 If true, then the writing of the last message failed because there was not enough space.

int readPosition
 The position up to where a message is already read.


Detailed Description

The platform dependend base of class MessageQueue.

This version works on a static memory buffer to avoid often memory allocations on the Aperios platform.

Use setSize(int size) to set the total size of data the queue can store. If a message doesn't fit into the queue, it is ignored.

Author:
Martin Lötzsch

Definition at line 27 of file MessageQueueBase.h.


Constructor & Destructor Documentation

MessageQueueBase::MessageQueueBase  ) 
 

Constructor.

Definition at line 17 of file MessageQueueBase.cpp.

References clear().

Here is the call graph for this function:

MessageQueueBase::~MessageQueueBase  ) 
 

Destructor.

Definition at line 23 of file MessageQueueBase.cpp.


Member Function Documentation

void MessageQueueBase::setSize int  size  ) 
 

Sets the size of the queue.

Ignored on the Win32 platform.

Parameters:
size The maximum size of the queue in Bytes.

Definition at line 28 of file MessageQueueBase.cpp.

References ASSERT, and queueSize.

Referenced by MessageQueue::setSize().

void MessageQueueBase::clear  ) 
 

Removes all messages from the queue.

Definition at line 36 of file MessageQueueBase.cpp.

References nextMessagePosition, nextMessageSize, numOfMessages, readPosition, selectedMessageForReadingPosition, and writingOfLastMessageFailed.

Referenced by MessageQueue::clear(), and MessageQueueBase().

int MessageQueueBase::getNumberOfMessages  )  const
 

Returns the number of the messages in the queue.

Definition at line 46 of file MessageQueueBase.cpp.

References numOfMessages.

Referenced by MessageQueue::copyAllMessages(), LogPlayer::getNumberOfMessages(), MessageQueue::getStreamedSize(), MessageQueue::handleAllMessages(), MessageQueue::handleSpecificMessages(), MessageQueue::isEmpty(), and operator<<().

void MessageQueueBase::write const void *  p,
int  size
[virtual]
 

The function adds a number of bytes to the last message in the queue.

Parameters:
p The address the data is located at.
size The number of bytes to be written.

Definition at line 51 of file MessageQueueBase.cpp.

References nextMessagePosition, nextMessageSize, queueSize, and writingOfLastMessageFailed.

Referenced by OutMessageQueue::writeToStream().

void MessageQueueBase::finishMessage MessageID  id,
unsigned long  timeStamp,
Player::teamColor  teamColor,
Player::playerNumber  playerNumber,
bool  messageWasSentFromAPhysicalRobot = true
 

Finishes the last message in the queue.

The number of messages becomes increased and a new message can be started.

Parameters:
id The type id of the message.
timeStamp The time stamp of the message
teamColor the team color of the robot that sent the message
playerNumber the player number of the robot that sent the message
messageWasSentFromAPhysicalRobot If true, then the message was sent from a physical robot. Is set to false on all non-Aperios/OpenR platforms.

Definition at line 64 of file MessageQueueBase.cpp.

References ASSERT, nextMessagePosition, nextMessageSize, numOfMessages, and writingOfLastMessageFailed.

Referenced by OutMessage::finishMessage().

bool MessageQueueBase::eof  )  const
 

Returns if the the currently selected message for reading was read completely.

Definition at line 240 of file MessageQueueBase.cpp.

References getMessageSize(), and readPosition.

Referenced by InMessageQueue::getEof().

Here is the call graph for this function:

void MessageQueueBase::read void *  p,
int  size
 

Reads a number of bytes from the currently selected message for reading.

Parameters:
p The address the data is written to. Note that p must point to a memory area that is at least "size" bytes large.
size The number of bytes to be read.

Definition at line 173 of file MessageQueueBase.cpp.

References ASSERT, getMessageSize(), readPosition, and selectedMessageForReadingPosition.

Referenced by InMessageQueue::readFromStream().

Here is the call graph for this function:

const char * MessageQueueBase::getData  )  const
 

Gives the MessageQueue direct read access to the selected message for reading.

Returns:
the address of the first byte of the message

Definition at line 180 of file MessageQueueBase.cpp.

References selectedMessageForReadingPosition.

Referenced by MessageQueue::copyMessage(), InMessage::getData(), and removeRepetitions().

MessageID MessageQueueBase::getMessageID  )  const
 

Returns the message id of the currently selected message for reading.

Definition at line 211 of file MessageQueueBase.cpp.

References MessageID, and selectedMessageForReadingPosition.

Referenced by MessageQueue::copyMessage(), LogPlayer::getCurrentMessageID(), InMessage::getMessageID(), and removeRepetitions().

unsigned long MessageQueueBase::getTimeStamp int  message  ) 
 

Returns the time stamp of a message.

Parameters:
message the number of the message

Definition at line 205 of file MessageQueueBase.cpp.

References getTimeStamp(), and setSelectedMessageForReading().

Referenced by MessageQueue::copyMessage(), LogPlayer::getTimeStamp(), and InMessage::getTimeStamp().

Here is the call graph for this function:

unsigned long MessageQueueBase::getTimeStamp  )  const
 

Returns the time stamp of the currently selected message for reading.

Definition at line 198 of file MessageQueueBase.cpp.

References selectedMessageForReadingPosition.

Referenced by getTimeStamp().

int MessageQueueBase::getMessageSize  )  const
 

Returns the message size of the currently selected message for reading.

Definition at line 185 of file MessageQueueBase.cpp.

References selectedMessageForReadingPosition.

Referenced by MessageQueue::copyMessage(), eof(), InMessage::getMessageSize(), read(), removeRepetitions(), and setSelectedMessageForReading().

Player::teamColor MessageQueueBase::getTeamColor  )  const
 

returns the team color of the robot that sent the currently selected message for reading.

Definition at line 218 of file MessageQueueBase.cpp.

References selectedMessageForReadingPosition.

Referenced by MessageQueue::copyMessage(), InMessage::getRobotNumber(), and InMessage::getTeamColor().

Player::playerNumber MessageQueueBase::getPlayerNumber  )  const
 

returns the player number of the robot that sent the currently selected message for reading.

Definition at line 225 of file MessageQueueBase.cpp.

References selectedMessageForReadingPosition.

Referenced by MessageQueue::copyMessage(), InMessage::getPlayerNumber(), and InMessage::getRobotNumber().

bool MessageQueueBase::getMessageWasSentFromAPhysicalRobot  )  const
 

returns whether the currently selected message for reading was sent from a physical robot

Definition at line 232 of file MessageQueueBase.cpp.

References selectedMessageForReadingPosition.

Referenced by MessageQueue::copyMessage(), and InMessage::getMessageWasSentFromAPhysicalRobot().

void MessageQueueBase::resetReadPosition  ) 
 

Returns the read position of the currently selected message for reading so that the message can be read again.

Definition at line 193 of file MessageQueueBase.cpp.

References readPosition.

Referenced by InMessage::resetReadPosition().

void MessageQueueBase::setSelectedMessageForReading int  message  ) 
 

Definition at line 160 of file MessageQueueBase.cpp.

References ASSERT, getMessageSize(), numOfMessages, readPosition, and selectedMessageForReadingPosition.

Referenced by MessageQueue::copyMessage(), MessageQueue::getStreamedSize(), getTimeStamp(), MessageQueue::handleAllMessages(), MessageQueue::handleSpecificMessages(), LogPlayer::saveAMV(), LogPlayer::saveCSV(), and LogPlayer::saveImages().

Here is the call graph for this function:

void MessageQueueBase::removeRepetitions  ) 
 

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 84 of file MessageQueueBase.cpp.

References getData(), getMessageID(), getMessageSize(), idDebugDrawing2, idDebugDrawingFinished, idStopwatch, idText, nextMessagePosition, numOfMessageIDs, numOfMessages, readPosition, selectedMessageForReadingPosition, and Drawings::TypeOfDrawing.

Referenced by MessageQueue::removeRepetitions().

Here is the call graph for this function:


Member Data Documentation

char* MessageQueueBase::buf [private]
 

the buffer on that the queue works

Definition at line 130 of file MessageQueueBase.h.

int MessageQueueBase::selectedMessageForReadingPosition [private]
 

the position of the message that is selected for reading

Definition at line 133 of file MessageQueueBase.h.

Referenced by clear(), getData(), getMessageID(), getMessageSize(), getMessageWasSentFromAPhysicalRobot(), getPlayerNumber(), getTeamColor(), getTimeStamp(), read(), removeRepetitions(), and setSelectedMessageForReading().

int MessageQueueBase::numOfMessages [private]
 

the number of stored messages

Definition at line 136 of file MessageQueueBase.h.

Referenced by clear(), finishMessage(), getNumberOfMessages(), removeRepetitions(), and setSelectedMessageForReading().

int MessageQueueBase::queueSize [private]
 

the queue size

Definition at line 139 of file MessageQueueBase.h.

Referenced by setSize(), and write().

int MessageQueueBase::nextMessagePosition [private]
 

the position where the next message starts (in bytes)

Definition at line 142 of file MessageQueueBase.h.

Referenced by clear(), finishMessage(), removeRepetitions(), and write().

int MessageQueueBase::nextMessageSize [private]
 

the current size of the next message

Definition at line 145 of file MessageQueueBase.h.

Referenced by clear(), finishMessage(), and write().

bool MessageQueueBase::writingOfLastMessageFailed [private]
 

If true, then the writing of the last message failed because there was not enough space.

Definition at line 148 of file MessageQueueBase.h.

Referenced by clear(), finishMessage(), and write().

int MessageQueueBase::readPosition [private]
 

The position up to where a message is already read.

Definition at line 151 of file MessageQueueBase.h.

Referenced by clear(), eof(), read(), removeRepetitions(), resetReadPosition(), and setSelectedMessageForReading().


The documentation for this class was generated from the following files:
Generated on Thu Sep 23 20:09:35 2004 for GT2004 by doxygen 1.3.6