16 #ifndef RCLCPP__GENERIC_SUBSCRIPTION_HPP_
17 #define RCLCPP__GENERIC_SUBSCRIPTION_HPP_
23 #include "rcpputils/shared_library.hpp"
25 #include "rclcpp/callback_group.hpp"
26 #include "rclcpp/macros.hpp"
27 #include "rclcpp/node_interfaces/node_base_interface.hpp"
28 #include "rclcpp/node_interfaces/node_topics_interface.hpp"
29 #include "rclcpp/qos.hpp"
30 #include "rclcpp/serialized_message.hpp"
31 #include "rclcpp/subscription_base.hpp"
32 #include "rclcpp/typesupport_helpers.hpp"
33 #include "rclcpp/visibility_control.hpp"
70 template<
typename AllocatorT = std::allocator<
void>>
73 const std::shared_ptr<rcpputils::SharedLibrary> ts_lib,
74 const std::string & topic_name,
75 const std::string & topic_type,
83 options.to_rcl_subscription_options(qos),
84 options.event_callbacks,
85 options.use_default_callbacks,
87 any_callback_(callback),
90 TRACETOOLS_TRACEPOINT(
91 rclcpp_subscription_init,
92 static_cast<const void *
>(get_subscription_handle().get()),
93 static_cast<const void *
>(
this));
94 TRACETOOLS_TRACEPOINT(
95 rclcpp_subscription_callback_added,
96 static_cast<const void *
>(
this),
97 static_cast<const void *
>(&any_callback_));
99 #ifndef TRACETOOLS_DISABLED
100 any_callback_.register_callback_for_tracing();
123 const std::shared_ptr<rclcpp::SerializedMessage> & serialized_message,
141 rclcpp::dynamic_typesupport::DynamicMessageType::SharedPtr get_shared_dynamic_message_type()
145 rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr get_shared_dynamic_message()
override;
148 rclcpp::dynamic_typesupport::DynamicSerializationSupport::SharedPtr
149 get_shared_dynamic_serialization_support()
override;
155 void return_dynamic_message(
156 rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr & message)
override;
159 void handle_dynamic_message(
160 const rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr & message,
167 std::shared_ptr<rcpputils::SharedLibrary> ts_lib_;
Subscription for serialized messages whose type is not known at compile time.
RCLCPP_PUBLIC void return_message(std::shared_ptr< void > &message) override
Return the message borrowed in create_message.
RCLCPP_PUBLIC rclcpp::dynamic_typesupport::DynamicMessage::SharedPtr create_dynamic_message() override
Borrow a new serialized message (this clones!)
RCLCPP_PUBLIC void return_serialized_message(std::shared_ptr< rclcpp::SerializedMessage > &message) override
Return the message borrowed in create_serialized_message.
RCLCPP_PUBLIC void handle_message(std::shared_ptr< void > &message, const rclcpp::MessageInfo &message_info) override
Cast the message to a rclcpp::SerializedMessage and call the callback.
RCLCPP_PUBLIC std::shared_ptr< rclcpp::SerializedMessage > create_serialized_message() override
Borrow a new serialized message.
RCLCPP_PUBLIC void handle_loaned_message(void *loaned_message, const rclcpp::MessageInfo &message_info) override
This function is currently not implemented.
RCLCPP_PUBLIC std::shared_ptr< void > create_message() override
Borrow a new message.
GenericSubscription(rclcpp::node_interfaces::NodeBaseInterface *node_base, const std::shared_ptr< rcpputils::SharedLibrary > ts_lib, const std::string &topic_name, const std::string &topic_type, const rclcpp::QoS &qos, AnySubscriptionCallback< rclcpp::SerializedMessage, AllocatorT > callback, const rclcpp::SubscriptionOptionsWithAllocator< AllocatorT > &options)
Constructor.
RCLCPP_PUBLIC void handle_serialized_message(const std::shared_ptr< rclcpp::SerializedMessage > &serialized_message, const rclcpp::MessageInfo &message_info) override
Handle dispatching rclcpp::SerializedMessage to user callback.
Additional meta data about messages taken from subscriptions.
Encapsulation of Quality of Service settings.
Pure virtual interface class for the NodeBase part of the Node API.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
DeliveredMessageKind
The kind of message that the subscription delivers in its callback, used by the executor.
RCLCPP_PUBLIC const rosidl_message_type_support_t * get_message_typesupport_handle(const std::string &type, const std::string &typesupport_identifier, rcpputils::SharedLibrary &library)
Extracts the message type support handle from the library.
Structure containing optional configuration for Subscriptions.