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/registerservices.h" 00041 00042 using namespace JAUS; 00043 00044 00053 RegisterServices::RegisterServices(const Address& dest, 00054 const Address& src) : Message(REGISTER_SERVICES, dest, src) 00055 { 00056 } 00057 00058 00064 RegisterServices::RegisterServices(const RegisterServices& message) : Message(REGISTER_SERVICES) 00065 { 00066 *this = message; 00067 } 00068 00069 00075 RegisterServices::~RegisterServices() 00076 { 00077 00078 } 00079 00080 00092 int RegisterServices::WriteMessageBody(Packet& packet) const 00093 { 00094 int total = 0; 00095 total += packet.WriteByte((Byte)mServices.size()); 00096 00097 Service::ID::Set::const_iterator id; 00098 for(id = mServices.begin(); 00099 id != mServices.end(); 00100 id++) 00101 { 00102 total += id->Write(packet); 00103 } 00104 00105 return total; 00106 } 00107 00108 00120 int RegisterServices::ReadMessageBody(const Packet& packet) 00121 { 00122 int total = 0; 00123 Byte count = 0; 00124 00125 total += packet.Read(count); 00126 for(Byte i = 0; i < count; i++) 00127 { 00128 Service::ID id; 00129 total += id.Read(packet); 00130 mServices.insert(id); 00131 } 00132 00133 return total; 00134 } 00135 00136 00142 void RegisterServices::ClearMessageBody() 00143 { 00144 mServices.clear(); 00145 } 00146 00147 00154 bool RegisterServices::IsLargeDataSet(const unsigned int maxPayloadSize) const 00155 { 00156 unsigned int size = BYTE_SIZE; 00157 Service::ID::Set::const_iterator s; 00158 for(s = mServices.begin(); 00159 s != mServices.end(); 00160 s++) 00161 { 00162 size += (unsigned int)(BYTE_SIZE + s->mName.size() + BYTE_SIZE*2); 00163 } 00164 return size > maxPayloadSize; 00165 } 00166 00167 00173 RegisterServices& RegisterServices::operator =(const RegisterServices& message) 00174 { 00175 if(this != &message) 00176 { 00177 CopyHeaderData(&message); 00178 mServices = message.mServices; 00179 } 00180 return *this; 00181 } 00182 00183 00184 /* End of File */