00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 #ifndef __JAUS_CORE_TIME_QUERY_TIME__H 00041 #define __JAUS_CORE_TIME_QUERY_TIME__H 00042 00043 #include "jaus/core/corecodes.h" 00044 #include "jaus/core/message.h" 00045 00046 namespace JAUS 00047 { 00054 class QueryTime : public Message 00055 { 00056 public: 00064 class JAUS_CORE_DLL PresenceVector : public JAUS::PresenceVector 00065 { 00066 public: 00067 const static Byte Time = 0x01; 00068 const static Byte Date = 0x02; 00069 }; 00070 QueryTime(const Address& dest = Address(), 00071 const Address& src = Address()) : Message(QUERY_TIME, dest, src) 00072 { 00073 mPresenceVector = 0; 00074 } 00075 QueryTime(const QueryTime& message) : Message(QUERY_TIME) 00076 { 00077 *this = message; 00078 } 00079 ~QueryTime() 00080 { 00081 } 00082 void SetPresenceVector(const Byte presenceVector) { mPresenceVector = presenceVector; } 00083 // Return true if a command message, otherwise false. 00084 virtual bool IsCommand() const { return false; } 00085 // Writes message payload data to the packet at the current write position. 00086 virtual int WriteMessageBody(Packet& packet) const 00087 { 00088 int expected = BYTE_SIZE; 00089 int written = 0; 00090 written += packet.Write(mPresenceVector); 00091 return expected == written ? expected : -1; 00092 } 00093 // Reads message payload data from the packets current read position. 00094 virtual int ReadMessageBody(const Packet& packet) 00095 { 00096 int expected = BYTE_SIZE; 00097 int read = 0; 00098 read += packet.Read(mPresenceVector); 00099 return expected == read ? expected : -1; 00100 } 00101 // Make a copy of the message and returns pointer to it. 00102 virtual Message* Clone() const { return new QueryTime(*this); } 00103 // Gets the presence vector data for the message. 00104 virtual UInt GetPresenceVector() const { return mPresenceVector; } 00105 // Get the size of the message presence vector. 0 value indicates no presence vector. 00106 virtual UInt GetPresenceVectorSize() const { return BYTE_SIZE; } 00107 // Get the mask associated with presence vector. Indicates what bits are used. 00108 virtual UInt GetPresenceVectorMask() const { return 0x03; } 00109 // Gets the response type to the associated message, 0 if message is a response type. 00110 virtual UShort GetMessageCodeOfResponse() const { return REPORT_TIME; } 00111 // Gets the name of the message in human readable format (for logging, etc.) 00112 virtual std::string GetMessageName() const { return "Query Time"; } 00113 // Clears only message body information. 00114 virtual void ClearMessageBody() { mPresenceVector = 0;} 00115 // Return true if payload is greater than maxPaylodSize (payload == message data only). 00116 virtual bool IsLargeDataSet(const unsigned int maxPayloadSize) const { return false; } 00117 QueryTime& operator=(const QueryTime& message) 00118 { 00119 CopyHeaderData(&message); 00120 mPresenceVector = message.mPresenceVector; 00121 return *this; 00122 } 00123 protected: 00124 Byte mPresenceVector; 00125 }; 00126 } 00127 00128 #endif 00129 /* End of File */