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/topic_statistics/subscription_topic_statistics.hpp"
35 #include "rclcpp/visibility_control.hpp"
57 using SubscriptionFactoryFunction = std::function<
58 rclcpp::SubscriptionBase::SharedPtr(
60 const std::string & topic_name,
63 const SubscriptionFactoryFunction create_typed_subscription;
78 typename MessageMemoryStrategyT =
typename SubscriptionT::MessageMemoryStrategyType,
79 typename ROSMessageType =
typename SubscriptionT::ROSMessageType
83 CallbackT && callback,
85 typename MessageMemoryStrategyT::SharedPtr msg_mem_strat,
87 subscription_topic_stats =
nullptr
90 auto allocator = options.get_allocator();
94 any_subscription_callback.
set(std::forward<CallbackT>(callback));
98 [options, msg_mem_strat, any_subscription_callback, subscription_topic_stats](
100 const std::string & topic_name,
102 ) -> rclcpp::SubscriptionBase::SharedPtr
109 rclcpp::get_message_type_support_handle<MessageT>(),
112 any_subscription_callback,
115 subscription_topic_stats);
119 sub->post_init_setup(node_base, qos, options);
120 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, std::shared_ptr< rclcpp::topic_statistics::SubscriptionTopicStatistics< ROSMessageType >> subscription_topic_stats=nullptr)
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.