Skip to content

Commit

Permalink
use postfixes from rosidl_parser.definition and add some docs
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Chen <[email protected]>
  • Loading branch information
ihasdapie committed Aug 10, 2022
1 parent 12850ae commit d5ea939
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand All @@ -41,18 +40,34 @@ 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,
void * request_message,
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 *
Expand All @@ -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;
Expand Down

0 comments on commit d5ea939

Please sign in to comment.