message_router_response.cpp
Go to the documentation of this file.
1 
26 #include <boost/make_shared.hpp>
27 
30 
31 using boost::make_shared;
32 
33 namespace eip {
34 
35 using serialization::SerializableBuffer;
36 
38 {
39  size_t result = sizeof(service) + sizeof(EIP_USINT) + sizeof(general_status)
40  + sizeof(EIP_USINT);
42  {
43  result += additional_status_->getLength();
44  }
45  if (response_data_)
46  {
47  result += response_data_->getLength();
48  }
49  return result;
50 }
51 
53 {
54  reader.read(service);
55  // read the general status twice to skip the reserved data
56  reader.read(general_status);
57  reader.read(general_status);
58  EIP_USINT additional_status_length;
59  reader.read(additional_status_length);
60  additional_status_ = readData(reader, (size_t)2*additional_status_length);
61  response_data_ = readData(reader, length - reader.getByteCount());
62  return reader;
63 }
64 
65 shared_ptr<Serializable> MessageRouterResponse::readData(Reader& reader, int length)
66 {
67  shared_ptr<SerializableBuffer> sb;
68  if (length > 0)
69  {
70  sb = make_shared<SerializableBuffer>();
71  sb->deserialize(reader, length);
72  }
73  return sb;
74 }
75 
76 } // namespace eip
eip::serialization::Reader
Definition: reader.h:42
eip
Definition: connection.h:41
eip::MessageRouterResponse::deserialize
virtual Reader & deserialize(Reader &reader, size_t length)
Definition: message_router_response.cpp:52
eip::MessageRouterResponse::additional_status_
shared_ptr< Serializable > additional_status_
Definition: message_router_response.h:109
eip::MessageRouterResponse::response_data_
shared_ptr< Serializable > response_data_
Definition: message_router_response.h:110
eip::serialization::Reader::getByteCount
virtual size_t getByteCount()=0
message_router_response.h
EIP_USINT
uint8_t EIP_USINT
Definition: eip_types.h:36
eip::serialization::Reader::read
void read(T &v)
Definition: reader.h:51
eip::MessageRouterResponse::readData
shared_ptr< Serializable > readData(Reader &reader, int length)
Definition: message_router_response.cpp:65
eip::MessageRouterResponse::getLength
virtual size_t getLength() const
Definition: message_router_response.cpp:37
serializable_buffer.h
eip::MessageRouterResponse::service
EIP_USINT service
Definition: message_router_response.h:52
eip::MessageRouterResponse::general_status
EIP_USINT general_status
Definition: message_router_response.h:53


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Wed Mar 2 2022 00:38:56