Apollo 9.0
自动驾驶开放平台
apollo::cyber::PyService类 参考

#include <py_cyber.h>

apollo::cyber::PyService 的协作图:

Public 成员函数

 PyService (const std::string &service_name, const std::string &data_type, Node *node)
 
void register_func (int(*func)(const char *))
 
std::string read ()
 
int write (const std::string &data)
 

详细描述

在文件 py_cyber.h 第 187 行定义.

构造及析构函数说明

◆ PyService()

apollo::cyber::PyService::PyService ( const std::string &  service_name,
const std::string &  data_type,
Node *  node 
)
inline

在文件 py_cyber.h 第 189 行定义.

191 : node_(node),
192 service_name_(service_name),
193 data_type_(data_type),
194 func_(nullptr) {
195 auto f = [this](
196 const std::shared_ptr<const message::PyMessageWrap>& request,
197 std::shared_ptr<message::PyMessageWrap>& response) {
198 response = this->cb(request);
199 };
200 service_ =
201 node_->CreateService<message::PyMessageWrap, message::PyMessageWrap>(
202 service_name, f);
203 }
double f
auto CreateService(const std::string &service_name, const typename Service< Request, Response >::ServiceCallback &service_callback) -> std::shared_ptr< Service< Request, Response > >
Create a Service object with specific service_name
Definition node.h:258

成员函数说明

◆ read()

std::string apollo::cyber::PyService::read ( )
inline

在文件 py_cyber.h 第 207 行定义.

207 {
208 std::string msg("");
209 if (!request_cache_.empty()) {
210 msg = std::move(request_cache_.front());
211 request_cache_.pop_front();
212 }
213 return msg;
214 }

◆ register_func()

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

在文件 py_cyber.h 第 205 行定义.

205{ func_ = func; }

◆ write()

int apollo::cyber::PyService::write ( const std::string &  data)
inline

在文件 py_cyber.h 第 216 行定义.

216 {
217 response_cache_.push_back(data);
218 return SUCC;
219 }

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