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 #include "jaus/core/events/queryevents.h" 00041 00042 using namespace JAUS; 00043 00052 QueryEvents::QueryEvents(const Address& dest, 00053 const Address& src) : Message(QUERY_EVENTS, dest, src) 00054 { 00055 mQueryType = MessageID; 00056 mQueryFilter = 0; 00057 } 00058 00059 00065 QueryEvents::QueryEvents(const QueryEvents& message) : Message(QUERY_EVENTS) 00066 { 00067 mQueryType = MessageID; 00068 mQueryFilter = 0; 00069 *this = message; 00070 } 00071 00072 00078 QueryEvents::~QueryEvents() 00079 { 00080 00081 } 00082 00083 00095 int QueryEvents::WriteMessageBody(Packet& packet) const 00096 { 00097 int total = 0; 00098 int expected = BYTE_SIZE; 00099 total += packet.WriteByte((Byte)mQueryType); 00100 switch(mQueryType) 00101 { 00102 case MessageID: 00103 expected += USHORT_SIZE; 00104 total += packet.Write(mQueryFilter); 00105 break; 00106 case EventType: 00107 case EventID: 00108 case AllEvents: 00109 default: 00110 expected += BYTE_SIZE; 00111 total += packet.WriteByte( (Byte)(mQueryFilter) ); 00112 break; 00113 }; 00114 return total == expected ? total : -1; 00115 } 00116 00117 00129 int QueryEvents::ReadMessageBody(const Packet& packet) 00130 { 00131 int total = 0; 00132 int expected = BYTE_SIZE; 00133 total += packet.Read((Byte &)mQueryType); 00134 switch(mQueryType) 00135 { 00136 case MessageID: 00137 expected += USHORT_SIZE; 00138 total += packet.Read(mQueryFilter); 00139 break; 00140 case EventType: 00141 case EventID: 00142 case AllEvents: 00143 default: 00144 { 00145 Byte data = 0; 00146 expected += BYTE_SIZE; 00147 total += packet.Read( data ); 00148 mQueryFilter = data; 00149 } 00150 break; 00151 }; 00152 return total == expected ? total : -1; 00153 } 00154 00155 00161 void QueryEvents::ClearMessageBody() 00162 { 00163 mQueryType = MessageID; 00164 mQueryFilter = 0; 00165 } 00166 00167 00173 QueryEvents& QueryEvents::operator =(const QueryEvents& message) 00174 { 00175 if(this != &message) 00176 { 00177 CopyHeaderData(&message); 00178 mQueryType = message.mQueryType; 00179 mQueryFilter = message.mQueryFilter; 00180 } 00181 return *this; 00182 } 00183 00184 00185 /* End of File */