15 #ifndef RCLCPP__SERVICE_HPP_ 16 #define RCLCPP__SERVICE_HPP_ 82 template<typename ServiceT>
100 const
std::
string & service_name,
103 :
ServiceBase(node_handle, service_name), any_callback_(any_callback)
105 using rosidl_typesupport_cpp::get_service_type_support_handle;
106 auto service_type_support_handle = get_service_type_support_handle<ServiceT>();
113 service_handle_, node_handle.get(), service_type_support_handle, service_name.c_str(),
126 any_callback_(any_callback)
132 if (!service_handle->
impl) {
135 std::string(
"rcl_service_t in constructor argument must be initialized beforehand."));
151 ss <<
"Error in destruction of rcl service_handle_ handle: " <<
175 any_callback_.dispatch(request_header, typed_request, response);
176 send_response(request_header, response);
202 #endif // RCLCPP__SERVICE_HPP_ const char * rcl_service_get_service_name(const rcl_service_t *service)
virtual ~Service()
Definition: service.hpp:145
virtual void handle_request(std::shared_ptr< rmw_request_id_t > request_header, std::shared_ptr< void > request)=0
rcl_ret_t rcl_service_init(rcl_service_t *service, const rcl_node_t *node, const rosidl_service_type_support_t *type_support, const char *service_name, const rcl_service_options_t *options)
std::shared_ptr< rmw_request_id_t > create_request_header()
Definition: service.hpp:163
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
rcl_service_t * service_handle_
Definition: service.hpp:75
const rcl_service_t * get_service_handle()
struct rcl_service_impl_t * impl
Definition: allocator_common.hpp:24
std::string get_service_name()
void send_response(std::shared_ptr< rmw_request_id_t > req_id, std::shared_ptr< typename ServiceT::Response > response)
Definition: service.hpp:179
void handle_request(std::shared_ptr< rmw_request_id_t > request_header, std::shared_ptr< void > request)
Definition: service.hpp:170
virtual std::shared_ptr< void > create_request()=0
rcl_ret_t rcl_send_response(const rcl_service_t *service, rmw_request_id_t *response_header, void *ros_response)
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
ServiceBase(std::shared_ptr< rcl_node_t > node_handle, const std::string &service_name)
Definition: service.hpp:83
bool owns_rcl_handle_
Definition: service.hpp:77
T static_pointer_cast(T... args)
#define rcl_get_error_string_safe
rcl_ret_t rcl_service_fini(rcl_service_t *service, rcl_node_t *node)
#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...)
Definition: macros.hpp:51
virtual std::shared_ptr< rmw_request_id_t > create_request_header()=0
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
Definition: service.hpp:39
std::shared_ptr< rcl_node_t > node_handle_
Definition: service.hpp:73
rcl_service_t rcl_get_zero_initialized_service(void)
Service(std::shared_ptr< rcl_node_t > node_handle, rcl_service_t *service_handle, AnyServiceCallback< ServiceT > any_callback)
Definition: service.hpp:121
std::shared_ptr< void > create_request()
Definition: service.hpp:158
std::string service_name_
Definition: service.hpp:76
Definition: any_service_callback.hpp:34