Apollo 10.0
自动驾驶开放平台
underlay_message.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#ifndef CYBER_TRANSPORT_RTPS_UNDERLAY_MESSAGE_H_
18#define CYBER_TRANSPORT_RTPS_UNDERLAY_MESSAGE_H_
19
20#include <cstdint>
21
22#include <array>
23#include <string>
24#include <utility>
25#include <vector>
26
27#include "cyber/base/macros.h"
28
29#include "fastcdr/Cdr.h"
30
31namespace apollo {
32namespace cyber {
33namespace transport {
34
41 public:
46
51
57
63
69
75
80 inline void timestamp(uint64_t _timestamp) { m_timestamp = _timestamp; }
81
86 inline uint64_t timestamp() const { return m_timestamp; }
87
92 inline uint64_t& timestamp() { return m_timestamp; }
97 inline void seq(uint64_t _seq) { m_seq = _seq; }
98
103 inline uint64_t seq() const { return m_seq; }
104
109 inline uint64_t& seq() { return m_seq; }
114 inline void data(const std::string& _data) { m_data = _data; }
115
120 inline void data(std::string&& _data) { m_data = std::move(_data); }
121
126 inline const std::string& data() const { return m_data; }
127
132 inline std::string& data() { return m_data; }
133
140 static size_t getMaxCdrSerializedSize(size_t current_alignment = 0);
141
149 static size_t getCdrSerializedSize(const UnderlayMessage& data,
150 size_t current_alignment = 0);
151
156 void serialize(eprosima::fastcdr::Cdr& cdr) const; // NOLINT
157
162 void deserialize(eprosima::fastcdr::Cdr& cdr); // NOLINT
163
171 static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
172
176 static bool isKeyDefined();
177
183 void serializeKey(eprosima::fastcdr::Cdr& cdr) const; // NOLINT
184
185 private:
186 uint64_t m_timestamp;
187 uint64_t m_seq;
188 std::string m_data;
189};
190
191} // namespace transport
192} // namespace cyber
193} // namespace apollo
194
195#endif // CYBER_TRANSPORT_RTPS_UNDERLAY_MESSAGE_H_
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.
void data(std::string &&_data)
This function moves the value in member data
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...
uint64_t seq() const
This function returns the value of member seq
void seq(uint64_t _seq)
This function sets a value in member seq
const std::string & data() const
This function returns a constant reference to member data
std::string & data()
This function returns a reference to member data
UnderlayMessage & operator=(const UnderlayMessage &x)
Copy assignment.
uint64_t & timestamp()
This function returns a reference to member timestamp
void timestamp(uint64_t _timestamp)
This function sets a value in member timestamp
uint64_t & seq()
This function returns a reference to member seq
void data(const std::string &_data)
This function copies the value in member data
void serialize(eprosima::fastcdr::Cdr &cdr) const
This function serializes an object using CDR serialization.
uint64_t timestamp() const
This function returns the value of member timestamp
class register implement
Definition arena_queue.h:37