serializable_primitive.h
Go to the documentation of this file.
00001 
00026 #ifndef ODVA_ETHERNETIP_SERIALIZATION_SERIALIZABLE_PRIMITIVE_H
00027 #define ODVA_ETHERNETIP_SERIALIZATION_SERIALIZABLE_PRIMITIVE_H
00028 
00029 #include "odva_ethernetip/serialization/serializable.h"
00030 #include "odva_ethernetip/serialization/writer.h"
00031 #include "odva_ethernetip/serialization/reader.h"
00032 
00033 namespace eip {
00034 namespace serialization {
00035 
00040 template <typename T>
00041 class SerializablePrimitive : public Serializable
00042 {
00043 public:
00044 
00046   T data;
00047 
00051   SerializablePrimitive() { }
00052 
00057   SerializablePrimitive(const T& d) : data(d) { }
00058 
00063   virtual size_t getLength() const
00064   {
00065     return sizeof(T);
00066   }
00067 
00074   virtual Writer& serialize(Writer& writer) const
00075   {
00076     writer.write(data);
00077     return writer;
00078   }
00079 
00088   virtual Reader& deserialize(Reader& reader, size_t length)
00089   {
00090     deserialize(reader);
00091     return reader;
00092   }
00093 
00101   virtual Reader& deserialize(Reader& reader)
00102   {
00103     reader.read(data);
00104     return reader;
00105   }
00106 };
00107 
00108 } // namespace serialization
00109 } // namespace eip
00110 #endif  // ODVA_ETHERNETIP_SERIALIZATION_SERIALIZABLE_PRIMITIVE_H


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