diff --git a/rclcpp/include/rclcpp/typesupport_helpers.hpp b/rclcpp/include/rclcpp/typesupport_helpers.hpp index c93b318440..e732a2a73a 100644 --- a/rclcpp/include/rclcpp/typesupport_helpers.hpp +++ b/rclcpp/include/rclcpp/typesupport_helpers.hpp @@ -23,6 +23,7 @@ #include "rcpputils/shared_library.hpp" #include "rosidl_runtime_cpp/message_type_support_decl.hpp" #include "rosidl_runtime_cpp/service_type_support_decl.hpp" +#include "rosidl_runtime_cpp/action_type_support_decl.hpp" #include "rclcpp/visibility_control.hpp" @@ -76,7 +77,7 @@ get_message_typesupport_handle( /// Extract the service type support handle from the library. /** - * The library needs to match the topic type. The shared library must stay loaded for the lifetime of the result. + * The library needs to match the service type. The shared library must stay loaded for the lifetime of the result. * * \param[in] type The service type, e.g. "std_srvs/srv/Empty" * \param[in] typesupport_identifier Type support identifier, typically "rosidl_typesupport_cpp" @@ -91,6 +92,23 @@ get_service_typesupport_handle( const std::string & typesupport_identifier, rcpputils::SharedLibrary & library); +/// Extract the action type support handle from the library. +/** + * The library needs to match the action type. The shared library must stay loaded for the lifetime of the result. + * + * \param[in] type The action type, e.g. "action_tutorials_interfaces/action/Fibonacci" + * \param[in] typesupport_identifier Type support identifier, typically "rosidl_typesupport_cpp" + * \param[in] library The shared type support library + * \throws std::runtime_error if the symbol of type not found in the library. + * \return A action type support handle + */ +RCLCPP_PUBLIC +const rosidl_action_type_support_t * +get_action_typesupport_handle( + const std::string & type, + const std::string & typesupport_identifier, + rcpputils::SharedLibrary & library); + } // namespace rclcpp #endif // RCLCPP__TYPESUPPORT_HELPERS_HPP_ diff --git a/rclcpp/src/rclcpp/typesupport_helpers.cpp b/rclcpp/src/rclcpp/typesupport_helpers.cpp index 04dd8c4c9f..8f3c1a2817 100644 --- a/rclcpp/src/rclcpp/typesupport_helpers.cpp +++ b/rclcpp/src/rclcpp/typesupport_helpers.cpp @@ -177,4 +177,19 @@ const rosidl_service_type_support_t * get_service_typesupport_handle( )); } +const rosidl_action_type_support_t * get_action_typesupport_handle( + const std::string & type, + const std::string & typesupport_identifier, + rcpputils::SharedLibrary & library) +{ + static const std::string typesupport_name = "action"; + static const std::string symbol_part_name = "__get_action_type_support_handle__"; + static const std::string middle_module_additional = "action"; + + return static_cast(get_typesupport_handle_impl( + type, typesupport_identifier, typesupport_name, symbol_part_name, + middle_module_additional, library + )); +} + } // namespace rclcpp