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

#include <py_cyber.h>

apollo::cyber::PyReader 的协作图:

Public 成员函数

 PyReader (const std::string &channel, const std::string &type, Node *node)
 
void register_func (int(*func)(const char *))
 
std::string read (bool wait=false)
 

详细描述

在文件 py_cyber.h110 行定义.

构造及析构函数说明

◆ PyReader()

apollo::cyber::PyReader::PyReader ( const std::string &  channel,
const std::string &  type,
Node node 
)
inline

在文件 py_cyber.h112 行定义.

113 : channel_name_(channel), data_type_(type), node_(node), func_(nullptr) {
114 if (data_type_.compare(RAWDATATYPE) == 0) {
115 auto f =
116 [this](const std::shared_ptr<const message::PyMessageWrap>& request) {
117 this->cb(request);
118 };
119 reader_ = node_->CreateReader<message::PyMessageWrap>(channel, f);
120 } else {
121 auto f =
122 [this](const std::shared_ptr<const message::RawMessage>& request) {
123 this->cb_rawmsg(request);
124 };
125 reader_rawmsg_ = node_->CreateReader<message::RawMessage>(channel, f);
126 }
127 }
double f
auto CreateReader(const std::string &channel_name, const CallbackFunc< MessageT > &reader_func=nullptr) -> std::shared_ptr< cyber::Reader< MessageT > >
Create a Reader with specific message type with channel name qos and other configs used will be defau...
Definition node.h:240
const char RAWDATATYPE[]
Definition py_cyber.h:109

成员函数说明

◆ read()

std::string apollo::cyber::PyReader::read ( bool  wait = false)
inline

在文件 py_cyber.h131 行定义.

131 {
132 std::string msg("");
133 std::unique_lock<std::mutex> ul(msg_lock_);
134 if (!cache_.empty()) {
135 msg = std::move(cache_.front());
136 cache_.pop_front();
137 }
138
139 if (!wait) {
140 return msg;
141 }
142
143 msg_cond_.wait(ul, [this] { return !this->cache_.empty(); });
144 if (!cache_.empty()) {
145 msg = std::move(cache_.front());
146 cache_.pop_front();
147 }
148
149 return msg;
150 }

◆ register_func()

void apollo::cyber::PyReader::register_func ( int(*)(const char *)  func)
inline

在文件 py_cyber.h129 行定义.

129{ func_ = func; }

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