Function rosidl_runtime_c_type_description_utils_get_field_map

Function Documentation

rcutils_ret_t rosidl_runtime_c_type_description_utils_get_field_map(const rosidl_runtime_c__type_description__IndividualTypeDescription *individual_description, const rcutils_allocator_t *allocator, rcutils_hash_map_t **hash_map)

Construct a hash map of an IndividualTypeDescription’s Field objects, keyed by field name.

NOTE: The hash_map output arg must be passed in pointing to NULL.

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 the individual_description arg’s Field objects. It is not authorized to deallocate them and it cannot outlive the owner it borrows from.

    • Finalizing the rcutils_hash_map_t should not result in the map’s values getting finalized.

Attribute

Adherence

Allocates Memory

Yes

Thread-Safe

No

Uses Atomics

No

Lock-Free

Yes

Parameters:
  • individual_description[in] the individual type description to get the fields from

  • allocator[in] the allocator to use through out the lifetime of the hash_map

  • hash_map[out] rcutils_hash_map_t to be initialized, containing Field objects keyed by their field names. Must point to NULL, outputs pointing to NULL if error.

Returns:

#RCUTILS_RET_OK if successful, or

Returns:

#RCUTILS_RET_BAD_ALLOC if memory allocation fails, or

Returns:

#RCUTILS_RET_INVALID_ARGUMENT for invalid arguments, or

Returns:

#RCUTILS_RET_ERROR if an unknown error occurs.