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,
78 std::function<
void(std::shared_ptr<rclcpp::SerializedMessage>)> callback,
92 this->add_event_handler(
94 RCL_SUBSCRIPTION_REQUESTED_DEADLINE_MISSED);
97 this->add_event_handler(
99 RCL_SUBSCRIPTION_LIVELINESS_CHANGED);
102 this->add_event_handler(
104 RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS);
108 this->add_event_handler(
109 [
this](QOSRequestedIncompatibleQoSInfo & info) {
110 this->default_incompatible_qos_callback(info);
112 RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS);
118 this->add_event_handler(
120 RCL_SUBSCRIPTION_MESSAGE_LOST);
143 const std::shared_ptr<rclcpp::SerializedMessage> & serialized_message,
161 std::function<void(std::shared_ptr<rclcpp::SerializedMessage>)> callback_;
163 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 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.
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, std::function< void(std::shared_ptr< rclcpp::SerializedMessage >)> callback, const rclcpp::SubscriptionOptionsWithAllocator< AllocatorT > &options)
Constructor.
RCLCPP_PUBLIC std::shared_ptr< void > create_message() override
Borrow a new message.
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.
Object oriented version of rcl_serialized_message_t with destructor to avoid memory leaks.
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.
RCLCPP_PUBLIC const rosidl_message_type_support_t * get_typesupport_handle(const std::string &type, const std::string &typesupport_identifier, rcpputils::SharedLibrary &library)
Extract the type support handle from the library.
SubscriptionEventCallbacks event_callbacks
Callbacks for events related to this subscription.
bool use_default_callbacks
Whether or not to use default callbacks when user doesn't supply any in event_callbacks.
Structure containing optional configuration for Subscriptions.