Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: action, message, service typesupport and message bounds #472

Merged
merged 7 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ extern "C"

typedef struct rosidl_action_type_support_t rosidl_action_type_support_t;

/// Contains rosidl action type support data.
/*
* Actions are built based on services(goal, result and cancel) and message (feedback and status).
*/
struct rosidl_action_type_support_t
{
const rosidl_service_type_support_t * goal_service_type_support;
Expand All @@ -36,6 +40,12 @@ struct rosidl_action_type_support_t
const rosidl_message_type_support_t * status_message_type_support;
};

/// Get the action type support given a provided action and package.
/*
* \param PkgName name of the package that contains the action
* \param Name action name
* \return a rosidl_action_type_support_t struct if found, otherwise NULL.
*/
#define ROSIDL_GET_ACTION_TYPE_SUPPORT(PkgName, Name) \
ROSIDL_TYPESUPPORT_INTERFACE__ACTION_SYMBOL_NAME( \
rosidl_typesupport_c, PkgName, action, Name)()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,51 @@ typedef struct rosidl_message_type_support_t rosidl_message_type_support_t;
typedef const rosidl_message_type_support_t * (* rosidl_message_typesupport_handle_function)(
const rosidl_message_type_support_t *, const char *);

/// Contains rosidl message type support data
struct rosidl_message_type_support_t
{
/// String identifier for the type_support.
const char * typesupport_identifier;
/// Pointer to the message type support library
const void * data;
/// Pointer to the message type support handler function
rosidl_message_typesupport_handle_function func;
};

/// Get the message type support handle specific to this identifier.
/**
* The handle's message typesupport identifier function is returned or if the parameters are NULL
* then an assert will happen.
*
* \param handle Handle to message type support
* \param identifier The typesupport identifier to get the handle function for
* \return The associated message typesupport handle function.
*/
ROSIDL_GENERATOR_C_PUBLIC
const rosidl_message_type_support_t * get_message_typesupport_handle(
const rosidl_message_type_support_t * handle, const char * identifier);

// Get the message type support handle function specific to this identifier.
/**
* If the identifier is the same as this handle's typesupport_identifier the handle is simply
* returned or if the parameters are NULL then an assert will happen.
*
* \param handle Handle to message type support
* \param identifier The typesupport identifier to get the handle function for
* \return if the identifier match's the handle's identifier then the handle's function
* is returned.
*/
ROSIDL_GENERATOR_C_PUBLIC
const rosidl_message_type_support_t * get_message_typesupport_handle_function(
const rosidl_message_type_support_t * handle, const char * identifier);

