forward_close_success.h
Go to the documentation of this file.
00001 
00026 #ifndef ODVA_ETHERNETIP_FORWARD_CLOSE_SUCCESS_H
00027 #define ODVA_ETHERNETIP_FORWARD_CLOSE_SUCCESS_H
00028 
00029 #include <string>
00030 #include <boost/shared_ptr.hpp>
00031 #include <boost/make_shared.hpp>
00032 
00033 #include "odva_ethernetip/eip_types.h"
00034 #include "odva_ethernetip/serialization/serializable.h"
00035 #include "odva_ethernetip/serialization/serializable_buffer.h"
00036 #include "odva_ethernetip/serialization/reader.h"
00037 #include "odva_ethernetip/serialization/writer.h"
00038 
00039 using boost::shared_ptr;
00040 using boost::make_shared;
00041 
00042 namespace eip {
00043 
00044 using serialization::Serializable;
00045 using serialization::SerializableBuffer;
00046 using serialization::Reader;
00047 using serialization::Writer;
00048 
00053 class ForwardCloseSuccess : public Serializable
00054 {
00055 public:
00056 
00057   EIP_UINT connection_sn;
00058   EIP_UINT originator_vendor_id;
00059   EIP_UDINT originator_sn;
00060 
00065   shared_ptr<Serializable> getResponseData() const
00066   {
00067     return response_data_;
00068   }
00069 
00074   virtual size_t getLength() const
00075   {
00076     size_t result = sizeof(connection_sn)
00077       + sizeof(originator_vendor_id)
00078       + sizeof(originator_sn)
00079       + 2; // reserved byte and data length
00080     if (response_data_)
00081     {
00082       result += response_data_->getLength();
00083     }
00084     return result;
00085   }
00086 
00093   virtual Writer& serialize(Writer& writer) const
00094   {
00095     throw std::logic_error("Not implemented");
00096   }
00097 
00101   virtual Reader& deserialize(Reader& reader, size_t length)
00102   {
00103     return deserialize(reader);
00104   }
00105 
00109   virtual Reader& deserialize(Reader& reader)
00110   {
00111     EIP_USINT data_length;
00112     reader.read(connection_sn);
00113     reader.read(originator_vendor_id);
00114     reader.read(originator_sn);
00115     reader.read(data_length);
00116     reader.skip(1);
00117     if (data_length > 0)
00118     {
00119       shared_ptr<SerializableBuffer> sb = make_shared<SerializableBuffer> ();
00120       sb->deserialize(reader, data_length*2);
00121       response_data_ = sb;
00122     }
00123     else
00124     {
00125       response_data_ = shared_ptr<Serializable>();
00126     }
00127     return reader;
00128   }
00129 
00130 private:
00131   shared_ptr<Serializable> response_data_;
00132 
00133 };
00134 
00135 } // namespace eip
00136 
00137 #endif  // ODVA_ETHERNETIP_FORWARD_CLOSE_SUCCESS_H


odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Sat Jun 8 2019 20:21:23