Move request header to a separate structure

This commit is contained in:
Esteve Fernandez 2015-01-07 14:15:46 -08:00
parent 81040198e1
commit 180c0f9016
3 changed files with 6 additions and 6 deletions

View file

@ -101,7 +101,7 @@ public:
typename rclcpp::service::Service<ServiceT>::SharedPtr
create_service(
std::string service_name,
std::function<void(const std::shared_ptr<typename ServiceT::Request> &,
std::function<void(const std::shared_ptr<typename ServiceT::RequestWithHeader> &,
std::shared_ptr<typename ServiceT::Response>&)> callback,
rclcpp::callback_group::CallbackGroup::SharedPtr group=nullptr);

View file

@ -187,7 +187,7 @@ template <typename ServiceT>
typename service::Service<ServiceT>::SharedPtr
Node::create_service(
std::string service_name,
std::function<void(const std::shared_ptr<typename ServiceT::Request> &,
std::function<void(const std::shared_ptr<typename ServiceT::RequestWithHeader> &,
std::shared_ptr<typename ServiceT::Response>&)> callback,
rclcpp::callback_group::CallbackGroup::SharedPtr group)
{

View file

@ -70,7 +70,7 @@ class Service : public ServiceBase
{
public:
typedef std::function<
void(const std::shared_ptr<typename ServiceT::Request> &,
void(const std::shared_ptr<typename ServiceT::RequestWithHeader> &,
std::shared_ptr<typename ServiceT::Response>&)> CallbackType;
RCLCPP_MAKE_SHARED_DEFINITIONS(Service);
@ -83,19 +83,19 @@ public:
std::shared_ptr<void> create_request()
{
return std::shared_ptr<void>(new typename ServiceT::Request());
return std::shared_ptr<void>(new typename ServiceT::RequestWithHeader());
}
void handle_request(std::shared_ptr<void> &request)
{
auto typed_request = std::static_pointer_cast<typename ServiceT::Request>(request);
auto typed_request = std::static_pointer_cast<typename ServiceT::RequestWithHeader>(request);
auto response = std::shared_ptr<typename ServiceT::Response>(new typename ServiceT::Response);
callback_(typed_request, response);
send_response(typed_request, response);
}
void send_response(
std::shared_ptr<typename ServiceT::Request> &request,
std::shared_ptr<typename ServiceT::RequestWithHeader> &request,
std::shared_ptr<typename ServiceT::Response> &response)
{
::ros_middleware_interface::send_response(get_service_handle(), request.get(), response.get());