message_router_request.h
Go to the documentation of this file.
00001 
00026 #ifndef ODVA_ETHERNETIP_MESSAGE_ROUTER_REQUEST_H
00027 #define ODVA_ETHERNETIP_MESSAGE_ROUTER_REQUEST_H
00028 
00029 #include <string>
00030 #include <boost/shared_ptr.hpp>
00031 
00032 #include "odva_ethernetip/eip_types.h"
00033 #include "odva_ethernetip/serialization/serializable.h"
00034 #include "odva_ethernetip/serialization/reader.h"
00035 #include "odva_ethernetip/serialization/writer.h"
00036 #include "odva_ethernetip/path.h"
00037 
00038 using boost::shared_ptr;
00039 
00040 namespace eip {
00041 
00042 using serialization::Serializable;
00043 using serialization::Reader;
00044 using serialization::Writer;
00045 
00049 class MessageRouterRequest : public Serializable
00050 {
00051 public:
00052 
00053   EIP_USINT service;
00054 
00058   MessageRouterRequest(EIP_USINT service_code = 0) : service(service_code) { }
00059 
00064   Path& getPath()
00065   {
00066     return path_;
00067   }
00068 
00073   void setData(shared_ptr<Serializable> data)
00074   {
00075     data_ = data;
00076   }
00077 
00082   shared_ptr<Serializable> getData() const
00083   {
00084     return data_;
00085   }
00086 
00091   virtual size_t getLength() const
00092   {
00093     size_t result = sizeof(service) + path_.getLength();
00094     if (data_)
00095     {
00096       result += data_->getLength();
00097     }
00098     return result;
00099   }
00100 
00107   virtual Writer& serialize(Writer& writer) const
00108   {
00109     writer.write(service);
00110     path_.serialize(writer);
00111     if (data_) {
00112       data_->serialize(writer);
00113     }
00114     return writer;
00115   }
00116 
00120   virtual Reader& deserialize(Reader& reader, size_t length)
00121   {
00122     throw std::logic_error("Not implemented");
00123   }
00124 
00128   virtual Reader& deserialize(Reader& reader)
00129   {
00130     throw std::logic_error("Not implemented");
00131   }
00132 
00133 private:
00134   shared_ptr<Serializable> data_;
00135   Path path_;
00136 };
00137 
00138 } // namespace eip
00139 
00140 #endif  // ODVA_ETHERNETIP_MESSAGE_ROUTER_REQUEST_H


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