serializable_primitive.h
Go to the documentation of this file.
1 
26 #ifndef ODVA_ETHERNETIP_SERIALIZATION_SERIALIZABLE_PRIMITIVE_H
27 #define ODVA_ETHERNETIP_SERIALIZATION_SERIALIZABLE_PRIMITIVE_H
28 
32 
33 namespace eip {
34 namespace serialization {
35 
40 template <typename T>
42 {
43 public:
44 
46  T data;
47 
52 
57  SerializablePrimitive(const T& d) : data(d) { }
58 
63  virtual size_t getLength() const
64  {
65  return sizeof(T);
66  }
67 
74  virtual Writer& serialize(Writer& writer) const
75  {
76  writer.write(data);
77  return writer;
78  }
79 
88  virtual Reader& deserialize(Reader& reader, size_t length)
89  {
90  deserialize(reader);
91  return reader;
92  }
93 
101  virtual Reader& deserialize(Reader& reader)
102  {
103  reader.read(data);
104  return reader;
105  }
106 };
107 
108 } // namespace serialization
109 } // namespace eip
110 #endif // ODVA_ETHERNETIP_SERIALIZATION_SERIALIZABLE_PRIMITIVE_H
void write(const T &v)
Definition: writer.h:50
virtual Reader & deserialize(Reader &reader)
Definition: connection.h:41
virtual Reader & deserialize(Reader &reader, size_t length)
T data
Data as the primitive type to be serialized or deserialized.
virtual Writer & serialize(Writer &writer) const


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