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 
49 class MessageRouterRequest : public Serializable
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
uint8_t EIP_USINT
Definition: eip_types.h:36
virtual Reader & deserialize(Reader &reader, size_t length)
virtual Writer & serialize(Writer &writer) const
virtual size_t getLength() const
virtual Writer & serialize(Writer &writer) const
Definition: path.h:137
virtual Reader & deserialize(Reader &reader)
Definition: path.h:50
Definition: connection.h:41
virtual size_t getLength() const
Definition: path.cpp:79
MessageRouterRequest(EIP_USINT service_code=0)
void setData(shared_ptr< Serializable > data)
shared_ptr< Serializable > getData() const
shared_ptr< Serializable > data_


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Mon Jun 10 2019 14:00:16