Apollo 10.0
自动驾驶开放平台
apollo::cyber::transport::MessageInfo类 参考

#include <message_info.h>

apollo::cyber::transport::MessageInfo 的协作图:

Public 成员函数

 MessageInfo ()
 
 MessageInfo (const Identity &sender_id, uint64_t seq_num)
 
 MessageInfo (const Identity &sender_id, uint64_t seq_num, const Identity &spare_id)
 
 MessageInfo (const MessageInfo &another)
 
virtual ~MessageInfo ()
 
MessageInfooperator= (const MessageInfo &another)
 
bool operator== (const MessageInfo &another) const
 
bool operator!= (const MessageInfo &another) const
 
bool SerializeTo (std::string *dst) const
 
bool SerializeTo (char *dst, std::size_t len) const
 
bool DeserializeFrom (const std::string &src)
 
bool DeserializeFrom (const char *src, std::size_t len)
 
const Identitysender_id () const
 
void set_sender_id (const Identity &sender_id)
 
uint64_t channel_id () const
 
void set_channel_id (uint64_t channel_id)
 
uint64_t seq_num () const
 
void set_seq_num (uint64_t seq_num)
 
const Identityspare_id () const
 
void set_spare_id (const Identity &spare_id)
 
uint64_t send_time () const
 
void set_send_time (uint64_t send_time)
 

静态 Public 属性

static const std::size_t kSize
 

详细描述

在文件 message_info.h30 行定义.

构造及析构函数说明

◆ MessageInfo() [1/4]

apollo::cyber::transport::MessageInfo::MessageInfo ( )

在文件 message_info.cc31 行定义.

31: sender_id_(false), spare_id_(false) {}

◆ MessageInfo() [2/4]

apollo::cyber::transport::MessageInfo::MessageInfo ( const Identity sender_id,
uint64_t  seq_num 
)

在文件 message_info.cc33 行定义.

34 : sender_id_(sender_id), seq_num_(seq_num), spare_id_(false) {}
const Identity & sender_id() const

◆ MessageInfo() [3/4]

apollo::cyber::transport::MessageInfo::MessageInfo ( const Identity sender_id,
uint64_t  seq_num,
const Identity spare_id 
)

在文件 message_info.cc36 行定义.

38 : sender_id_(sender_id), seq_num_(seq_num), spare_id_(spare_id) {}
const Identity & spare_id() const

◆ MessageInfo() [4/4]

apollo::cyber::transport::MessageInfo::MessageInfo ( const MessageInfo another)

在文件 message_info.cc40 行定义.

41 : sender_id_(another.sender_id_),
42 channel_id_(another.channel_id_),
43 seq_num_(another.seq_num_),
44 spare_id_(another.spare_id_) {}

◆ ~MessageInfo()

apollo::cyber::transport::MessageInfo::~MessageInfo ( )
virtual

在文件 message_info.cc46 行定义.

46{}

成员函数说明

◆ channel_id()

uint64_t apollo::cyber::transport::MessageInfo::channel_id ( ) const
inline

在文件 message_info.h52 行定义.

52{ return channel_id_; }

◆ DeserializeFrom() [1/2]

bool apollo::cyber::transport::MessageInfo::DeserializeFrom ( const char *  src,
std::size_t  len 
)

在文件 message_info.cc107 行定义.

107 {
108 RETURN_VAL_IF_NULL(src, false);
109 if (len != kSize) {
110 AWARN << "src size mismatch, given[" << len << "] target[" << kSize << "]";
111 return false;
112 }
113
114 char* ptr = const_cast<char*>(src);
115 sender_id_.set_data(ptr);
116 ptr += ID_SIZE;
117 std::memcpy(
118 reinterpret_cast<char*>(&channel_id_), ptr, sizeof(channel_id_));
119 ptr += sizeof(channel_id_);
120 std::memcpy(
121 reinterpret_cast<char*>(&seq_num_), ptr, sizeof(seq_num_));
122 ptr += sizeof(seq_num_);
123 spare_id_.set_data(ptr);
124 ptr += ID_SIZE;
125 std::memcpy(
126 reinterpret_cast<char*>(&send_time_), ptr, sizeof(send_time_));
127 return true;
128}
void set_data(const char *data)
Definition identity.h:45
static const std::size_t kSize
#define RETURN_VAL_IF_NULL(ptr, val)
Definition log.h:98
#define AWARN
Definition log.h:43
constexpr uint8_t ID_SIZE
Definition identity.h:28

◆ DeserializeFrom() [2/2]

bool apollo::cyber::transport::MessageInfo::DeserializeFrom ( const std::string &  src)

在文件 message_info.cc103 行定义.

103 {
104 return DeserializeFrom(src.data(), src.size());
105}
bool DeserializeFrom(const std::string &src)

◆ operator!=()

bool apollo::cyber::transport::MessageInfo::operator!= ( const MessageInfo another) const

