Apollo  6.0
Open source self driving car software
message_info.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_MESSAGE_MESSAGE_INFO_H_
18 #define CYBER_TRANSPORT_MESSAGE_MESSAGE_INFO_H_
19 
20 #include <cstddef>
21 #include <cstdint>
22 #include <string>
23 
25 
26 namespace apollo {
27 namespace cyber {
28 namespace transport {
29 
30 class MessageInfo {
31  public:
32  MessageInfo();
33  MessageInfo(const Identity& sender_id, uint64_t seq_num);
34  MessageInfo(const Identity& sender_id, uint64_t seq_num,
35  const Identity& spare_id);
36  MessageInfo(const MessageInfo& another);
37  virtual ~MessageInfo();
38 
39  MessageInfo& operator=(const MessageInfo& another);
40  bool operator==(const MessageInfo& another) const;
41  bool operator!=(const MessageInfo& another) const;
42 
43  bool SerializeTo(std::string* dst) const;
44  bool SerializeTo(char* dst, std::size_t len) const;
45  bool DeserializeFrom(const std::string& src);
46  bool DeserializeFrom(const char* src, std::size_t len);
47 
48  // getter and setter
49  const Identity& sender_id() const { return sender_id_; }
50  void set_sender_id(const Identity& sender_id) { sender_id_ = sender_id; }
51 
52  uint64_t channel_id() const { return channel_id_; }
53  void set_channel_id(uint64_t channel_id) { channel_id_ = channel_id; }
54 
55  uint64_t seq_num() const { return seq_num_; }
56  void set_seq_num(uint64_t seq_num) { seq_num_ = seq_num; }
57 
58  const Identity& spare_id() const { return spare_id_; }
59  void set_spare_id(const Identity& spare_id) { spare_id_ = spare_id; }
60 
61  static const std::size_t kSize;
62 
63  private:
64  Identity sender_id_;
65  uint64_t channel_id_ = 0;
66  uint64_t seq_num_ = 0;
67  Identity spare_id_;
68 };
69 
70 } // namespace transport
71 } // namespace cyber
72 } // namespace apollo
73 
74 #endif // CYBER_TRANSPORT_MESSAGE_MESSAGE_INFO_H_
bool operator==(const MessageInfo &another) const
void set_sender_id(const Identity &sender_id)
Definition: message_info.h:50
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool DeserializeFrom(const std::string &src)
bool operator!=(const MessageInfo &another) const
void set_spare_id(const Identity &spare_id)
Definition: message_info.h:59
void set_seq_num(uint64_t seq_num)
Definition: message_info.h:56
Definition: identity.h:30
void set_channel_id(uint64_t channel_id)
Definition: message_info.h:53
uint64_t seq_num() const
Definition: message_info.h:55
const Identity & sender_id() const
Definition: message_info.h:49
uint64_t channel_id() const
Definition: message_info.h:52
static const std::size_t kSize
Definition: message_info.h:61
Definition: message_info.h:30
bool SerializeTo(std::string *dst) const
MessageInfo & operator=(const MessageInfo &another)
const Identity & spare_id() const
Definition: message_info.h:58