Apollo 10.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.h188 行定义.

构造及析构函数说明

◆ PyService()

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

在文件 py_cyber.h190 行定义.

192 : node_(node),
193 service_name_(service_name),
194 data_type_(data_type),
195 func_(nullptr) {
196 auto f = [this](
197 const std::shared_ptr<const message::PyMessageWrap>& request,
198 std::shared_ptr<message::PyMessageWrap>& response) {
199 response = this->cb(request);
200 };
201 service_ =
202 node_->CreateService<message::PyMessageWrap, message::PyMessageWrap>(
203 service_name, f);
204 }
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.h208 行定义.

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

◆ register_func()

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

在文件 py_cyber.h206 行定义.

206{ func_ = func; }

◆ write()

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

在文件 py_cyber.h217 行定义.

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

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