Apollo 11.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.h109 行定义.

构造及析构函数说明

◆ PyReader()

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

在文件 py_cyber.h111 行定义.

112 : channel_name_(channel), data_type_(type), node_(node), func_(nullptr) {
113 if (data_type_.compare(RAWDATATYPE) == 0) {
114 auto f =
115 [this](const std::shared_ptr<const message::PyMessageWrap>& request) {
116 this->cb(request);
117 };
118 reader_ = node_->CreateReader<message::PyMessageWrap>(channel, f);
119 } else {
120 auto f =
121 [this](const std::shared_ptr<const message::RawMessage>& request) {
122 this->cb_rawmsg(request);
123 };
124 reader_rawmsg_ = node_->CreateReader<message::RawMessage>(channel, f);
125 }
126 }
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:108

成员函数说明

◆ read()

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

在文件 py_cyber.h130 行定义.

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

◆ register_func()

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

在文件 py_cyber.h128 行定义.

128{ func_ = func; }

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