Protocols: Fix includes to use the explicit path of the header files
[remote/remote-mci.git] / protocols / client_server / MsgMoteIdList.cc
blobd053e80f4458cbc3738f08c694b5daf0f8cb36da
1 #include "protocols/client_server/MsgMoteIdList.h"
3 namespace remote { namespace protocols { namespace client_server {
5 MsgMoteIdList::MsgMoteIdList() : moteIdList()
9 void MsgMoteIdList::operator = (const MsgMoteIdList& o)
11 moteIdList = o.moteIdList;
14 uint32_t MsgMoteIdList::getLength()
16 // length and elements
17 return sizeof(uint16_t)+sizeof(uint32_t)*moteIdList.size();
20 uint8_t* MsgMoteIdList::write(uint8_t* buffer, uint32_t& buflen)
22 uint16_t count;
23 dbkey_t moteId;
25 count = moteIdList.size();
27 buffer = writevalue(count,buffer,buflen);
29 idlist_t::iterator i;
30 for ( i = moteIdList.begin(); i != moteIdList.end(); i++)
32 moteId = *i;
33 buffer = writevalue(moteId,buffer,buflen);
35 return buffer;
38 uint8_t* MsgMoteIdList::read(uint8_t* buffer, uint32_t& buflen)
40 uint16_t count,i;
41 dbkey_t moteId;
42 moteIdList.clear();
44 buffer = readvalue(count,buffer,buflen);
46 for (i=0; i < count; i++)
48 buffer = readvalue(moteId,buffer,buflen);
49 moteIdList.push_back(moteId);
51 return buffer;
54 void MsgMoteIdList::print(FILE* s)
56 uint16_t count;
57 dbkey_t moteId;
58 count = moteIdList.size();
59 fprintf(s,"MESSAGE MsgMoteIdList\n");
60 fprintf(s,"%u elements:\n",count);
62 idlist_t::iterator i;
63 for ( i = moteIdList.begin(); i != moteIdList.end(); i++)
65 moteId = *i;
66 fprintf(s,"%u\n",moteId);
70 void MsgMoteIdList::clear()
72 moteIdList.clear();
75 void MsgMoteIdList::addMoteId(dbkey_t p_moteId)
77 moteIdList.push_back(p_moteId);
80 bool MsgMoteIdList::getNextMoteId(dbkey_t &p_moteId)
82 if (moteIdList.empty()) return false;
83 else
85 p_moteId = moteIdList.front();
86 moteIdList.pop_front();
87 return true;
91 }}}