src
cpf_packet.cpp
Go to the documentation of this file.
1
26
#include <boost/make_shared.hpp>
27
#include <boost/foreach.hpp>
28
29
#include "
odva_ethernetip/cpf_packet.h
"
30
31
using
boost::make_shared;
32
33
namespace
eip
{
34
35
size_t
CPFPacket::getLength
()
const
36
{
37
// 2 bytes just for the number of items
38
size_t
l = 2;
39
BOOST_FOREACH(
CPFItem
i,
items_
)
40
{
41
l += i.
getLength
();
42
}
43
return
l;
44
}
45
46
Writer
&
CPFPacket::serialize
(
Writer
& writer)
const
47
{
48
writer.
write
(
getItemCount
());
49
BOOST_FOREACH(
CPFItem
i,
items_
)
50
{
51
i.
serialize
(writer);
52
}
53
return
writer;
54
}
55
56
Reader
&
CPFPacket::deserialize
(
Reader
& reader)
57
{
58
items_
.clear();
59
EIP_UINT
num_items;
60
reader.
read
(num_items);
61
for
(
int
i = 0; i < num_items; ++i)
62
{
63
CPFItem
item;
64
item.
deserialize
(reader);
65
items_
.push_back(item);
66
}
67
return
reader;
68
}
69
70
}
// namespace eip
eip::serialization::Writer
Definition:
writer.h:41
eip::CPFItem::serialize
virtual Writer & serialize(Writer &writer) const
Definition:
cpf_item.cpp:37
eip::serialization::Reader
Definition:
reader.h:42
eip
Definition:
connection.h:41
eip::CPFPacket::serialize
virtual Writer & serialize(Writer &writer) const
Definition:
cpf_packet.cpp:46
eip::serialization::Writer::write
void write(const T &v)
Definition:
writer.h:50
EIP_UINT
uint16_t EIP_UINT
Definition:
eip_types.h:39
eip::serialization::Reader::read
void read(T &v)
Definition:
reader.h:51
eip::CPFPacket::getLength
virtual size_t getLength() const
Definition:
cpf_packet.cpp:35
eip::CPFPacket::getItemCount
EIP_UINT getItemCount() const
Definition:
cpf_packet.h:57
eip::CPFItem::deserialize
virtual Reader & deserialize(Reader &reader, size_t length)
Definition:
cpf_item.cpp:47
cpf_packet.h
eip::CPFItem
Definition:
cpf_item.h:48
eip::CPFPacket::deserialize
virtual Reader & deserialize(Reader &reader, size_t length)
Definition:
cpf_packet.h:89
eip::CPFItem::getLength
virtual size_t getLength() const
Definition:
cpf_item.h:121
eip::CPFPacket::items_
vector< CPFItem > items_
Definition:
cpf_packet.h:104
odva_ethernetip
Author(s): Kareem Shehata
autogenerated on Wed Mar 2 2022 00:38:55