message_router_request.h
Go to the documentation of this file.
1 
26 #ifndef ODVA_ETHERNETIP_MESSAGE_ROUTER_REQUEST_H
27 #define ODVA_ETHERNETIP_MESSAGE_ROUTER_REQUEST_H
28 
29 #include <string>
30 #include <boost/shared_ptr.hpp>
31 
36 #include "odva_ethernetip/path.h"
37 
38 using boost::shared_ptr;
39 
40 namespace eip {
41 
42 using serialization::Serializable;
43 using serialization::Reader;
44 using serialization::Writer;
45 
50 {
51 public:
52 
54 
58  MessageRouterRequest(EIP_USINT service_code = 0) : service(service_code) { }
59 
65  {
66  return path_;
67  }
68 
73  void setData(shared_ptr<Serializable> data)
74  {
75  data_ = data;
76  }
77 
82  shared_ptr<Serializable> getData() const
83  {
84  return data_;
85  }
86 
91  virtual size_t getLength() const
92  {
93  size_t result = sizeof(service) + path_.getLength();
94  if (data_)
95  {
96  result += data_->getLength();
97  }
98  return result;
99  }
100 
107  virtual Writer& serialize(Writer& writer) const
108  {
109  writer.write(service);
110  path_.serialize(writer);
111  if (data_) {
112  data_->serialize(writer);
113  }
114  return writer;
115  }
116 
120  virtual Reader& deserialize(Reader& reader, size_t length)
121  {
122  throw std::logic_error("Not implemented");
123  }
124 
128  virtual Reader& deserialize(Reader& reader)
129  {
130  throw std::logic_error("Not implemented");
131  }
132 
133 private:
134  shared_ptr<Serializable> data_;
136 };
137 
138 } // namespace eip
139 
140 #endif // ODVA_ETHERNETIP_MESSAGE_ROUTER_REQUEST_H
path.h
eip::serialization::Writer
Definition: writer.h:41
eip_types.h
eip::serialization::Reader
Definition: reader.h:42
eip::MessageRouterRequest::setData
void setData(shared_ptr< Serializable > data)
Definition: message_router_request.h:73
eip
Definition: connection.h:41
eip::MessageRouterRequest::path_
Path path_
Definition: message_router_request.h:135
eip::serialization::Writer::write
void write(const T &v)
Definition: writer.h:50
eip::MessageRouterRequest
Definition: message_router_request.h:49
eip::MessageRouterRequest::deserialize
virtual Reader & deserialize(Reader &reader)
Definition: message_router_request.h:128
EIP_USINT
uint8_t EIP_USINT
Definition: eip_types.h:36
eip::MessageRouterRequest::getData
shared_ptr< Serializable > getData() const
Definition: message_router_request.h:82
eip::serialization::Serializable
Definition: serializable.h:38
eip::MessageRouterRequest::getLength
virtual size_t getLength() const
Definition: message_router_request.h:91
eip::MessageRouterRequest::serialize
virtual Writer & serialize(Writer &writer) const
Definition: message_router_request.h:107
reader.h
eip::MessageRouterRequest::getPath
Path & getPath()
Definition: message_router_request.h:64
eip::MessageRouterRequest::MessageRouterRequest
MessageRouterRequest(EIP_USINT service_code=0)
Definition: message_router_request.h:58
eip::MessageRouterRequest::service
EIP_USINT service
Definition: message_router_request.h:53
eip::Path::getLength
virtual size_t getLength() const
Definition: path.cpp:79
eip::MessageRouterRequest::data_
shared_ptr< Serializable > data_
Definition: message_router_request.h:134
eip::MessageRouterRequest::deserialize
virtual Reader & deserialize(Reader &reader, size_t length)
Definition: message_router_request.h:120
eip::Path::serialize
virtual Writer & serialize(Writer &writer) const
Definition: path.h:137
serializable.h
writer.h
eip::Path
Definition: path.h:50


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