Initial commit
[remote/remote-mci.git] / protocols / diku_host_server / MsgHostRequest.cc
blob8f5b464dc200d47b809c0093184683c374ae16d5
1 #include "MsgHostRequest.h"
3 namespace remote { namespace protocols { namespace diku_host_server {
5 MsgHostRequest::MsgHostRequest(MsgMoteAddresses& addresses, MsgPayload& message)
6 : addresses(&addresses),
7 message(&message),
8 deleteMsg(false)
9 {}
11 MsgHostRequest::MsgHostRequest(uint8_t*& buffer, uint32_t& buflen)
13 buffer=this->read(buffer,buflen);
14 deleteMsg = true;
17 MsgHostRequest::~MsgHostRequest()
19 if (deleteMsg)
21 delete this->addresses;
22 delete this->message;
26 uint32_t MsgHostRequest::getLength()
28 return addresses->getLength() + message->getLength();
31 uint8_t* MsgHostRequest::write(uint8_t* buffer, uint32_t& buflen)
33 buffer = addresses->write(buffer,buflen);
34 buffer = message->write(buffer,buflen);
35 return buffer;
38 uint8_t* MsgHostRequest::read(uint8_t* buffer, uint32_t& buflen)
40 addresses = new MsgMoteAddresses(buffer,buflen);
41 message = new MsgPayload(buffer,buflen);
42 return buffer;
45 void MsgHostRequest::print(_IO_FILE* s)
49 MsgMoteAddresses& MsgHostRequest::getMoteAddresses()
51 return *addresses;
54 MsgPayload& MsgHostRequest::getMessage()
56 return *message;
59 }}}