Protocols: Fix includes to use the explicit path of the header files
[remote/remote-mci.git] / protocols / host_server / MsgMoteConnectionInfoList.cc
blob00d33aac681abbe89fa59a4820f7ffd6278170a0
1 #include "protocols/host_server/MsgMoteConnectionInfoList.h"
3 namespace remote { namespace protocols { namespace host_server {
5 MsgMoteConnectionInfoList::MsgMoteConnectionInfoList()
9 MsgMoteConnectionInfoList::~MsgMoteConnectionInfoList()
13 uint32_t MsgMoteConnectionInfoList::getLength()
15 MsgMoteConnectionInfo* moteInfo;
16 infolist_t::iterator i;
17 uint32_t length = sizeof(uint16_t);
19 for ( i = infoList.begin(); i != infoList.end(); i++)
21 moteInfo = *i;
22 length += moteInfo->getLength();
24 return length;
27 uint8_t* MsgMoteConnectionInfoList::write(uint8_t* buffer, uint32_t& buflen)
29 uint16_t count;
30 MsgMoteConnectionInfo* moteInfo;
32 count = infoList.size();
34 if (count>1000)
36 __THROW__ ("Illegal infoList count > 1000!");
39 buffer = writevalue(count,buffer,buflen);
41 infolist_t::iterator i;
42 for ( i = infoList.begin(); i != infoList.end(); i++)
44 moteInfo = *i;
45 buffer = moteInfo->write(buffer,buflen);
47 return buffer;
50 uint8_t* MsgMoteConnectionInfoList::read(uint8_t* buffer, uint32_t& buflen)
52 uint16_t count,i;
53 MsgMoteConnectionInfo* moteInfo;
55 infoList.clear();
57 buffer = readvalue(count,buffer,buflen);
59 if (count>1000)
61 __THROW__ ("Illegal infoList count > 1000!");
64 for (i=0; i < count; i++)
66 moteInfo = new MsgMoteConnectionInfo();
67 buffer = moteInfo->read(buffer,buflen);
68 infoList.push_back(moteInfo);
70 return buffer;
73 void MsgMoteConnectionInfoList::print(FILE* s)
77 void MsgMoteConnectionInfoList::clear()
79 infolist_t::iterator i;
80 for ( i = infoList.begin(); i != infoList.end(); i++)
82 delete *i;
84 infoList.clear();
87 void MsgMoteConnectionInfoList::addMoteInfo(MsgMoteConnectionInfo p_info)
89 MsgMoteConnectionInfo* info = new MsgMoteConnectionInfo(p_info);
90 infoList.push_back(info);
93 bool MsgMoteConnectionInfoList::getNextMoteInfo(MsgMoteConnectionInfo& p_info)
95 if (infoList.empty()) return false;
96 else
98 p_info = *(infoList.front());
99 delete infoList.front();
100 infoList.pop_front();
101 return true;