From 4de8ad65e91bc088af0a4a456e9a179bc348f5bb Mon Sep 17 00:00:00 2001 From: methylDragon Date: Fri, 7 Apr 2023 18:05:36 -0700 Subject: [PATCH] Remove RMW interfaces Signed-off-by: methylDragon --- rmw/CMakeLists.txt | 1 - .../rmw/dynamic_message_type_support.h | 96 ----------- rmw/src/dynamic_message_type_support.c | 156 ------------------ 3 files changed, 253 deletions(-) delete mode 100644 rmw/src/dynamic_message_type_support.c diff --git a/rmw/CMakeLists.txt b/rmw/CMakeLists.txt index 5e237186..be181238 100644 --- a/rmw/CMakeLists.txt +++ b/rmw/CMakeLists.txt @@ -28,7 +28,6 @@ include(cmake/configure_rmw_library.cmake) set(rmw_sources "src/allocators.c" "src/convert_rcutils_ret_to_rmw_ret.c" - "src/dynamic_message_type_support.c" "src/event.c" "src/init.c" "src/init_options.c" diff --git a/rmw/include/rmw/dynamic_message_type_support.h b/rmw/include/rmw/dynamic_message_type_support.h index ea9e78fb..64c58d28 100644 --- a/rmw/include/rmw/dynamic_message_type_support.h +++ b/rmw/include/rmw/dynamic_message_type_support.h @@ -35,102 +35,6 @@ extern "C" /// Interfaces for runtime interface reflection -// RUNTIME INTERFACE REFLECTION TYPE SUPPORT ======================================================= -/// Get dynamic type message typesupport with bound message description -/** - * NOTE: Take note of the ownership rules for the returned struct and the `description` argument! - * - * If the user passes a NULL description, it is deferred instead, the middleware is responsibile - * for populating the fields on type discovery!!! - * - * Ownership: - * - The `rosidl_message_type_support_t *` returned from this function has different ownership - * rules compared to the statically allocated `rosidl_message_type_support_t` structs from - * code-generated types! - * - The caller is responsible for deallocating the returned pointer - * - *
- * Attribute | Adherence - * ------------------ | ------------- - * Allocates Memory | Yes - * Thread-Safe | No - * Uses Atomics | No - * Lock-Free | Yes - */ -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_ret_t -rmw_dynamic_message_type_support_handle_create( - rosidl_dynamic_typesupport_serialization_support_t * serialization_support, - bool middleware_supports_type_discovery, - const rosidl_type_hash_t * type_hash, - const rosidl_runtime_c__type_description__TypeDescription * type_description, - const rosidl_runtime_c__type_description__TypeSource__Sequence * type_description_sources, - rosidl_message_type_support_t ** ts); // OUT - -/// Destroy a rosidl_message_type_support_t obtained with -/// `rmw_dynamic_message_type_support_handle_create()`, which has dynamically allocated members -/// -/// NOTE: Using this on a statically allocated typesupport will cause undefined behavior! -/// (Static memory will get freed in that case.) -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_ret_t -rmw_dynamic_message_type_support_handle_destroy(rosidl_message_type_support_t * type_support); - -/// Get the name of the rmw_dynamic_typesupport_c identifier -/** - * \return Name of rmw_dynamic_typesupport_c identifier - */ -RMW_PUBLIC -RMW_WARN_UNUSED -const char * -rmw_get_dynamic_typesupport_identifier(void); - -/// Construct serialization support-specific rosidl_dynamic_typesupport_dynamic_type_t from a given -/// type description -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_ret_t -rmw_create_dynamic_message_type_from_description( - rosidl_dynamic_typesupport_serialization_support_t * serialization_support, - const rosidl_runtime_c__type_description__TypeDescription * type_description, - rosidl_dynamic_typesupport_dynamic_type_t ** ts); // OUT - -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_ret_t -rmw_create_dynamic_message_from_dynamic_message_type( - rosidl_dynamic_typesupport_dynamic_type_t * dynamic_message_type, - rosidl_dynamic_typesupport_dynamic_data_t ** cloned_dynamic_message_type); // OUT - -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_ret_t -rmw_clone_dynamic_message( - const rosidl_dynamic_typesupport_dynamic_data_t * dynamic_message, - rosidl_dynamic_typesupport_dynamic_data_t ** cloned_dynamic_message); // OUT - -// NOTE(methylDragon): The responsibility is on the user to ensure that the dynamic message's -// dynamic type matches the layout of the buffer -/// The user must provide a rosidl_dynamic_typesupport_dynamic_data_t with dynamic data impl -/// that matches the serialization library used to serialize the buffer. It must also match the -/// layout of the buffer if the serialization library cannot infer the layout from the buffer alone. -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_ret_t -rmw_serialized_to_dynamic_message( - rmw_serialized_message_t * serialized_message, - rosidl_dynamic_typesupport_dynamic_data_t * dynamic_message); - -RMW_PUBLIC -RMW_WARN_UNUSED -rmw_ret_t -rmw_dynamic_message_to_serialized( - rosidl_dynamic_typesupport_dynamic_data_t * dynamic_message, - rmw_serialized_message_t * serialized_message); - -// INTERFACES FOR RMW IMPLEMENTATIONS TO FULFILL =================================================== RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t diff --git a/rmw/src/dynamic_message_type_support.c b/rmw/src/dynamic_message_type_support.c deleted file mode 100644 index 6bb24949..00000000 --- a/rmw/src/dynamic_message_type_support.c +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2022 Open Source Robotics Foundation, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rmw/convert_rcutils_ret_to_rmw_ret.h" -#include "rmw/dynamic_message_type_support.h" -#include "rmw/error_handling.h" -#include "rmw/visibility_control.h" - -// NOTE(methylDragon): How do we test this? It depends on specific serialization support. Do I just -// use the FastRTPS support then? - -/// Create a rosidl_message_type_support_t from a TypeDescription message -rmw_ret_t -rmw_dynamic_message_type_support_handle_create( - rosidl_dynamic_typesupport_serialization_support_t * serialization_support, - bool middleware_supports_type_discovery, - const rosidl_type_hash_t * type_hash, - const rosidl_runtime_c__type_description__TypeDescription * type_description, - const rosidl_runtime_c__type_description__TypeSource__Sequence * type_description_sources, - rosidl_message_type_support_t ** ts) -{ - if (!middleware_supports_type_discovery && type_description == NULL) { - RMW_SET_ERROR_MSG( - "Middleware does not support type discovery. Deferred dynamic type message type support will " - "never be populated. You must provide a type description."); - return RMW_RET_INVALID_ARGUMENT; - } - // TODO(methylDragon): Remove if and when the deferred description path is supported - if (type_description == NULL) { - RMW_SET_ERROR_MSG( - "Deferred type description is not currently supported. You must provide a type description."); - return RMW_RET_INVALID_ARGUMENT; - } - - RMW_CHECK_ARGUMENT_FOR_NULL(serialization_support, RMW_RET_INVALID_ARGUMENT); - RMW_CHECK_ARGUMENT_FOR_NULL(type_hash, RMW_RET_INVALID_ARGUMENT); - RMW_CHECK_ARGUMENT_FOR_NULL(type_description, RMW_RET_INVALID_ARGUMENT); - RMW_CHECK_ARGUMENT_FOR_NULL(ts, RMW_RET_INVALID_ARGUMENT); - - // NOTE(methylDragon): Not supported for now - // RMW_CHECK_ARGUMENT_FOR_NULL(type_description_sources, RMW_RET_INVALID_ARGUMENT); - - return rmw_convert_rcutils_ret_to_rmw_ret( - rosidl_dynamic_message_type_support_handle_create( - serialization_support, type_hash, type_description, type_description_sources, ts)); -} - -rmw_ret_t -rmw_dynamic_message_type_support_handle_destroy(rosidl_message_type_support_t * ts) -{ - RCUTILS_CHECK_ARGUMENT_FOR_NULL(ts, RMW_RET_INVALID_ARGUMENT); - return rmw_convert_rcutils_ret_to_rmw_ret(rosidl_dynamic_message_type_support_handle_destroy(ts)); -} - -const char * -rmw_get_dynamic_typesupport_identifier(void) -{ - return rosidl_dynamic_typesupport_c__identifier; -} - -rmw_ret_t -rmw_create_dynamic_message_type_from_description( - rosidl_dynamic_typesupport_serialization_support_t * serialization_support, - const rosidl_runtime_c__type_description__TypeDescription * type_description, - rosidl_dynamic_typesupport_dynamic_type_t ** ts) -{ - return rmw_convert_rcutils_ret_to_rmw_ret( - rosidl_dynamic_typesupport_dynamic_type_create_from_description( - serialization_support, type_description, ts)); -} - -rmw_ret_t -rmw_create_dynamic_message_from_dynamic_message_type( - rosidl_dynamic_typesupport_dynamic_type_t * dynamic_message_type, - rosidl_dynamic_typesupport_dynamic_data_t ** cloned_dynamic_message_type) -{ - return rmw_convert_rcutils_ret_to_rmw_ret( - rosidl_dynamic_typesupport_dynamic_data_create_from_dynamic_type( - dynamic_message_type, cloned_dynamic_message_type)); -} - -rmw_ret_t -rmw_clone_dynamic_message( - const rosidl_dynamic_typesupport_dynamic_data_t * dynamic_message, - rosidl_dynamic_typesupport_dynamic_data_t ** cloned_dynamic_message) -{ - return rmw_convert_rcutils_ret_to_rmw_ret( - rosidl_dynamic_typesupport_dynamic_data_clone(dynamic_message, cloned_dynamic_message)); -} - -rmw_ret_t -rmw_serialized_to_dynamic_message( - rmw_serialized_message_t * serialized_message, - rosidl_dynamic_typesupport_dynamic_data_t * dynamic_message) -{ - bool success; - rmw_ret_t ret = rmw_convert_rcutils_ret_to_rmw_ret( - rosidl_dynamic_typesupport_dynamic_data_deserialize( - dynamic_message, serialized_message, &success)); - - if (success) { - return RMW_RET_OK; - } else { - RMW_SET_ERROR_MSG( - "could not deserialize serialized message to dynamic data: " - "dynamic data not enough memory"); - return ret; - } -} - -rmw_ret_t -rmw_dynamic_message_to_serialized( - rosidl_dynamic_typesupport_dynamic_data_t * dynamic_message, - rmw_serialized_message_t * serialized_message) -{ - bool success; - rmw_ret_t ret = rmw_convert_rcutils_ret_to_rmw_ret( - rosidl_dynamic_typesupport_dynamic_data_serialize( - dynamic_message, serialized_message, &success)); - - if (success) { - return RMW_RET_OK; - } else { - RMW_SET_ERROR_MSG("could not serialize dynamic data to serialized message!"); - return ret; - } -} - -#ifdef __cplusplus -} -#endif