15 #ifndef RCLCPP__SUBSCRIPTION_FACTORY_HPP_
16 #define RCLCPP__SUBSCRIPTION_FACTORY_HPP_
25 #include "rosidl_typesupport_cpp/message_type_support.hpp"
27 #include "rclcpp/any_subscription_callback.hpp"
28 #include "rclcpp/get_message_type_support_handle.hpp"
29 #include "rclcpp/node_interfaces/node_base_interface.hpp"
30 #include "rclcpp/qos.hpp"
31 #include "rclcpp/subscription.hpp"
32 #include "rclcpp/subscription_options.hpp"
33 #include "rclcpp/subscription_traits.hpp"
34 #include "rclcpp/visibility_control.hpp"
56 using SubscriptionFactoryFunction = std::function<
57 rclcpp::SubscriptionBase::SharedPtr(
59 const std::string & topic_name,
62 const SubscriptionFactoryFunction create_typed_subscription;
76 typename MessageMemoryStrategyT =
typename SubscriptionT::MessageMemoryStrategyType
80 CallbackT && callback,
82 typename MessageMemoryStrategyT::SharedPtr msg_mem_strat
85 auto allocator = options.get_allocator();
89 any_subscription_callback.
set(std::forward<CallbackT>(callback));
93 [options, msg_mem_strat, any_subscription_callback](
95 const std::string & topic_name,
97 ) -> rclcpp::SubscriptionBase::SharedPtr
104 rclcpp::get_message_type_support_handle<MessageT>(),
107 any_subscription_callback,
113 sub->post_init_setup(node_base, qos, options);
114 auto sub_base_ptr = std::dynamic_pointer_cast<SubscriptionBase>(sub);
AnySubscriptionCallback< MessageT, AllocatorT > set(CallbackT callback)
Generic function for setting the callback.
Encapsulation of Quality of Service settings.
Subscription implementation, templated on the type of message this subscription receives.
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.
SubscriptionFactory create_subscription_factory(CallbackT &&callback, const rclcpp::SubscriptionOptionsWithAllocator< AllocatorT > &options, typename MessageMemoryStrategyT::SharedPtr msg_mem_strat)
Return a SubscriptionFactory setup to create a SubscriptionT<MessageT, AllocatorT>.
Factory containing a function used to create a Subscription<MessageT>.
Structure containing optional configuration for Subscriptions.