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

Tools/MessageQueue/OutMessage.h

Go to the documentation of this file.
00001 /**
00002 * @file OutMessage.h
00003 *
00004 * Declaration of class OutMessageQueue, OutBinaryMessage, OutTextMessage and OutMessage.
00005 *
00006 * Include that file in implementation files that only want to write to MessageQueues.
00007 * (Usually it lasts to include "Tools/Debugging/Debugging.h")
00008 *
00009 * @author Martin Lötzsch
00010 */
00011 
00012 #ifndef __OutMessage_h_
00013 #define __OutMessage_h_
00014 
00015 #include "Tools/Streams/OutStreams.h"
00016 #include "Platform/MessageQueueBase.h"
00017 
00018 /**
00019 * @class OutMessageQueue.
00020 *
00021 * A PhysicalOutStream that writes the data to a MessageQueue.
00022 */
00023 class OutMessageQueue : public PhysicalOutStream
00024 {
00025 private:
00026   /** The queue where the data is written to */
00027   MessageQueueBase* queue; 
00028   
00029 public:
00030   /** Default constructor */
00031   OutMessageQueue();
00032   
00033 protected:
00034 /**
00035 * opens the stream.
00036 * @param q A pointer to the message queue base
00037   */
00038   void open(MessageQueueBase* q);
00039   
00040 /**
00041 * The function writes a number of bytes into a physical stream.
00042 * @param p The address the data is located at.
00043 * @param size The number of bytes to be written.
00044   */
00045   virtual void writeToStream(const void* p,int size);
00046 };
00047 
00048 /** 
00049 * @class OutBinaryMessage
00050 *
00051 * A binary stream into a message queue.
00052 */
00053 class OutBinaryMessage : public OutStream<OutMessageQueue,OutBinary>
00054 {
00055 public:
00056 /** 
00057 * Constructor 
00058 * @param q A pointer to the message queue base
00059   */
00060   OutBinaryMessage(MessageQueueBase* q);
00061 };
00062 
00063 /** 
00064 * @class OutTextMessage
00065 *
00066 * A text stream into a message queue.
00067 */
00068 class OutTextMessage : public OutStream<OutMessageQueue,OutText>
00069 {
00070 public:
00071 /** 
00072 * Constructor 
00073 * @param q A pointer to the message queue base
00074   */
00075   OutTextMessage(MessageQueueBase* q);
00076 };
00077 
00078 /** 
00079 * @class OutTextRawMessage
00080 *
00081 * A text stream into a message queue.
00082 */
00083 class OutTextRawMessage : public OutStream<OutMessageQueue,OutTextRaw>
00084 {
00085 public:
00086 /** 
00087 * Constructor 
00088 * @param q A pointer to the message queue base
00089   */
00090   OutTextRawMessage(MessageQueueBase* q);
00091 };
00092 
00093 /**
00094 * @class OutMessage
00095 *
00096 * An Interface for writing messages into a MessageQueue.
00097 *
00098 * Use the bin or text member for formated writing into a message queue. 
00099 */
00100 class OutMessage
00101 {
00102 private:
00103 /** 
00104 * The message queue where the messages are written into. 
00105   */
00106   MessageQueueBase& queue;
00107   
00108 public:
00109   /** An interface for writing binary messages into the queue */ 
00110   OutBinaryMessage bin;
00111   
00112   /** An interface for writing text messages into the queue */ 
00113   OutTextMessage text;
00114   
00115   /** 
00116   * An interface for writing text messages in a raw style (see class OutTextRaw) 
00117   * into the queue 
00118   */ 
00119   OutTextMessage textRaw;
00120   
00121   /** 
00122   * Constructor
00123   * @param queue A reference to a MessageQueueBase
00124   */
00125   OutMessage(MessageQueueBase& queue);
00126 
00127   /** 
00128   * Finishes the message and allows to write a new message. 
00129   * Call that function after the writing of every message.
00130   * @param id The type id of the message
00131   */
00132   void finishMessage(MessageID id);
00133 
00134 protected:
00135   /** 
00136   * Finishes the message and allows to write a new message. 
00137   * @param id The type id of the message
00138   * @param timeStamp The time stamp of the message
00139   * @param teamColor the team color of the robot that sent the message
00140   * @param playerNumber the player number of the robot that sent the message 
00141   * @param messageWasSentFromAPhysicalRobot If true, then the message was sent 
00142   *     from a physical robot.  
00143   */
00144   void finishMessage(MessageID id, unsigned long timeStamp,
00145     Player::teamColor teamColor,Player::playerNumber playerNumber,
00146     bool messageWasSentFromAPhysicalRobot);
00147 
00148   /** The player's team color that is attached to new messages */
00149   Player::teamColor teamColorForNewMessages;
00150 
00151   /** The player number that is attached to new messages */
00152   Player::playerNumber playerNumberForNewMessages;
00153 
00154   /** gives the MessageQueue class access to protected members */
00155   friend class MessageQueue;
00156 
00157   /** gives the InMessage class access to protected members */
00158   friend class InMessage;
00159 
00160   /** gives the operator that copies a InMessage to another queue access to protected members */
00161   friend void operator >> (InMessage& message, MessageQueue& queue);
00162 
00163   /** gives the In streaming opeator access to protected members */
00164   friend In& operator>>(In& stream,MessageQueue& messageQueue);
00165 };
00166 
00167 
00168 #endif //__OutMessage_h_
00169 
00170 /*
00171 * Change Log:
00172 *
00173 * $Log: OutMessage.h,v $
00174 * Revision 1.1.1.1  2004/05/22 17:37:19  cvsadm
00175 * created new repository GT2004_WM
00176 *
00177 * Revision 1.3  2004/01/28 20:52:32  loetzsch
00178 * Added the OutTextRaw stream writer.
00179 *
00180 * Revision 1.2  2003/12/06 23:23:55  loetzsch
00181 * messages in a MessageQueue now contain
00182 * - the team color of the robot which sent the message
00183 * - the player number of the robot which sent the message
00184 * - if the message was sent from a physical robot or not
00185 *
00186 * Revision 1.1  2003/10/07 10:13:24  cvsadm
00187 * Created GT2004 (M.J.)
00188 *
00189 * Revision 1.1.1.1  2003/07/02 09:40:28  cvsadm
00190 * created new repository for the competitions in Padova from the 
00191 * tamara CVS (Tuesday 2:00 pm)
00192 *
00193 * removed unused solutions
00194 *
00195 * Revision 1.3  2002/11/19 17:38:32  dueffert
00196 * doxygen bugs corrected
00197 *
00198 * Revision 1.2  2002/10/14 13:14:25  dueffert
00199 * doxygen comments corrected
00200 *
00201 * Revision 1.1  2002/09/10 15:53:59  cvsadm
00202 * Created new project GT2003 (M.L.)
00203 * - Cleaned up the /Src/DataTypes directory
00204 * - Removed challenge related source code
00205 * - Removed processing of incoming audio data
00206 * - Renamed AcousticMessage to SoundRequest
00207 *
00208 * Revision 1.1  2002/07/23 13:47:14  loetzsch
00209 * - new streaming classes
00210 * - new debug message handling
00211 * - exchanged StaticQueue by MessageQueue
00212 *
00213 */

Generated on Thu Sep 23 19:57:39 2004 for GT2004 by doxygen 1.3.6