rmw  master
C API providing a middleware abstraction layer which is used to implement the rest of ROS.
Classes | Typedefs | Functions
names_and_types.h File Reference
#include <stddef.h>
#include "rcutils/allocator.h"
#include "rcutils/types.h"
#include "rmw/macros.h"
#include "rmw/types.h"
#include "rmw/visibility_control.h"
Include dependency graph for names_and_types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rmw_names_and_types_t
 Associative array of topic or service names and types. More...
 

Typedefs

typedef struct RMW_PUBLIC_TYPE rmw_names_and_types_t rmw_names_and_types_t
 Associative array of topic or service names and types. More...
 

Functions

rmw_names_and_types_t rmw_get_zero_initialized_names_and_types (void)
 Return a zero initialized array of names and types. More...
 
rmw_ret_t rmw_names_and_types_check_zero (rmw_names_and_types_t *names_and_types)
 Check that the given names_and_types array is zero initialized. More...
 
rmw_ret_t rmw_names_and_types_init (rmw_names_and_types_t *names_and_types, size_t size, rcutils_allocator_t *allocator)
 Initialize an array of names and types. More...
 
rmw_ret_t rmw_names_and_types_fini (rmw_names_and_types_t *names_and_types)
 Finalize an array of names and types. More...
 

Typedef Documentation

◆ rmw_names_and_types_t

Associative array of topic or service names and types.

Function Documentation

◆ rmw_get_zero_initialized_names_and_types()

rmw_names_and_types_t rmw_get_zero_initialized_names_and_types ( void  )

Return a zero initialized array of names and types.

◆ rmw_names_and_types_check_zero()

rmw_ret_t rmw_names_and_types_check_zero ( rmw_names_and_types_t names_and_types)

Check that the given names_and_types array is zero initialized.


Attribute Adherence
Allocates Memory No
Thread-Safe Yes
Uses Atomics No
Lock-Free Yes
Thread-safety
Access to the array of names and types is read-only, but it is not synchronized. Concurrent names_and_types reads are safe, but concurrent reads and writes are not.
Parameters
[in]names_and_typesArray to be checked.
Returns
RMW_RET_OK if array is zero initialized, RMW_RET_INVALID_ARGUMENT otherwise.
Remarks
This function sets the RMW error state on failure.

◆ rmw_names_and_types_init()

rmw_ret_t rmw_names_and_types_init ( rmw_names_and_types_t names_and_types,
size_t  size,
rcutils_allocator_t allocator 
)

Initialize an array of names and types.

This function initializes the string array for the names and allocates space for all the string arrays for the types according to the given size, but it does not initialize the string array for each setup of types. However, the string arrays for each set of types is zero initialized.


Attribute Adherence
Allocates Memory Yes
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Thread-safety
Initialization is a reentrant procedure, but:
  • Access to arrays of names and types is not synchronized. It is not safe to read or write names_and_types during initialization.
  • The default allocators are thread-safe objects, but any custom allocator may not be. Check your allocator documentation for further reference.
Parameters
[in,out]names_and_typesArray to be initialized on success, but left unchanged on failure.
[in]sizeSize of the array.
[in]allocatorAllocator to be used to populate names_and_types.
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if names_and_types is NULL, or
RMW_RET_INVALID_ARGUMENT if names_and_types is not a zero initialized array, or
RMW_RET_INVALID_ARGUMENT if allocator is invalid, by rcutils_allocator_is_valid() definition, or
RMW_BAD_ALLOC if memory allocation fails, or
RMW_RET_ERROR when an unspecified error occurs.
Remarks
This function sets the RMW error state on failure.

◆ rmw_names_and_types_fini()

rmw_ret_t rmw_names_and_types_fini ( rmw_names_and_types_t names_and_types)

Finalize an array of names and types.

This function deallocates the string array of names and the array of string arrays of types, and zero initializes the given array. If a logical error, such as RMW_RET_INVALID_ARGUMENT, ensues, this function will return early, leaving the given array unchanged. Otherwise, it will proceed despite errors.


Attribute Adherence
Allocates Memory No
Thread-Safe No
Uses Atomics No
Lock-Free Yes
Thread-safety
Finalization is a reentrant procedure, but access to arrays of names and types is not synchronized. It is not safe to read or write names_and_types during initialization.
Parameters
[in,out]names_and_typesArray to be finalized.
Returns
RMW_RET_OK if successful, or
RMW_RET_INVALID_ARGUMENT if names_and_types is NULL, or
RMW_RET_ERROR when an unspecified error occurs.
Remarks
This function sets the RMW error state on failure.