From 57b49d89fc056ef6ab86ef84171dbf29b09030e1 Mon Sep 17 00:00:00 2001 From: dhood Date: Mon, 22 Jan 2018 17:31:24 -0800 Subject: [PATCH] Expose getter --- rcl/include/rcl/node.h | 27 +++++++++++++++++++++++++++ rcl/src/rcl/node.c | 9 +++++++++ 2 files changed, 36 insertions(+) diff --git a/rcl/include/rcl/node.h b/rcl/include/rcl/node.h index deddc925c..49ebb2f28 100644 --- a/rcl/include/rcl/node.h +++ b/rcl/include/rcl/node.h @@ -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. + * + *
+ * 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 diff --git a/rcl/src/rcl/node.c b/rcl/src/rcl/node.c index 257ef1ce5..3aff0e362 100644 --- a/rcl/src/rcl/node.c +++ b/rcl/src/rcl/node.c @@ -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