forward_open_success.h
Go to the documentation of this file.
1 
26 #ifndef ODVA_ETHERNETIP_FORWARD_OPEN_SUCCESS_H
27 #define ODVA_ETHERNETIP_FORWARD_OPEN_SUCCESS_H
28 
29 #include <string>
30 #include <boost/shared_ptr.hpp>
31 #include <boost/make_shared.hpp>
32 
38 
39 using boost::shared_ptr;
40 using boost::make_shared;
41 
42 namespace eip {
43 
44 using serialization::Serializable;
45 using serialization::SerializableBuffer;
46 using serialization::Reader;
47 using serialization::Writer;
48 
54 {
55 public:
56 
64 
69  shared_ptr<Serializable> getResponseData() const
70  {
71  return response_data_;
72  }
73 
78  virtual size_t getLength() const
79  {
80  size_t result = sizeof(o_to_t_connection_id)
81  + sizeof(t_to_o_connection_id)
82  + sizeof(connection_sn)
83  + sizeof(originator_vendor_id)
84  + sizeof(originator_sn)
85  + sizeof(o_to_t_api)
86  + sizeof(t_to_o_api)
87  + 2; // reserved byte and data length
88  if (response_data_)
89  {
90  result += response_data_->getLength();
91  }
92  return result;
93  }
94 
101  virtual Writer& serialize(Writer& writer) const
102  {
103  throw std::logic_error("Not implemented");
104  }
105 
109  virtual Reader& deserialize(Reader& reader, size_t length)
110  {
111  return deserialize(reader);
112  }
113 
117  virtual Reader& deserialize(Reader& reader)
118  {
119  EIP_USINT data_length;
120  reader.read(o_to_t_connection_id);
121  reader.read(t_to_o_connection_id);
122  reader.read(connection_sn);
123  reader.read(originator_vendor_id);
124  reader.read(originator_sn);
125  reader.read(o_to_t_api);
126  reader.read(t_to_o_api);
127  reader.read(data_length);
128  reader.skip(1);
129  if (data_length > 0)
130  {
131  shared_ptr<SerializableBuffer> sb = make_shared<SerializableBuffer> ();
132  sb->deserialize(reader, data_length*2);
133  response_data_ = sb;
134  }
135  else
136  {
137  response_data_ = shared_ptr<Serializable>();
138  }
139  return reader;
140  }
141 
142 private:
143  shared_ptr<Serializable> response_data_;
144 
145 };
146 
147 } // namespace eip
148 
149 #endif // ODVA_ETHERNETIP_FORWARD_OPEN_SUCCESS_H
eip::serialization::Writer
Definition: writer.h:41
eip_types.h
eip::serialization::Reader
Definition: reader.h:42
eip
Definition: connection.h:41
eip::ForwardOpenSuccess::serialize
virtual Writer & serialize(Writer &writer) const
Definition: forward_open_success.h:101
eip::ForwardOpenSuccess::o_to_t_api
EIP_UDINT o_to_t_api
Definition: forward_open_success.h:62
EIP_UINT
uint16_t EIP_UINT
Definition: eip_types.h:39
eip::ForwardOpenSuccess::originator_sn
EIP_UDINT originator_sn
Definition: forward_open_success.h:61
eip::ForwardOpenSuccess
Definition: forward_open_success.h:53
EIP_USINT
uint8_t EIP_USINT
Definition: eip_types.h:36
eip::serialization::Reader::read
void read(T &v)
Definition: reader.h:51
eip::serialization::Reader::skip
virtual void skip(size_t n)=0
eip::ForwardOpenSuccess::getResponseData
shared_ptr< Serializable > getResponseData() const
Definition: forward_open_success.h:69
eip::ForwardOpenSuccess::o_to_t_connection_id
EIP_UDINT o_to_t_connection_id
Definition: forward_open_success.h:57
eip::serialization::Serializable
Definition: serializable.h:38
eip::ForwardOpenSuccess::response_data_
shared_ptr< Serializable > response_data_
Definition: forward_open_success.h:143
eip::ForwardOpenSuccess::deserialize
virtual Reader & deserialize(Reader &reader, size_t length)
Definition: forward_open_success.h:109
eip::ForwardOpenSuccess::t_to_o_api
EIP_UDINT t_to_o_api
Definition: forward_open_success.h:63
reader.h
eip::ForwardOpenSuccess::deserialize
virtual Reader & deserialize(Reader &reader)
Definition: forward_open_success.h:117
eip::ForwardOpenSuccess::originator_vendor_id
EIP_UINT originator_vendor_id
Definition: forward_open_success.h:60
serializable_buffer.h
eip::ForwardOpenSuccess::t_to_o_connection_id
EIP_UDINT t_to_o_connection_id
Definition: forward_open_success.h:58
eip::ForwardOpenSuccess::connection_sn
EIP_UINT connection_sn
Definition: forward_open_success.h:59
EIP_UDINT
uint32_t EIP_UDINT
Definition: eip_types.h:42
serializable.h
eip::ForwardOpenSuccess::getLength
virtual size_t getLength() const
Definition: forward_open_success.h:78
writer.h


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