1 #include "MsgMoteConnectionInfoList.h"
3 namespace remote
{ namespace protocols
{ namespace diku_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
++)
22 length
+= moteInfo
->getLength();
27 uint8_t* MsgMoteConnectionInfoList::write(uint8_t* buffer
, uint32_t& buflen
)
30 MsgMoteConnectionInfo
* moteInfo
;
32 count
= infoList
.size();
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
++)
45 buffer
= moteInfo
->write(buffer
,buflen
);
50 uint8_t* MsgMoteConnectionInfoList::read(uint8_t* buffer
, uint32_t& buflen
)
53 MsgMoteConnectionInfo
* moteInfo
;
57 buffer
= readvalue(count
,buffer
,buflen
);
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
);
73 void MsgMoteConnectionInfoList::print(FILE* s
)
77 void MsgMoteConnectionInfoList::clear()
79 infolist_t::iterator i
;
80 for ( i
= infoList
.begin(); i
!= infoList
.end(); i
++)
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;
98 p_info
= *(infoList
.front());
99 delete infoList
.front();
100 infoList
.pop_front();