add the concept of an rcl instance id

it changes with each successful call to rcl_init
This commit is contained in:
William Woodall 2015-11-24 03:45:17 -08:00
parent d9e493a387
commit bac3b210d7
2 changed files with 23 additions and 0 deletions

View file

@ -161,6 +161,24 @@ rcl_node_get_options(const rcl_node_t * node);
rmw_node_t * rmw_node_t *
rcl_node_get_rmw_node_handle(const rcl_node_t * node); rcl_node_get_rmw_node_handle(const rcl_node_t * node);
/// Return the associated rcl instance id.
/* This id is stored when rcl_node_init is called and can be compared with the
* value returned by rcl_get_instance_id() to check if this node was created in
* the current rcl context (since the latest call to rcl_init().
*
* This function can fail, and therefore return 0, if:
* - node is NULL
* - node has not been initialized (the implementation is invalid)
*
* This function will succeed, however, even if rcl_fini has been called since
* the node was created.
*
* \param[in] node pointer to the rcl node
* \return rcl instance id captured at node creation or 0 if there was an error
*/
uint64_t
rcl_node_get_rcl_instance_id(const rcl_node_t * node);
#if __cplusplus #if __cplusplus
} }
#endif #endif

View file

@ -76,6 +76,11 @@ rcl_init(int argc, char ** argv, rcl_allocator_t allocator);
rcl_ret_t rcl_ret_t
rcl_fini(); rcl_fini();
/// Returns an uint64_t number that is unique for the latest rcl_init call.
/* If called before rcl_init or after rcl_fini then 0 will be returned. */
uint64_t
rcl_get_instance_id();
/// Return true until rcl_fini is called, then false. /// Return true until rcl_fini is called, then false.
/* This function is thread safe. */ /* This function is thread safe. */
bool bool