forward_close_success.h
Go to the documentation of this file.
1 
26 #ifndef ODVA_ETHERNETIP_FORWARD_CLOSE_SUCCESS_H
27 #define ODVA_ETHERNETIP_FORWARD_CLOSE_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 
60 
65  shared_ptr<Serializable> getResponseData() const
66  {
67  return response_data_;
68  }
69 
74  virtual size_t getLength() const
75  {
76  size_t result = sizeof(connection_sn)
77  + sizeof(originator_vendor_id)
78  + sizeof(originator_sn)
79  + 2; // reserved byte and data length
80  if (response_data_)
81  {
82  result += response_data_->getLength();
83  }
84  return result;
85  }
86 
93  virtual Writer& serialize(Writer& writer) const
94  {
95  throw std::logic_error("Not implemented");
96  }
97 
101  virtual Reader& deserialize(Reader& reader, size_t length)
102  {
103  return deserialize(reader);
104  }
105 
109  virtual Reader& deserialize(Reader& reader)
110  {
111  EIP_USINT data_length;
112  reader.read(connection_sn);
113  reader.read(originator_vendor_id);
114  reader.read(originator_sn);
115  reader.read(data_length);
116  reader.skip(1);
117  if (data_length > 0)
118  {
119  shared_ptr<SerializableBuffer> sb = make_shared<SerializableBuffer> ();
120  sb->deserialize(reader, data_length*2);
121  response_data_ = sb;
122  }
123  else
124  {
125  response_data_ = shared_ptr<Serializable>();
126  }
127  return reader;
128  }
129 
130 private:
131  shared_ptr<Serializable> response_data_;
132 
133 };
134 
135 } // namespace eip
136 
137 #endif // ODVA_ETHERNETIP_FORWARD_CLOSE_SUCCESS_H
eip::serialization::Writer
Definition: writer.h:41
eip_types.h
eip::ForwardCloseSuccess
Definition: forward_close_success.h:53
eip::serialization::Reader
Definition: reader.h:42
eip
Definition: connection.h:41
eip::ForwardCloseSuccess::deserialize
virtual Reader & deserialize(Reader &reader)
Definition: forward_close_success.h:109
eip::ForwardCloseSuccess::serialize
virtual Writer & serialize(Writer &writer) const
Definition: forward_close_success.h:93
EIP_UINT
uint16_t EIP_UINT
Definition: eip_types.h:39
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::ForwardCloseSuccess::deserialize
virtual Reader & deserialize(Reader &reader, size_t length)
Definition: forward_close_success.h:101
eip::serialization::Serializable
Definition: serializable.h:38
eip::ForwardCloseSuccess::response_data_
shared_ptr< Serializable > response_data_
Definition: forward_close_success.h:131
eip::ForwardCloseSuccess::originator_vendor_id
EIP_UINT originator_vendor_id
Definition: forward_close_success.h:58
reader.h
eip::ForwardCloseSuccess::getLength
virtual size_t getLength() const
Definition: forward_close_success.h:74
serializable_buffer.h
eip::ForwardCloseSuccess::originator_sn
EIP_UDINT originator_sn
Definition: forward_close_success.h:59
eip::ForwardCloseSuccess::connection_sn
EIP_UINT connection_sn
Definition: forward_close_success.h:57
eip::ForwardCloseSuccess::getResponseData
shared_ptr< Serializable > getResponseData() const
Definition: forward_close_success.h:65
EIP_UDINT
uint32_t EIP_UDINT
Definition: eip_types.h:42
serializable.h
writer.h


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