Apollo 10.0
自动驾驶开放平台
apollo::cyber::transport::History< MessageT > 模板类 参考

#include <history.h>

apollo::cyber::transport::History< MessageT > 的协作图:

struct  CachedMessage
 

Public 类型

using MessagePtr = std::shared_ptr< MessageT >
 

Public 成员函数

 History (const HistoryAttributes &attr)
 
virtual ~History ()
 
void Enable ()
 
void Disable ()
 
void Add (const MessagePtr &msg, const MessageInfo &msg_info)
 
void Clear ()
 
void GetCachedMessage (std::vector< CachedMessage > *msgs) const
 
size_t GetSize () const
 
uint32_t depth () const
 
uint32_t max_depth () const
 

详细描述

template<typename MessageT>
class apollo::cyber::transport::History< MessageT >

在文件 history.h35 行定义.

成员类型定义说明

◆ MessagePtr

template<typename MessageT >
using apollo::cyber::transport::History< MessageT >::MessagePtr = std::shared_ptr<MessageT>

在文件 history.h37 行定义.

构造及析构函数说明

◆ History()

template<typename MessageT >
apollo::cyber::transport::History< MessageT >::History ( const HistoryAttributes attr)
explicit

在文件 history.h69 行定义.

70 : enabled_(false), max_depth_(1000) {
71 auto& global_conf = common::GlobalData::Instance()->Config();
72 if (global_conf.has_transport_conf() &&
73 global_conf.transport_conf().has_resource_limit()) {
74 max_depth_ =
75 global_conf.transport_conf().resource_limit().max_history_depth();
76 }
77
78 if (attr.history_policy == proto::QosHistoryPolicy::HISTORY_KEEP_ALL) {
79 depth_ = max_depth_;
80 } else {
81 depth_ = attr.depth;
82 if (depth_ > max_depth_) {
83 depth_ = max_depth_;
84 }
85 }
86}

◆ ~History()

template<typename MessageT >
apollo::cyber::transport::History< MessageT >::~History ( )
virtual

在文件 history.h89 行定义.

89 {
90 Clear();
91}

成员函数说明

◆ Add()

template<typename MessageT >
void apollo::cyber::transport::History< MessageT >::Add ( const MessagePtr msg,
const MessageInfo msg_info 
)

在文件 history.h94 行定义.

95 {
96 if (!enabled_) {
97 return;
98 }
99 std::lock_guard<std::mutex> lock(msgs_mutex_);
100 msgs_.emplace_back(msg, msg_info);
101 while (msgs_.size() > depth_) {
102 msgs_.pop_front();
103 }
104}

◆ Clear()

template<typename MessageT >
void apollo::cyber::transport::History< MessageT >::Clear ( )

在文件 history.h107 行定义.

107 {
108 std::lock_guard<std::mutex> lock(msgs_mutex_);
109 msgs_.clear();
110}

◆ depth()

template<typename MessageT >
uint32_t apollo::cyber::transport::History< MessageT >::depth ( ) const
inline

在文件 history.h57 行定义.

57{ return depth_; }

◆ Disable()

template<typename MessageT >
void apollo::cyber::transport::History< MessageT >::Disable ( )
inline

在文件 history.h50 行定义.

50{ enabled_ = false; }

◆ Enable()

template<typename MessageT >
void apollo::cyber::transport::History< MessageT >::Enable ( )
inline

在文件 history.h49 行定义.

49{ enabled_ = true; }

◆ GetCachedMessage()

template<typename MessageT >
void apollo::cyber::transport::History< MessageT >::GetCachedMessage ( std::vector< CachedMessage > *  msgs) const

在文件 history.h113 行定义.

114 {
115 if (msgs == nullptr) {
116 return;
117 }
118
119 std::lock_guard<std::mutex> lock(msgs_mutex_);
120 msgs->reserve(msgs_.size());
121 msgs->insert(msgs->begin(), msgs_.begin(), msgs_.end());
122}

◆ GetSize()

template<typename MessageT >
size_t apollo::cyber::transport::History< MessageT >::GetSize ( ) const

在文件 history.h125 行定义.

125 {
126 std::lock_guard<std::mutex> lock(msgs_mutex_);
127 return msgs_.size();
128}

◆ max_depth()

template<typename MessageT >
uint32_t apollo::cyber::transport::History< MessageT >::max_depth ( ) const
inline

在文件 history.h58 行定义.

58{ return max_depth_; }

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