Skip to content

Commit

Permalink
Expose getter
Browse files Browse the repository at this point in the history
  • Loading branch information
dhood committed Feb 13, 2018
1 parent 210d9b0 commit 57b49d8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
27 changes: 27 additions & 0 deletions rcl/include/rcl/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,33 @@ RCL_WARN_UNUSED
const struct rcl_guard_condition_t *
rcl_node_get_graph_guard_condition(const rcl_node_t * node);

/// Return the logger name of the node.
/**
* This function returns the node's internal logger name string.
* This function can fail, and therefore return `NULL`, if:
* - node is `NULL`
* - node has not been initialized (the implementation is invalid)
*
* The returned string is only valid as long as the given rcl_node_t is valid.
* The value of the string may change if the value in the rcl_node_t changes,
* and therefore copying the string is recommended if this is a concern.
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] node pointer to the node
* \return logger_name string if successful, otherwise `NULL`
*/
RCL_PUBLIC
RCL_WARN_UNUSED
const char *
rcl_node_get_logger_name(const rcl_node_t * node);

#if __cplusplus
}
#endif
Expand Down
9 changes: 9 additions & 0 deletions rcl/src/rcl/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,15 @@ rcl_node_get_graph_guard_condition(const rcl_node_t * node)
return node->impl->graph_guard_condition;
}

const char *
rcl_node_get_logger_name(const rcl_node_t * node)
{
if (!rcl_node_is_valid(node, NULL)) {
return NULL;
}
return node->impl->logger_name;
}

#if __cplusplus
}
#endif

0 comments on commit 57b49d8

Please sign in to comment.