Apollo 10.0
自动驾驶开放平台
message_info.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_MESSAGE_MESSAGE_INFO_H_
18#define CYBER_TRANSPORT_MESSAGE_MESSAGE_INFO_H_
19
20#include <cstddef>
21#include <cstdint>
22#include <string>
23
25
26namespace apollo {
27namespace cyber {
28namespace transport {
29
31 public:
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 uint64_t send_time() const { return send_time_; }
64 void set_send_time(uint64_t send_time) { send_time_ = send_time; }
65
66 private:
67 Identity sender_id_;
68 uint64_t channel_id_ = 0;
69 uint64_t seq_num_ = 0;
70 Identity spare_id_;
71 uint64_t send_time_;
72};
73
74} // namespace transport
75} // namespace cyber
76} // namespace apollo
77
78#endif // CYBER_TRANSPORT_MESSAGE_MESSAGE_INFO_H_
const Identity & sender_id() const
void set_seq_num(uint64_t seq_num)
void set_channel_id(uint64_t channel_id)
bool operator!=(const MessageInfo &another) const
bool DeserializeFrom(const std::string &src)
void set_spare_id(const Identity &spare_id)
void set_send_time(uint64_t send_time)
static const std::size_t kSize
bool SerializeTo(std::string *dst) const
bool operator==(const MessageInfo &another) const
const Identity & spare_id() const
MessageInfo & operator=(const MessageInfo &another)
void set_sender_id(const Identity &sender_id)
class register implement
Definition arena_queue.h:37