Apollo 10.0
自动驾驶开放平台
apollo::common::ClientWrapper< Request, Response > 模板类 参考

Wrapper of cyber::Client which sends a topic with service name when SendRequst is invoked. 更多...

#include <client_wrapper.h>

apollo::common::ClientWrapper< Request, Response > 的协作图:

Public 成员函数

 ClientWrapper (const std::shared_ptr< cyber::Node > &node, const std::string &service_name)
 
std::shared_ptr< Response > SendRequest (std::shared_ptr< Request > request, const std::chrono::seconds &timeout_s=std::chrono::seconds(5))
 Request the Service with a shared ptr Request type
 
std::shared_ptr< Response > SendRequest (const Request &request, const std::chrono::seconds &timeout_s=std::chrono::seconds(5))
 Request the Service with a Request object
 
std::shared_future< Response > AsyncSendRequest (std::shared_ptr< Request > request)
 Send Request shared ptr asynchronously
 
std::shared_future< Response > AsyncSendRequest (const Request &request)
 Send Request object asynchronously
 
std::shared_future< Response > AsyncSendRequest (std::shared_ptr< Request > request, std::function< void(std::shared_future< std::shared_ptr< Response > >)> &&cb)
 Send Request shared ptr asynchronously and invoke cb after we get response
 

详细描述

template<typename Request, typename Response>
class apollo::common::ClientWrapper< Request, Response >

Wrapper of cyber::Client which sends a topic with service name when SendRequst is invoked.

在文件 client_wrapper.h40 行定义.

构造及析构函数说明

◆ ClientWrapper()

template<typename Request , typename Response >
apollo::common::ClientWrapper< Request, Response >::ClientWrapper ( const std::shared_ptr< cyber::Node > &  node,
const std::string &  service_name 
)

在文件 client_wrapper.h96 行定义.

98 : client_(node->CreateClient<Request, Response>(service_name)),
99 request_writer_(node->CreateWriter<Request>(service_name)) {}

成员函数说明

◆ AsyncSendRequest() [1/3]

template<typename Request , typename Response >
std::shared_future< Response > apollo::common::ClientWrapper< Request, Response >::AsyncSendRequest ( const Request &  request)

Send Request object asynchronously

在文件 client_wrapper.h126 行定义.

127 {
128 auto response = client_->AsyncSendRequest(request);
129 request_writer_->Write(request);
130 return response;
131}

◆ AsyncSendRequest() [2/3]

template<typename Request , typename Response >
std::shared_future< Response > apollo::common::ClientWrapper< Request, Response >::AsyncSendRequest ( std::shared_ptr< Request >  request)

Send Request shared ptr asynchronously

在文件 client_wrapper.h118 行定义.

119 {
120 auto response = client_->AsyncSendRequest(request);
121 request_writer_->Write(request);
122 return response;
123}

◆ AsyncSendRequest() [3/3]

template<typename Request , typename Response >
std::shared_future< Response > apollo::common::ClientWrapper< Request, Response >::AsyncSendRequest ( std::shared_ptr< Request >  request,
std::function< void(std::shared_future< std::shared_ptr< Response > >)> &&  cb 
)

Send Request shared ptr asynchronously and invoke cb after we get response

参数
requestRequest shared ptr
cbcallback function after we get response
返回
std::shared_future<Response> a std::future shared ptr

在文件 client_wrapper.h134 行定义.

136 {
137 auto response = client_->AsyncSendRequest(request, cb);
138 request_writer_->Write(request);
139 return response;
140}

◆ SendRequest() [1/2]

template<typename Request , typename Response >
std::shared_ptr< Response > apollo::common::ClientWrapper< Request, Response >::SendRequest ( const Request &  request,
const std::chrono::seconds &  timeout_s = std::chrono::seconds(5) 
)

Request the Service with a Request object

参数
requestRequest object
timeout_srequest timeout, if timeout, response will be empty
返回
std::shared_ptr<Response> result of this request

在文件 client_wrapper.h110 行定义.

111 {
112 auto response = client_->SendRequest(request);
113 request_writer_->Write(request);
114 return response;
115}

◆ SendRequest() [2/2]

template<typename Request , typename Response >
std::shared_ptr< Response > apollo::common::ClientWrapper< Request, Response >::SendRequest ( std::shared_ptr< Request >  request,
const std::chrono::seconds &  timeout_s = std::chrono::seconds(5) 
)

Request the Service with a shared ptr Request type

参数
requestshared ptr of Request type
timeout_srequest timeout, if timeout, response will be empty
返回
std::shared_ptr<Response> result of this request

在文件 client_wrapper.h102 行定义.

103 {
104 auto response = client_->SendRequest(request);
105 request_writer_->Write(request);
106 return response;
107}

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