Apollo 11.0
自动驾驶开放平台
underlay_message.cc
浏览该文件的文档.
1// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
24
25#include "fastcdr/exceptions/BadParamException.h"
26
27namespace apollo {
28namespace cyber {
29namespace transport {
30
32 m_timestamp = 0;
33 m_seq = 0;
34}
35
37
39 m_timestamp = x.m_timestamp;
40 m_seq = x.m_seq;
41 m_data = x.m_data;
42 m_datatype = x.m_datatype;
43}
44
46 m_timestamp = x.m_timestamp;
47 m_seq = x.m_seq;
48 m_data = std::move(x.m_data);
49 m_datatype = std::move(x.m_datatype);
50}
51
53 m_timestamp = x.m_timestamp;
54 m_seq = x.m_seq;
55 m_data = x.m_data;
56 m_datatype = x.m_datatype;
57
58 return *this;
59}
60
62 m_timestamp = x.m_timestamp;
63 m_seq = x.m_seq;
64 m_data = std::move(x.m_data);
65 m_datatype = std::move(x.m_datatype);
66
67 return *this;
68}
69
70size_t UnderlayMessage::getMaxCdrSerializedSize(size_t current_alignment) {
71 size_t initial_alignment = current_alignment;
72
73 current_alignment +=
74 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
75
76 current_alignment +=
77 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
78
79 current_alignment +=
80 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1;
81
82 current_alignment +=
83 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1;
84
85 return current_alignment - initial_alignment;
86}
87
89 size_t current_alignment) {
90 size_t initial_alignment = current_alignment;
91
92 current_alignment +=
93 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
94
95 current_alignment +=
96 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
97
98 current_alignment += 4 +
99 eprosima::fastcdr::Cdr::alignment(current_alignment, 4) +
100 data.data().size() + 1;
101
102 current_alignment += 4 +
103 eprosima::fastcdr::Cdr::alignment(current_alignment, 4) +
104 data.datatype().size() + 1;
105
106 return current_alignment - initial_alignment;
107}
108
109void UnderlayMessage::serialize(eprosima::fastcdr::Cdr& scdr) const {
110 scdr << m_timestamp;
111
112 scdr << m_seq;
113
114 scdr << m_data;
115 scdr << m_datatype;
116}
117
118void UnderlayMessage::deserialize(eprosima::fastcdr::Cdr& dcdr) {
119 dcdr >> m_timestamp;
120 dcdr >> m_seq;
121 dcdr >> m_data;
122 dcdr >> m_datatype;
123}
124
125size_t UnderlayMessage::getKeyMaxCdrSerializedSize(size_t current_alignment) {
126 size_t current_align = current_alignment;
127 return current_align;
128}
129
130bool UnderlayMessage::isKeyDefined() { return false; }
131
132void UnderlayMessage::serializeKey(eprosima::fastcdr::Cdr& scdr) const {
133 (void)scdr;
134}
135
136} // namespace transport
137} // namespace cyber
138} // namespace apollo
This class represents the structure UnderlayMessage defined by the user in the IDL file.
void serializeKey(eprosima::fastcdr::Cdr &cdr) const
This function serializes the key members of an object using CDR serialization.
static bool isKeyDefined()
This function tells you if the Key has been defined for this type
static size_t getCdrSerializedSize(const UnderlayMessage &data, size_t current_alignment=0)
This function returns the serialized size of a data depending on the buffer alignment.
static size_t getMaxCdrSerializedSize(size_t current_alignment=0)
This function returns the maximum serialized size of an object depending on the buffer alignment.
void deserialize(eprosima::fastcdr::Cdr &cdr)
This function deserializes an object using CDR serialization.
static size_t getKeyMaxCdrSerializedSize(size_t current_alignment=0)
This function returns the maximum serialized size of the Key of an object depending on the buffer ali...
const std::string & data() const
This function returns a constant reference to member data
UnderlayMessage & operator=(const UnderlayMessage &x)
Copy assignment.
void serialize(eprosima::fastcdr::Cdr &cdr) const
This function serializes an object using CDR serialization.
class register implement
Definition arena_queue.h:37