@@ -63,13 +63,25 @@ namespace experimental
6363class IntraProcessManager ;
6464} // namespace experimental
6565
66- enum class SubscriptionType : uint8_t
66+ // / The kind of message that the subscription delivers in its callback, used by the executor
67+ /* *
68+ * This enum needs to exist because the callback handle is not accessible to the executor's scope.
69+ *
70+ * "Kind" is used since what is being delivered is a category of messages, for example, there are
71+ * different ROS message types that can be delivered, but they're all ROS messages.
72+ *
73+ * As a concrete example, all of the following callbacks will be considered ROS_MESSAGE for
74+ * DeliveredMessageKind:
75+ * - void callback(const std_msgs::msg::String &)
76+ * - void callback(const std::string &) // type adaption
77+ * - void callback(std::unique_ptr<std_msgs::msg::String>)
78+ */
79+ enum class DeliveredMessageKind : uint8_t
6780{
68- INVALID = 0 , // The subscription type is most likely uninitialized
69- ROS_MESSAGE = 1 , // take message as ROS message and handle as ROS message
70- SERIALIZED_MESSAGE = 2 , // take message as serialized and handle as serialized
71- DYNAMIC_MESSAGE_DIRECT = 3 , // take message as DynamicMessage and handle as DynamicMessage
72- DYNAMIC_MESSAGE_FROM_SERIALIZED = 4 // take message as serialized and handle as DynamicMessage
81+ INVALID = 0 ,
82+ ROS_MESSAGE = 1 , // The subscription delivers a ROS message to its callback
83+ SERIALIZED_MESSAGE = 2 , // The subscription delivers a serialized message to its callback
84+ DYNAMIC_MESSAGE = 3 , // The subscription delivers a dynamic message to its callback
7385};
7486
7587// / Virtual base class for subscriptions. This pattern allows us to iterate over different template
@@ -88,7 +100,8 @@ class SubscriptionBase : public std::enable_shared_from_this<SubscriptionBase>
88100 * \param[in] type_support_handle rosidl type support struct, for the Message type of the topic.
89101 * \param[in] topic_name Name of the topic to subscribe to.
90102 * \param[in] subscription_options Options for the subscription.
91- * \param[in] subscription_type Enum flag to change how the message will be received and delivered
103+ * \param[in] delivered_message_kind Enum flag to change how the message will be received and
104+ * delivered
92105 */
93106 RCLCPP_PUBLIC
94107 SubscriptionBase (
@@ -98,7 +111,7 @@ class SubscriptionBase : public std::enable_shared_from_this<SubscriptionBase>
98111 const rcl_subscription_options_t & subscription_options,
99112 const SubscriptionEventCallbacks & event_callbacks,
100113 bool use_default_callbacks,
101- SubscriptionType subscription_type = SubscriptionType ::ROS_MESSAGE);
114+ DeliveredMessageKind delivered_message_kind = DeliveredMessageKind ::ROS_MESSAGE);
102115
103116 // / Destructor.
104117 RCLCPP_PUBLIC
@@ -249,10 +262,10 @@ class SubscriptionBase : public std::enable_shared_from_this<SubscriptionBase>
249262
250263 // / Return the type of the subscription.
251264 /* *
252- * \return `SubscriptionType `, which adjusts how messages are received and delivered.
265+ * \return `DeliveredMessageKind `, which adjusts how messages are received and delivered.
253266 */
254267 RCLCPP_PUBLIC
255- SubscriptionType
268+ DeliveredMessageKind
256269 get_subscription_type () const ;
257270
258271 // / Get matching publisher count.
@@ -650,7 +663,7 @@ class SubscriptionBase : public std::enable_shared_from_this<SubscriptionBase>
650663 RCLCPP_DISABLE_COPY (SubscriptionBase)
651664
652665 rosidl_message_type_support_t type_support_;
653- SubscriptionType subscription_type_ ;
666+ DeliveredMessageKind delivered_message_type_ ;
654667
655668 std::atomic<bool > subscription_in_use_by_wait_set_{false };
656669 std::atomic<bool > intra_process_subscription_waitable_in_use_by_wait_set_{false };
0 commit comments