Apollo 9.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 "fastcdr/Cdr.h"
28
29namespace apollo {
30namespace cyber {
31namespace transport {
32
39 public:
44
49
55
61
67
73
78 inline void timestamp(int32_t _timestamp) { m_timestamp = _timestamp; }
79
84 inline int32_t timestamp() const { return m_timestamp; }
85
90 inline int32_t& timestamp() { return m_timestamp; }
95 inline void seq(int32_t _seq) { m_seq = _seq; }
96
101 inline int32_t seq() const { return m_seq; }
102
107 inline int32_t& seq() { return m_seq; }
112 inline void data(const std::string& _data) { m_data = _data; }
113
118 inline void data(std::string&& _data) { m_data = std::move(_data); }
119
124 inline const std::string& data() const { return m_data; }
125
130 inline std::string& data() { return m_data; }
135 inline void datatype(const std::string& _datatype) { m_datatype = _datatype; }
136
141 inline void datatype(std::string&& _datatype) {
142 m_datatype = std::move(_datatype);
143 }
144
149 inline const std::string& datatype() const { return m_datatype; }
150
155 inline std::string& datatype() { return m_datatype; }
156
163 static size_t getMaxCdrSerializedSize(size_t current_alignment = 0);
164
172 static size_t getCdrSerializedSize(const UnderlayMessage& data,
173 size_t current_alignment = 0);
174
179 void serialize(eprosima::fastcdr::Cdr& cdr) const; // NOLINT
180
185 void deserialize(eprosima::fastcdr::Cdr& cdr); // NOLINT
186
194 static size_t getKeyMaxCdrSerializedSize(size_t current_alignment = 0);
195
199 static bool isKeyDefined();
200
206 void serializeKey(eprosima::fastcdr::Cdr& cdr) const; // NOLINT
207
208 private:
209 int32_t m_timestamp;
210 int32_t m_seq;
211 std::string m_data;
212 std::string m_datatype;
213};
214
215} // namespace transport
216} // namespace cyber
217} // namespace apollo
218
219#endif // CYBER_TRANSPORT_RTPS_UNDERLAY_MESSAGE_H_
This class represents the structure UnderlayMessage defined by the user in the IDL file.
int32_t seq() const
This function returns the value of member seq
void serializeKey(eprosima::fastcdr::Cdr &cdr) const
This function serializes the key members of an object using CDR serialization.
void datatype(const std::string &_datatype)
This function copies the value in member datatype
void datatype(std::string &&_datatype)
This function moves the value in member datatype
int32_t timestamp() const
This function returns the value of member timestamp
void data(std::string &&_data)
This function moves the value in member data
int32_t & seq()
This function returns a reference to member seq
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
std::string & data()
This function returns a reference to member data
UnderlayMessage & operator=(const UnderlayMessage &x)
Copy assignment.
const std::string & datatype() const
This function returns a constant reference to member datatype
void timestamp(int32_t _timestamp)
This function sets a value in member timestamp
void seq(int32_t _seq)
This function sets a value in member seq
void data(const std::string &_data)
This function copies the value in member data
std::string & datatype()
This function returns a reference to member datatype
int32_t & timestamp()
This function returns a reference to member timestamp
void serialize(eprosima::fastcdr::Cdr &cdr) const
This function serializes an object using CDR serialization.
class register implement