/// Get the message type support given a provided action and package.
/*
* \param PkgName Name of the package that contains the message
* \param MsgSubfolder name of the subfolder (for example: msg)
* \param MsgName message name
* \return a rosidl_message_type_support_t struct if founded, otherwise NULL.
*/
#define ROSIDL_GET_MSG_TYPE_SUPPORT(PkgName, MsgSubfolder, MsgName) \
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME( \
rosidl_typesupport_c, PkgName, MsgSubfolder, MsgName)()
Expand Down
28 changes: 28 additions & 0 deletions rosidl_runtime_c/include/rosidl_runtime_c/sequence_bound.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,47 @@ typedef const rosidl_runtime_c__Sequence__bound * (* rosidl_runtime_c__bound_han

struct rosidl_runtime_c__Sequence__bound
{
/// String identifier for the type_support.
const char * typesupport_identifier;
/// Pointer to type support handle function
const void * data;
rosidl_runtime_c__bound_handle_function func;
};

/// Get the message bounds handle specific to this identifier.
/**
* The handle's sequence bound is simply returned or if the parameters are NULL then an assert
* will happen.
*
* \param handle Handle to service type support
* \param identifier The identifier to get the handle for
* \return The associated sequence bound handle function.
*/
ROSIDL_GENERATOR_C_PUBLIC
const rosidl_runtime_c__Sequence__bound * get_sequence_bound_handle(
const rosidl_runtime_c__Sequence__bound * handle, const char * identifier);

/// Get the message bounds handle function specific to this identifier.
/**
* If the identifier is the same as this handle function's identifier the handle is simply returned
* or if the parameters are NULL then an assert will happen.
*
* \param handle Handle to service type support
* \param identifier The identifier to get the handle function for
* \return if the identifier match's the handle's identifier then the handle's function
* is returned.
*/
ROSIDL_GENERATOR_C_PUBLIC
const rosidl_runtime_c__Sequence__bound * get_sequence_bound_handle_function(
const rosidl_runtime_c__Sequence__bound * handle, const char * identifier);

/// Get the sequence bounds given a provided action and package.
/*
* \param PkgName Name of the package that contains the message
* \param MsgSubfolder name of the subfolder (foe example: msg)
* \param MsgName message name
* \return a rosidl_message_bounds_t struct if founded, otherwise NULL.
*/
#define ROSIDL_GET_SEQUENCE_BOUNDS(PkgName, MsgSubfolder, MsgName) \
ROSIDL_BOUNDS_INTERFACE__MESSAGE_SYMBOL_NAME( \
rosidl_typesupport_c, PkgName, MsgSubfolder, MsgName)()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,51 @@ typedef struct rosidl_service_type_support_t rosidl_service_type_support_t;
typedef const rosidl_service_type_support_t * (* rosidl_service_typesupport_handle_function)(
const rosidl_service_type_support_t *, const char *);

/// Contains rosidl service type support data
struct rosidl_service_type_support_t
{
/// String identifier for the type_support.
const char * typesupport_identifier;
/// Pointer to the service type support library
const void * data;
/// Pointer to the service type support handler function
rosidl_service_typesupport_handle_function func;
};

/// Get the service type support handle specific to this identifier.
/**
* The handle's message typesupport identifier function is returned or if the parameters are NULL
* then an assert will happen.
*
* \param handle Handle to service type support
* \param identifier The typesupport identifier to get the handle function for
* \return The associated service typesupport handle function.
*/
ROSIDL_GENERATOR_C_PUBLIC
const rosidl_service_type_support_t * get_service_typesupport_handle(
const rosidl_service_type_support_t * handle, const char * identifier);

/// Get the service type support handle function specific to this identifier.
/**
* If the identifier is the same as this handle's typesupport_identifier the handle is simply
* returned or if the parameters are NULL then an assert will happen.
*
* \param handle Handle to service type support
* \param identifier The typesupport identifier to get the handle function for
* \return if the identifier match's the handle's identifier then the handle's function
* is returned.
*/
ROSIDL_GENERATOR_C_PUBLIC
const rosidl_service_type_support_t * get_service_typesupport_handle_function(
const rosidl_service_type_support_t * handle, const char * identifier);

/// Get the service type support given a provided action and package.
/*
* \param PkgName Name of the package that contains the service
* \param SrvSubfolder name of the subfolder (for example: srv)
* \param SrvName service name
* \return a rosidl_service_type_support_t struct if founded, otherwise NULL.
*/
#define ROSIDL_GET_SRV_TYPE_SUPPORT(PkgName, SrvSubfolder, SrvName) \
ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME( \
rosidl_typesupport_c, PkgName, SrvSubfolder, SrvName)()
Expand Down
75 changes: 74 additions & 1 deletion rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,117 @@ extern "C"
#endif

/// Initialize a rosidl_runtime_c__String structure.
/* The contents of rosidl_runtime_c__String are initialized to a single null character ('\0').
/*
* The contents of rosidl_runtime_c__String are initialized to a single null character ('\0').
* The string initially has size 0 and capacity 1.
* Size represents the size of the contents of the string, while capacity represents the overall
* storage of the string (counting the null terminator).
* All strings must be null-terminated.
* The rosidl_runtime_c__String structure should be deallocated using the given function
* rosidl_runtime_c__String__fini() when it is no longer needed.
* Calling this function with an already initialized U16 string sequence structure will leak
* memory.
*
* \param[inout] str a pointer to a rosidl_runtime_c__String structure
* \return true if successful, false if the passed string pointer is null
* or the memory allocation failed
*/
ROSIDL_GENERATOR_C_PUBLIC
bool
rosidl_runtime_c__String__init(rosidl_runtime_c__String * str);

/// Deallocate the memory of the rosidl_runtime_c__String structure.
/*
* Calling the function with an already deallocated sequence is a no-op.
*
* \param[inout] str a pointer to a rosidl_runtime_c__String structure to be finalized
*/
ROSIDL_GENERATOR_C_PUBLIC
void
rosidl_runtime_c__String__fini(rosidl_runtime_c__String * str);

/// Assign the c string pointer of n characters to the rosidl_runtime_c__String structure.
/*
* \param[inout] str a pointer to a string structure
* \param[in] value c string pointer to be assigned
* \param[in] n size of the value string
* \return true if successful, false if the passed string pointer is null
* or if the passed value pointer is null or if the size is higher than SIZE_MAX
* or if the memory reallocation failed.
*/
ROSIDL_GENERATOR_C_PUBLIC
bool
rosidl_runtime_c__String__assignn(
rosidl_runtime_c__String * str, const char * value, size_t n);

/// Assign the c string pointer to the rosidl_runtime_c__String structure.
/*
*
* This function is identical to rosidl_runtime_c__String__assignn() except the length of the
* c string does not have to be given and therefore the c string must be null terminated.
*
* \see rosidl_runtime_c__String__assignn()
*
* \param[inout] str a pointer to a rosidl_runtime_c__String structure
* \param[in] value c string pointer to be assigned
* \return true if successful, false if the passed string pointer is null
* or if the passed value pointer is null or if the size is higher than SIZE_MAX
* or if the memory reallocation failed.
*/
ROSIDL_GENERATOR_C_PUBLIC
bool
rosidl_runtime_c__String__assign(
rosidl_runtime_c__String * str, const char * value);

/// Initialize a rosidl_runtime_c__String__Sequence__init structure.
/*
* The rosidl_runtime_c__String__Sequence is initialized with the size passed to the function.
* The rosidl_runtime_c__String__Sequence structure should be deallocated using the given function
* rosidl_runtime_c__String__Sequence__fini() when it is no longer needed.
* Calling this function with an already initialized U16 string sequence structure will leak
* memory.
*
* \param[inout] sequence a pointer to a string sequence
* \param[in] size represents the size of the string sequence
* \return true if successful, false if the passed string pointer is null
* or the memory allocation failed
*/
ROSIDL_GENERATOR_C_PUBLIC
bool
rosidl_runtime_c__String__Sequence__init(
rosidl_runtime_c__String__Sequence * sequence, size_t size);

/// Deallocate the memory of the string sequence structure.
/*
* Calling the function with an already deallocated sequence is a no-op.
*
* \param[inout] sequence a pointer to a string sequence to be finalized
*/
ROSIDL_GENERATOR_C_PUBLIC
void
rosidl_runtime_c__String__Sequence__fini(
rosidl_runtime_c__String__Sequence * sequence);

/// Create a rosidl_runtime_c__String__Sequence structure with a specific size.
/*
* The string sequence initially has size and capacity equal to the size argument passed to the
* function.
* The rosidl_runtime_c__String__Sequence structure should be deallocated using the given function
* rosidl_runtime_c__String__Sequence__destroy() when it is no longer needed.
*
* \param[in] size of the desired string sequence
* \return a string sequence if initialization was successfully, otherwise NULL.
*/
ROSIDL_GENERATOR_C_PUBLIC
rosidl_runtime_c__String__Sequence *
rosidl_runtime_c__String__Sequence__create(size_t size);

/// Destroy a rosidl_runtime_c__String__Sequence structure.
/*
* Calling the function with an already deallocated sequence is a no-op.
*
* \param[inout] sequence a pointer to a string sequence to be finalized
*/
ROSIDL_GENERATOR_C_PUBLIC
void
rosidl_runtime_c__String__Sequence__destroy(
Expand Down
Loading