Function rosidl_runtime_c_type_description_utils_get_necessary_referenced_type_descriptions_map
Defined in File type_description_utils.h
Function Documentation
-
rcutils_ret_t rosidl_runtime_c_type_description_utils_get_necessary_referenced_type_descriptions_map(const rosidl_runtime_c__type_description__IndividualTypeDescription *main_type_description, const rcutils_hash_map_t *referenced_types_map, const rcutils_allocator_t *allocator, rcutils_hash_map_t **seen_map)
Return a map of only the referenced type descriptions that are recursively necessary.
The
seen_map
output arg must be passed in pointing toNULL
. It’s a parameter so it can be passed into subsequent recursive calls to traverse nested types.A referenced type description is recursively necessary if it is either:
Needed by a field of the main IndividualTypeDescription
Needed by a field of any prior necessary referenced type descriptions (hence recursive)
For more clarity, an unnecessary referenced type description will not be referenced when parsing a TypeDescription, and hence can be excluded.
Ownership:
The caller assumes ownership of the output
rcutils_hash_map_t
and must free it and its elements, but NOT finalize its values.The output
rcutils_hash_map_t
has values that borrows thereferenced_types_map
arg’sIndividualTypeDescription
values. It is not authorized to deallocate them and it cannot outlive owner it borrows from.Finalizing the output
rcutils_hash_map_t
should not result in its values getting finalized.
Procedure:
Create seen map
[Iterate through fields]:
If field is not nested type or field’s nested type is seen in the seen map:
Continue
If nested type is missing in referenced types or nested type name is empty:
Throw error
Else:
Add to seen map
Recurse on referenced type
Output seen map
Attribute
Adherence
Allocates Memory
Yes
Thread-Safe
No
Uses Atomics
No
Lock-Free
Yes
- Parameters:
main_type_description – [in] the main individual type description to check the fields of
referenced_types_map – [in] a map of referenced
IndividualTypeDescription
objects from the main individual type description’s parentTypeDescription
object, keyed by their type names.allocator – [in] the allocator to use through out the lifetime of the hash_map.
seen_map – [inout]
rcutils_hash_map_t
of seen necessaryIndividualTypeDescription
objects keyed by their type names. Used in recursive calls. Must point toNULL
for user’s top level call, outputs pointing toNULL
if error.
- Returns:
#RCUTILS_RET_OK if successful, or
- Returns:
#RCUTILS_RET_INVALID_ARGUMENT for invalid arguments, or
- Returns:
#RCUTILS_RET_BAD_ALLOC if memory allocation fails, or
- Returns:
#RCUTILS_RET_NOT_FOUND if passed referenced types are missing necessary types, or
- Returns:
#RCUTILS_RET_ERROR if an unknown error occurs.