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 
53 class ForwardCloseSuccess : public Serializable
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
virtual Reader & deserialize(Reader &reader)
uint8_t EIP_USINT
Definition: eip_types.h:36
virtual size_t getLength() const
virtual Writer & serialize(Writer &writer) const
virtual Reader & deserialize(Reader &reader, size_t length)
shared_ptr< Serializable > response_data_
Definition: connection.h:41
uint16_t EIP_UINT
Definition: eip_types.h:39
uint32_t EIP_UDINT
Definition: eip_types.h:42
shared_ptr< Serializable > getResponseData() const


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