include
odva_ethernetip
serialization
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
29
#include "
odva_ethernetip/serialization/serializable.h
"
30
#include "
odva_ethernetip/serialization/writer.h
"
31
#include "
odva_ethernetip/serialization/reader.h
"
32
33
namespace
eip
{
34
namespace
serialization {
35
40
template
<
typename
T>
41
class
SerializablePrimitive
:
public
Serializable
42
{
43
public
:
44
46
T
data
;
47
51
SerializablePrimitive
() { }
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
eip::serialization::SerializablePrimitive::SerializablePrimitive
SerializablePrimitive()
Definition:
serializable_primitive.h:51
eip::serialization::Writer
Definition:
writer.h:41
eip::serialization::SerializablePrimitive
Definition:
serializable_primitive.h:41
eip::serialization::Reader
Definition:
reader.h:42
eip
Definition:
connection.h:41
eip::serialization::Writer::write
void write(const T &v)
Definition:
writer.h:50
eip::serialization::SerializablePrimitive::deserialize
virtual Reader & deserialize(Reader &reader)
Definition:
serializable_primitive.h:101
eip::serialization::Reader::read
void read(T &v)
Definition:
reader.h:51
eip::serialization::SerializablePrimitive::data
T data
Data as the primitive type to be serialized or deserialized.
Definition:
serializable_primitive.h:46
eip::serialization::SerializablePrimitive::SerializablePrimitive
SerializablePrimitive(const T &d)
Definition:
serializable_primitive.h:57
eip::serialization::Serializable
Definition:
serializable.h:38
eip::serialization::SerializablePrimitive::getLength
virtual size_t getLength() const
Definition:
serializable_primitive.h:63
reader.h
eip::serialization::SerializablePrimitive::serialize
virtual Writer & serialize(Writer &writer) const
Definition:
serializable_primitive.h:74
eip::serialization::SerializablePrimitive::deserialize
virtual Reader & deserialize(Reader &reader, size_t length)
Definition:
serializable_primitive.h:88
serializable.h
writer.h
odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Wed Mar 2 2022 00:38:56