@@ -91,36 +91,40 @@ extract_type_identifier(const std::string & full_type)
9191 return std::make_tuple (package_name, middle_module, type_name);
9292}
9393
94- const void * get_typesupport_handle_impl (
94+ } // anonymous namespace
95+
96+ std::shared_ptr<rcpputils::SharedLibrary>
97+ get_typesupport_library (const std::string & type, const std::string & typesupport_identifier)
98+ {
99+ auto package_name = std::get<0 >(extract_type_identifier (type));
100+ auto library_path = get_typesupport_library_path (package_name, typesupport_identifier);
101+ return std::make_shared<rcpputils::SharedLibrary>(library_path);
102+ }
103+
104+ const rosidl_message_type_support_t *
105+ get_typesupport_handle (
95106 const std::string & type,
96107 const std::string & typesupport_identifier,
97- const std::string & typesupport_name,
98- const std::string & symbol_part_name,
99- const std::string & middle_module_additional,
100108 rcpputils::SharedLibrary & library)
101109{
102110 std::string package_name;
103111 std::string middle_module;
104112 std::string type_name;
105113 std::tie (package_name, middle_module, type_name) = extract_type_identifier (type);
106114
107- if (middle_module.empty ()) {
108- middle_module = middle_module_additional;
109- }
110-
111- auto mk_error = [&package_name, &type_name, &typesupport_name](auto reason) {
115+ auto mk_error = [&package_name, &type_name](auto reason) {
112116 std::stringstream rcutils_dynamic_loading_error;
113117 rcutils_dynamic_loading_error <<
114- " Something went wrong loading the typesupport library for " <<
115- typesupport_name << " type " << package_name <<
118+ " Something went wrong loading the typesupport library for message type " << package_name <<
116119 " /" << type_name << " . " << reason;
117120 return rcutils_dynamic_loading_error.str ();
118121 };
119122
120123 try {
121- std::string symbol_name = typesupport_identifier + symbol_part_name +
122- package_name + " __" + middle_module + " __" + type_name;
123- const void * (* get_ts)() = nullptr ;
124+ std::string symbol_name = typesupport_identifier + " __get_message_type_support_handle__" +
125+ package_name + " __" + (middle_module.empty () ? " msg" : middle_module) + " __" + type_name;
126+
127+ const rosidl_message_type_support_t * (* get_ts)() = nullptr ;
124128 // This will throw runtime_error if the symbol was not found.
125129 get_ts = reinterpret_cast <decltype (get_ts)>(library.get_symbol (symbol_name));
126130 return get_ts ();
@@ -129,52 +133,4 @@ const void * get_typesupport_handle_impl(
129133 }
130134}
131135
132- } // anonymous namespace
133-
134- std::shared_ptr<rcpputils::SharedLibrary>
135- get_typesupport_library (const std::string & type, const std::string & typesupport_identifier)
136- {
137- auto package_name = std::get<0 >(extract_type_identifier (type));
138- auto library_path = get_typesupport_library_path (package_name, typesupport_identifier);
139- return std::make_shared<rcpputils::SharedLibrary>(library_path);
140- }
141-
142- const rosidl_message_type_support_t * get_typesupport_handle (
143- const std::string & type,
144- const std::string & typesupport_identifier,
145- rcpputils::SharedLibrary & library)
146- {
147- return get_message_typesupport_handle (type, typesupport_identifier, library);
148- }
149-
150- const rosidl_message_type_support_t * get_message_typesupport_handle (
151- const std::string & type,
152- const std::string & typesupport_identifier,
153- rcpputils::SharedLibrary & library)
154- {
155- static const std::string typesupport_name = " message" ;
156- static const std::string symbol_part_name = " __get_message_type_support_handle__" ;
157- static const std::string middle_module_additional = " msg" ;
158-
159- return static_cast <const rosidl_message_type_support_t *>(get_typesupport_handle_impl (
160- type, typesupport_identifier, typesupport_name, symbol_part_name,
161- middle_module_additional, library
162- ));
163- }
164-
165- const rosidl_service_type_support_t * get_service_typesupport_handle (
166- const std::string & type,
167- const std::string & typesupport_identifier,
168- rcpputils::SharedLibrary & library)
169- {
170- static const std::string typesupport_name = " service" ;
171- static const std::string symbol_part_name = " __get_service_type_support_handle__" ;
172- static const std::string middle_module_additional = " srv" ;
173-
174- return static_cast <const rosidl_service_type_support_t *>(get_typesupport_handle_impl (
175- type, typesupport_identifier, typesupport_name, symbol_part_name,
176- middle_module_additional, library
177- ));
178- }
179-
180136} // namespace rclcpp
0 commit comments