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/discovery/reportsubsystemlist.h" 00041 00042 using namespace JAUS; 00043 00044 00053 ReportSubsystemList::ReportSubsystemList(const Address& dest, 00054 const Address& src) : Message(REPORT_SUBSYSTEM_LIST, dest, src) 00055 { 00056 } 00057 00058 00064 ReportSubsystemList::ReportSubsystemList(const ReportSubsystemList& message) : Message(REPORT_SUBSYSTEM_LIST) 00065 { 00066 *this = message; 00067 } 00068 00069 00075 ReportSubsystemList::~ReportSubsystemList() 00076 { 00077 00078 } 00079 00080 00092 int ReportSubsystemList::WriteMessageBody(Packet& packet) const 00093 { 00094 int total = 0; 00095 int expected = BYTE_SIZE; 00096 total += packet.WriteByte((Byte)mSubsystemList.size()); 00097 00098 Address::List::const_iterator id; 00099 for(id = mSubsystemList.begin(); 00100 id != mSubsystemList.end(); 00101 id++) 00102 { 00103 expected += BYTE_SIZE*4; 00104 total += packet.Write(id->ToUInt()); 00105 } 00106 00107 return total == expected ? total : -1; 00108 } 00109 00110 00122 int ReportSubsystemList::ReadMessageBody(const Packet& packet) 00123 { 00124 int total = 0; 00125 int expected = BYTE_SIZE; 00126 Byte count1 = 0; 00127 00128 total += packet.Read(count1); 00129 for(Byte i = 0; i < count1; i++) 00130 { 00131 UInt id; 00132 expected += UINT_SIZE; 00133 total += packet.Read(id); 00134 mSubsystemList.push_back(Address(id)); 00135 } 00136 00137 return total == expected ? total : -1; 00138 } 00139 00140 00146 void ReportSubsystemList::ClearMessageBody() 00147 { 00148 mSubsystemList.clear(); 00149 } 00150 00151 00158 bool ReportSubsystemList::IsLargeDataSet(const unsigned int maxPayloadSize) const 00159 { 00160 unsigned int size = BYTE_SIZE + (UInt)mSubsystemList.size()*UINT_SIZE; 00161 return size > maxPayloadSize; 00162 } 00163 00164 00170 ReportSubsystemList& ReportSubsystemList::operator =(const ReportSubsystemList& message) 00171 { 00172 if(this != &message) 00173 { 00174 CopyHeaderData(&message); 00175 mSubsystemList = message.mSubsystemList; 00176 } 00177 return *this; 00178 } 00179 00180 00181 /* End of File */