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.
int | lastMessage
| Cache the current message in the message queue.

## 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 lastMessage, 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 47 of file MessageQueueBase.cpp. References numOfMessages. Referenced by MessageQueue::copyAllMessages(), LogPlayer::getNumberOfMessages(), MessageQueue::getStreamedSize(), MessageQueue::handleAllMessages(), MessageQueue::handleSpecificMessages(), MessageQueue::isEmpty(), operator<<(), and LogPlayer::saveSynchronized().

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 52 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 65 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 280 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 210 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 217 of file MessageQueueBase.cpp. References selectedMessageForReadingPosition. Referenced by MessageQueue::copyMessage(), InMessage::getData(), removeRepetitions(), and LogPlayer::saveSynchronized().

MessageID MessageQueueBase::getMessageID | ( |  | ) | const

| Returns the message id of the currently selected message for reading. Definition at line 248 of file MessageQueueBase.cpp. References MessageID, and selectedMessageForReadingPosition. Referenced by MessageQueue::copyMessage(), LogPlayer::getCurrentMessageID(), InMessage::getMessageID(), removeRepetitions(), LogPlayer::saveSynchronized(), and LogPlayer::statistics().

unsigned long MessageQueueBase::getTimeStamp | ( | int | message | ) |

  | Returns the time stamp of a message. Parameters:
  message | the number of the message
Definition at line 242 of file MessageQueueBase.cpp. References getTimeStamp(), and setSelectedMessageForReading(). Referenced by MessageQueue::copyMessage(), LogPlayer::getTimeStamp(), InMessage::getTimeStamp(), and LogPlayer::saveSynchronized().

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 235 of file MessageQueueBase.cpp. References selectedMessageForReadingPosition. Referenced by getTimeStamp(), and removeRepetitions().

int MessageQueueBase::getMessageSize | ( |  | ) | const

| Returns the message size of the currently selected message for reading. Definition at line 222 of file MessageQueueBase.cpp. References selectedMessageForReadingPosition. Referenced by MessageQueue::copyMessage(), eof(), InMessage::getMessageSize(), read(), removeRepetitions(), LogPlayer::saveSynchronized(), 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 258 of file MessageQueueBase.cpp. References selectedMessageForReadingPosition. Referenced by MessageQueue::copyMessage(), InMessage::getRobotNumber(), InMessage::getTeamColor(), and LogPlayer::saveSynchronized().

Player::playerNumber MessageQueueBase::getPlayerNumber | ( |  | ) | const

| returns the player number of the robot that sent the currently selected message for reading. Definition at line 265 of file MessageQueueBase.cpp. References selectedMessageForReadingPosition. Referenced by MessageQueue::copyMessage(), InMessage::getPlayerNumber(), InMessage::getRobotNumber(), and LogPlayer::saveSynchronized().

bool MessageQueueBase::getMessageWasSentFromAPhysicalRobot | ( |  | ) | const

| returns whether the currently selected message for reading was sent from a physical robot Definition at line 272 of file MessageQueueBase.cpp. References selectedMessageForReadingPosition. Referenced by MessageQueue::copyMessage(), InMessage::getMessageWasSentFromAPhysicalRobot(), and LogPlayer::saveSynchronized().

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 230 of file MessageQueueBase.cpp. References readPosition. Referenced by InMessage::resetReadPosition().

void MessageQueueBase::setSelectedMessageForReading | ( | int | message | ) |

| Definition at line 189 of file MessageQueueBase.cpp. References ASSERT, getMessageSize(), lastMessage, numOfMessages, readPosition, and selectedMessageForReadingPosition. Referenced by MessageQueue::copyMessage(), MessageQueue::getStreamedSize(), getTimeStamp(), MessageQueue::handleAllMessages(), MessageQueue::handleSpecificMessages(), LogPlayer::keep(), CLogAnalyzerBase::readLogfile(), LogPlayer::remove(), LogPlayer::saveAMV(), LogPlayer::saveCSV(), LogPlayer::saveImages(), LogPlayer::saveSynchronized(), and LogPlayer::statistics().

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 85 of file MessageQueueBase.cpp. References getData(), getMessageID(), getMessageSize(), getTimeStamp(), idDebugDataResponse, idDebugDrawing2, idDebugDrawingFinished, idDebugRequest, idDebugResponse, idDrawingManager, idModuleSolutionTable, idProcessFinished, idStopwatch, idStreamSpecification, idText, lastMessage, 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().

int MessageQueueBase::lastMessage`[private]`

| Cache the current message in the message queue. Definition at line 154 of file MessageQueueBase.h. Referenced by clear(), removeRepetitions(), and setSelectedMessageForReading().

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

- Platform/Aperios1.3.2/MessageQueueBase.h
- Platform/Aperios1.3.2/MessageQueueBase.cpp