diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h index 8f5ce9649..07a47c0f2 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h @@ -29,7 +29,6 @@ extern "C" typedef struct rosidl_service_type_support_t rosidl_service_type_support_t; -// TODO(ihasdapie): Some documentation for this fn would be nice typedef const rosidl_service_type_support_t * (* rosidl_service_typesupport_handle_function)( const rosidl_service_type_support_t *, const char *); @@ -41,11 +40,19 @@ typedef struct rosidl_service_introspection_info_s { int64_t sequence_number; } rosidl_service_introspection_info_t; -/// Fills in a service introspection request or response message +/// Creates a ServiceEvent message for the service. /** - * - Returns NULL ptr if fail + * Instantiates a ServiceEvent message with the given info and request/response message. + * The message is allocated using the given allocator and must be deallocated using + * the rosidl_service_introspection_destroy_handle * - */ + * \param[in] POD fields of service_msgs/msg/ServiceEventInfo to be passed from rcl + * \param[in] allocator The allocator to use for allocating the ServiceEvent message + * \param[in] request_message type-erased handle to request message from rcl. Can be NULL. + * \param[in] response_message type-erased handle to request message from rcl. Can be NULL. + * \param[in] enable_message_payload Whether to enable message payloads in the ServiceEvent message + * \return The built ServiceEvent message. Will return NULL if the message could not be built. + **/ typedef void * (* rosidl_service_introspection_message_create_handle)( const rosidl_service_introspection_info_t * info, rcutils_allocator_t * allocator, @@ -53,6 +60,14 @@ typedef void * (* rosidl_service_introspection_message_create_handle)( void * response_message, bool enable_message_payload); +/// Destroys a ServiceEvent message +/** + * Destroys a ServiceEvent message returned by a rosidl_service_introspection_message_create_handle + * by calling the corresponding __fini function then deallocating + * + * \param[in] event_message The message to destroy. + * \param[in] allocator The allocator to use for deallocating the message. + */ typedef bool (* rosidl_service_introspection_message_destroy_handle)( void * event_message, rcutils_allocator_t * allocator); diff --git a/rosidl_typesupport_introspection_c/resource/srv__type_support.c.em b/rosidl_typesupport_introspection_c/resource/srv__type_support.c.em index 105b4515f..778f54cea 100644 --- a/rosidl_typesupport_introspection_c/resource/srv__type_support.c.em +++ b/rosidl_typesupport_introspection_c/resource/srv__type_support.c.em @@ -22,6 +22,9 @@ TEMPLATE( @{ from rosidl_pycommon import convert_camel_case_to_lower_case_underscore +from rosidl_parser.definition import SERVICE_REQUEST_MESSAGE_SUFFIX +from rosidl_parser.definition import SERVICE_RESPONSE_MESSAGE_SUFFIX +from rosidl_parser.definition import SERVICE_EVENT_MESSAGE_SUFFIX include_parts = [package_name] + list(interface_path.parents[0].parts) + [ 'detail', convert_camel_case_to_lower_case_underscore(interface_path.stem)] include_base = '/'.join(include_parts) @@ -65,16 +68,15 @@ static rosidl_service_type_support_t @(function_prefix)__@(service.namespaced_ty get_service_typesupport_handle_function, }; -// TODO(ihasdapie): Use postfixes from rosidl_parser.definition // Forward declaration of request/response type support functions const rosidl_message_type_support_t * -ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name)_Request)(); +ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_REQUEST_MESSAGE_SUFFIX)(); const rosidl_message_type_support_t * -ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name)_Response)(); +ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_RESPONSE_MESSAGE_SUFFIX)(); const rosidl_message_type_support_t * -ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name)_Event)(); +ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_EVENT_MESSAGE_SUFFIX)(); ROSIDL_TYPESUPPORT_INTROSPECTION_C_EXPORT_@(package_name) const rosidl_service_type_support_t * @@ -89,17 +91,17 @@ ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(rosidl_typesupport_introspecti if (!service_members->request_members_) { service_members->request_members_ = (const rosidl_typesupport_introspection_c__MessageMembers *) - ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name)_Request)()->data; + ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_REQUEST_MESSAGE_SUFFIX)()->data; } if (!service_members->response_members_) { service_members->response_members_ = (const rosidl_typesupport_introspection_c__MessageMembers *) - ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name)_Response)()->data; + ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_RESPONSE_MESSAGE_SUFFIX)()->data; } if (!service_members->response_members_) { service_members->response_members_ = (const rosidl_typesupport_introspection_c__MessageMembers *) - ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name)_Event)()->data; + ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_EVENT_MESSAGE_SUFFIX)()->data; } return &@(function_prefix)__@(service.namespaced_type.name)_service_type_support_handle;