Go to the documentation of this file.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
00041
00042
00043
00044
00045
00046 #ifndef __JAUS_CORE_MESSAGE_H
00047 #define __JAUS_CORE_MESSAGE_H
00048
00049 #include "header.h"
00050 #include "bitvector.h"
00051 #include "transport/largedataset.h"
00052
00053 namespace JAUS
00054 {
00069 class JAUS_CORE_DLL Message
00070 {
00071 public:
00072 typedef Header::Priority Priority;
00073 typedef std::vector<Message*> List;
00074 typedef std::map<UShort, Message*> Map;
00075
00076 Message(const UShort messageCode, const Address& dest = Address(), const Address& src = Address());
00077
00078 virtual ~Message();
00079
00080 virtual bool IsCommand() const = 0;
00081
00082 virtual int WriteMessageBody(Packet& packet) const = 0;
00083
00084 virtual int ReadMessageBody(const Packet& packet) = 0;
00085
00086 virtual Message* Clone() const = 0;
00087
00088 virtual UInt GetPresenceVector() const = 0;
00089
00090 virtual UInt GetPresenceVectorSize() const = 0;
00091
00092 virtual UInt GetPresenceVectorMask() const = 0;
00093
00094 virtual UShort GetMessageCodeOfResponse() const = 0;
00095
00096 virtual std::string GetMessageName() const = 0;
00097
00098 virtual void ClearMessageBody() = 0;
00099
00100 virtual bool IsLargeDataSet(const unsigned int maxPayloadSize = 1437) const = 0;
00101
00102 int SetPriority(const Byte p = Header::Priority::Standard);
00103
00104 int SetSourceID(const Address &src);
00105
00106 int SetDestinationID(const Address &dest);
00107
00108 int SwapSourceAndDestination();
00109
00110 void CopyHeaderData(const Message* msg);
00111
00112 void ClearMessageHeader();
00113
00114 void ClearMessage();
00115
00116 inline UShort GetMessageCode() const { return mMessageCode; }
00117
00118 inline Byte GetPriority() const { return mPriority; }
00119
00120 inline Address GetSourceID() const { return mSourceID; }
00121
00122 inline Address GetDestinationID() const { return mDestinationID; }
00123
00124 inline bool IsFieldPresent(const UInt presenceVector) const { return (GetPresenceVector() & presenceVector) > 0 ;}
00125
00126 inline bool AreFieldsPresent(const UInt presenceVector) const { return (GetPresenceVector() & presenceVector) == presenceVector; }
00127
00128 virtual void Print() const;
00129
00130 virtual void PrintMessageBody() const {}
00131
00132 virtual int RunTestCase() const { return FAILURE; }
00133
00134 virtual bool IsResponseToMessage(const Message* requestingMessage) const;
00135
00136 virtual int Write(Packet& packet,
00137 Header& header,
00138 const Packet* transportHeader = NULL,
00139 const bool clearPacket = true,
00140 const UShort startingSequenceNumber = 0,
00141 const Byte broadcastFlag = 0) const;
00142
00143 virtual int WriteLargeDataSet(Packet::List& stream,
00144 Header::List& streamHeaders,
00145 const UShort maxPayloadSize = 1437,
00146 const Packet* transportHeader = NULL,
00147 const UShort startingSequenceNumber = 0,
00148 const Byte broadcastFlag = 0) const;
00149
00150 virtual int Read(const Packet &packet, const Packet* transportHeader = NULL);
00151
00152 virtual int ReadLargeDataSet(const Packet::List& stream,
00153 const Packet* transportHeader = NULL);
00154
00155 virtual int ReadLargeDataSet(const std::map<UShort, Packet>& stream,
00156 const Packet* transportHeader = NULL);
00157 protected:
00158 Byte mPriority;
00159 UShort mMessageCode;
00160 Address mSourceID;
00161 Address mDestinationID;
00162 private:
00163 Packet mStreamPayload;
00164 };
00165
00166 }
00167
00168 #endif
00169