Apollo  6.0
Open source self driving car software
underlay_message.h
Go to the documentation of this file.
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 
29 namespace apollo {
30 namespace cyber {
31 namespace 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_
std::string & data()
This function returns a reference to member data.
Definition: underlay_message.h:130
void seq(int32_t _seq)
This function sets a value in member seq.
Definition: underlay_message.h:95
int32_t & timestamp()
This function returns a reference to member timestamp.
Definition: underlay_message.h:90
This class represents the structure UnderlayMessage defined by the user in the IDL file...
Definition: underlay_message.h:38
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
void datatype(std::string &&_datatype)
This function moves the value in member datatype.
Definition: underlay_message.h:141
const std::string & data() const
This function returns a constant reference to member data.
Definition: underlay_message.h:124
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 & datatype() const
This function returns a constant reference to member datatype.
Definition: underlay_message.h:149
static bool isKeyDefined()
This function tells you if the Key has been defined for this type.
std::string & datatype()
This function returns a reference to member datatype.
Definition: underlay_message.h:155
void datatype(const std::string &_datatype)
This function copies the value in member datatype.
Definition: underlay_message.h:135
void serialize(eprosima::fastcdr::Cdr &cdr) const
This function serializes an object using CDR serialization.
int32_t seq() const
This function returns the value of member seq.
Definition: underlay_message.h:101
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 data(const std::string &_data)
This function copies the value in member data.
Definition: underlay_message.h:112
void data(std::string &&_data)
This function moves the value in member data.
Definition: underlay_message.h:118
int32_t & seq()
This function returns a reference to member seq.
Definition: underlay_message.h:107
void serializeKey(eprosima::fastcdr::Cdr &cdr) const
This function serializes the key members of an object using CDR serialization.
UnderlayMessage & operator=(const UnderlayMessage &x)
Copy assignment.
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.
void deserialize(eprosima::fastcdr::Cdr &cdr)
This function deserializes an object using CDR serialization.
void timestamp(int32_t _timestamp)
This function sets a value in member timestamp.
Definition: underlay_message.h:78
int32_t timestamp() const
This function returns the value of member timestamp.
Definition: underlay_message.h:84