16#ifndef NROS_RCLCPP_SERVICE_HPP
17#define NROS_RCLCPP_SERVICE_HPP
22#include "rclcpp/detail/callback_context.hpp"
24#include "rclcpp/detail/entity_name.hpp"
26#include "rclcpp/service_handle.hpp"
27#include "rclcpp/size_bound.hpp"
29#include "rclcpp/detail/nros_cpp_ffi.h"
47 uint8_t* resp,
size_t resp_cap,
48 size_t* resp_len,
void* ctx);
51 const char* service_name,
const char* type_name,
54 void* context, uint8_t sched_context,
55 size_t* out_handle_id);
231 : initialized_(
other.initialized_), handle_id_(
other.handle_id_), service_name_{},
232 executor_(
other.executor_) {
233 ::rclcpp::detail::assign_entity_name(service_name_,
other.service_name_);
234 other.initialized_ =
false;
238 if (
this != &
other) {
239 initialized_ =
other.initialized_;
240 handle_id_ =
other.handle_id_;
241 ::rclcpp::detail::assign_entity_name(service_name_,
other.service_name_);
243 executor_ =
other.executor_;
244 other.initialized_ =
false;
260 friend class ::rclcpp::Node;
274 if (
user_fn ==
nullptr)
return false;
296 if (!initialized_) return ::rclcpp::detail::qos_all_unknown();
297 if (nros_cpp_service_server_get_actual_qos(
nullptr, executor_, handle_id_, &req, &resp) !=
299 return ::rclcpp::detail::qos_all_unknown();
301 return ::rclcpp::detail::qos_from_ffi(request ? req : resp);
309 size_t handle_id_ =
static_cast<size_t>(-1);
318 void* executor_ =
nullptr;
335template <
typename S,
typename F,
typename>
337 const ::rclcpp::QoS& qos, const ::rclcpp::ServiceOptions& options) {
350 : static_cast<uint8_t>(options.sched_context);
351 size_t handle =
static_cast<size_t>(-1);
353 &handle_, service_name, S::TYPE_NAME, S::Request::TYPE_HASH, ffi_qos,
355 ::rclcpp::detail::fn_to_context(user_fn), sched, &handle);
357 out.handle_id_ = handle;
360 ::rclcpp::detail::assign_entity_name(out.service_name_, service_name);
363 out.executor_ = executor_handle_;
364 out.initialized_ =
true;
Definition client.hpp:129
::rclcpp::Owned<::rclcpp::PollService< S > > create_service(const char *name, const ::rclcpp::QoS &qos=::rclcpp::QoS::services())
Definition service.hpp:118
const char * get_service_name() const
Definition service.hpp:171
Service & operator=(Service &&other)
Definition service.hpp:237
Service(Service &&other)
Definition service.hpp:230
~Service()
Definition service.hpp:213
void(*)(const RequestType &request, ResponseType &response) TypedServiceFn
Definition service.hpp:152
size_t handle_id() const
Executor arena slot for the registration; SIZE_MAX until registered.
Definition service.hpp:254
::rclcpp::QoS get_response_publisher_actual_qos() const
Definition service.hpp:202
typename S::Request RequestType
Definition service.hpp:138
::rclcpp::QoS get_request_subscription_actual_qos() const
Definition service.hpp:197
bool is_valid() const
Check if the service was registered.
Definition service.hpp:155
Service()
Definition service.hpp:251
typename S::Response ResponseType
Definition service.hpp:139
Inline storage-size macros for opaque entity buffers.
int nros_cpp_ret_t
Definition future.hpp:21
ResultOf< void > Result
Definition result.hpp:246
rclcpp::Node and global session helpers.
rclcpp::QoS — full DDS-shaped QoS settings (Phase 108.B.7).
rclcpp::Result, rclcpp::ErrorCode, and the RCLCPP_TRY macro.
bool(* nros_cpp_service_request_callback_t)(const uint8_t *req, size_t req_len, uint8_t *resp, size_t resp_cap, size_t *resp_len, void *ctx)
Definition service.hpp:46
nros_cpp_ret_t nros_cpp_service_server_register(const nros_cpp_node_t *node, const char *service_name, const char *type_name, const char *type_hash, nros_cpp_qos_t qos, nros_cpp_service_request_callback_t callback, void *context, uint8_t sched_context, size_t *out_handle_id)