15 #ifndef RCLCPP__ANY_SERVICE_CALLBACK_HPP_
16 #define RCLCPP__ANY_SERVICE_CALLBACK_HPP_
21 #include <type_traits>
26 #include "tracetools/tracetools.h"
27 #include "tracetools/utils.hpp"
32 template<
typename ServiceT>
53 : shared_ptr_callback_(nullptr), shared_ptr_with_request_header_callback_(nullptr)
67 void set(CallbackT callback)
69 shared_ptr_callback_ = callback;
77 SharedPtrWithRequestHeaderCallback
81 void set(CallbackT callback)
83 shared_ptr_with_request_header_callback_ = callback;
91 TRACEPOINT(callback_start, (
const void *)
this,
false);
92 if (shared_ptr_callback_ !=
nullptr) {
94 shared_ptr_callback_(request, response);
95 }
else if (shared_ptr_with_request_header_callback_ !=
nullptr) {
96 shared_ptr_with_request_header_callback_(request_header, request, response);
100 TRACEPOINT(callback_end, (
const void *)
this);
105 #ifndef TRACETOOLS_DISABLED
106 if (shared_ptr_callback_) {
108 rclcpp_callback_register,
110 get_symbol(shared_ptr_callback_));
111 }
else if (shared_ptr_with_request_header_callback_) {
113 rclcpp_callback_register,
115 get_symbol(shared_ptr_with_request_header_callback_));
117 #endif // TRACETOOLS_DISABLED
123 #endif // RCLCPP__ANY_SERVICE_CALLBACK_HPP_