在文件 message_info.cc64 行定义.

64 {
65 return !(*this == another);
66}

◆ operator=()

MessageInfo & apollo::cyber::transport::MessageInfo::operator= ( const MessageInfo another)

在文件 message_info.cc48 行定义.

48 {
49 if (this != &another) {
50 sender_id_ = another.sender_id_;
51 channel_id_ = another.channel_id_;
52 seq_num_ = another.seq_num_;
53 spare_id_ = another.spare_id_;
54 }
55 return *this;
56}

◆ operator==()

bool apollo::cyber::transport::MessageInfo::operator== ( const MessageInfo another) const

在文件 message_info.cc58 行定义.

58 {
59 return sender_id_ == another.sender_id_ &&
60 channel_id_ == another.channel_id_ && seq_num_ == another.seq_num_ &&
61 spare_id_ == another.spare_id_;
62}

◆ send_time()

uint64_t apollo::cyber::transport::MessageInfo::send_time ( ) const
inline

在文件 message_info.h63 行定义.

63{ return send_time_; }

◆ sender_id()

const Identity & apollo::cyber::transport::MessageInfo::sender_id ( ) const
inline

在文件 message_info.h49 行定义.

49{ return sender_id_; }

◆ seq_num()

uint64_t apollo::cyber::transport::MessageInfo::seq_num ( ) const
inline

在文件 message_info.h55 行定义.

55{ return seq_num_; }

◆ SerializeTo() [1/2]

bool apollo::cyber::transport::MessageInfo::SerializeTo ( char *  dst,
std::size_t  len 
) const

在文件 message_info.cc82 行定义.

82 {
83 if (dst == nullptr || len < kSize) {
84 return false;
85 }
86
87 char* ptr = dst;
88 std::memcpy(ptr, sender_id_.data(), ID_SIZE);
89 ptr += ID_SIZE;
90 std::memcpy(ptr,
91 reinterpret_cast<const char*>(&channel_id_), sizeof(channel_id_));
92 ptr += sizeof(channel_id_);
93 std::memcpy(ptr,
94 reinterpret_cast<const char*>(&seq_num_), sizeof(seq_num_));
95 ptr += sizeof(seq_num_);
96 std::memcpy(ptr, spare_id_.data(), ID_SIZE);
97 ptr += ID_SIZE;
98 std::memcpy(ptr,
99 reinterpret_cast<const char*>(&send_time_), sizeof(send_time_));
100 return true;
101}
const char * data() const
Definition identity.h:44

◆ SerializeTo() [2/2]

bool apollo::cyber::transport::MessageInfo::SerializeTo ( std::string *  dst) const

在文件 message_info.cc68 行定义.

68 {
69 RETURN_VAL_IF_NULL(dst, false);
70
71 dst->assign(sender_id_.data(), ID_SIZE);
72 dst->append(
73 reinterpret_cast<const char*>(&channel_id_), sizeof(channel_id_));
74 dst->append(
75 reinterpret_cast<const char*>(&seq_num_), sizeof(seq_num_));
76 dst->append(spare_id_.data(), ID_SIZE);
77 dst->append(reinterpret_cast<const char*>(
78 &send_time_), sizeof(send_time_));
79 return true;
80}

◆ set_channel_id()

void apollo::cyber::transport::MessageInfo::set_channel_id ( uint64_t  channel_id)
inline

在文件 message_info.h53 行定义.

53{ channel_id_ = channel_id; }

◆ set_send_time()

void apollo::cyber::transport::MessageInfo::set_send_time ( uint64_t  send_time)
inline

在文件 message_info.h64 行定义.

64{ send_time_ = send_time; }

◆ set_sender_id()

void apollo::cyber::transport::MessageInfo::set_sender_id ( const Identity sender_id)
inline

在文件 message_info.h50 行定义.

50{ sender_id_ = sender_id; }

◆ set_seq_num()

void apollo::cyber::transport::MessageInfo::set_seq_num ( uint64_t  seq_num)
inline

在文件 message_info.h56 行定义.

56{ seq_num_ = seq_num; }

◆ set_spare_id()

void apollo::cyber::transport::MessageInfo::set_spare_id ( const Identity spare_id)
inline

在文件 message_info.h59 行定义.

59{ spare_id_ = spare_id; }

◆ spare_id()

const Identity & apollo::cyber::transport::MessageInfo::spare_id ( ) const
inline

在文件 message_info.h58 行定义.

58{ return spare_id_; }

类成员变量说明

◆ kSize

const std::size_t apollo::cyber::transport::MessageInfo::kSize
static
初始值:
= 2 * ID_SIZE + sizeof(uint64_t) +
sizeof(uint64_t) + sizeof(int32_t) +
sizeof(uint64_t)

在文件 message_info.h61 行定义.


该类的文档由以下文件生成: