Skip to content

Commit 0c304c9

Browse files
committed
Add node graph interface for information by node
1 parent 3b9ea0f commit 0c304c9

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
//
2+
// Created by Ross Desmond on 10/30/18.
3+
//
4+
5+
#ifndef RMW_GET_NODE_INFO_AND_TYPES_H
6+
#define RMW_GET_NODE_INFO_AND_TYPES_H
7+
8+
#ifdef __cplusplus
9+
extern "C"
10+
{
11+
#endif
12+
13+
#include "rmw/macros.h"
14+
#include "rmw/names_and_types.h"
15+
#include "rmw/types.h"
16+
#include "rmw/visibility_control.h"
17+
18+
/// Return a list of subscribed topic names and their types.
19+
/**
20+
* This function returns a list of subscribed topic names and their types.
21+
*
22+
* The node parameter must not be `NULL`, and must point to a valid node.
23+
*
24+
* The topic_names_and_types parameter must be allocated and zero initialized.
25+
* The topic_names_and_types is the output for this function, and contains
26+
* allocated memory.
27+
* Therefore, it should be passed to rmw_names_and_types_fini() when
28+
* it is no longer needed.
29+
* Failing to do so will result in leaked memory.
30+
*
31+
* \param[in] node the handle to the node being used to query the ROS graph
32+
* \param[in] allocator allocator to be used when allocating space for strings
33+
* \param[in] node_name the name of the node to get information for
34+
* \param[out] topic_names_and_types list of topic names and their types the node_name is subscribed to
35+
* \return `RMW_RET_OK` if the query was successful, or
36+
* \return `RMW_RET_INVALID_ARGUMENT` if the node is invalid, or
37+
* \return `RMW_RET_INVALID_ARGUMENT` if any arguments are invalid, or
38+
* \return `RMW_RET_BAD_ALLOC` if memory allocation fails, or
39+
* \return `RMW_RET_ERROR` if an unspecified error occurs.
40+
*/
41+
RMW_PUBLIC
42+
RMW_WARN_UNUSED
43+
rmw_ret_t
44+
rmw_get_subscription_names_and_types_by_node(
45+
const rmw_node_t * node,
46+
rcutils_allocator_t * allocator,
47+
const char * node_name,
48+
rmw_names_and_types_t * topics_names_and_types);
49+
50+
/// Return a list of published topic names and their types.
51+
/**
52+
* This function returns a list of published topic names and their types.
53+
*
54+
* The node parameter must not be `NULL`, and must point to a valid node.
55+
*
56+
* The topic_names_and_types parameter must be allocated and zero initialized.
57+
* The topic_names_and_types is the output for this function, and contains
58+
* allocated memory.
59+
* Therefore, it should be passed to rmw_names_and_types_fini() when
60+
* it is no longer needed.
61+
* Failing to do so will result in leaked memory.
62+
*
63+
* \param[in] node the handle to the node being used to query the ROS graph
64+
* \param[in] allocator allocator to be used when allocating space for strings
65+
* \param[in] node_name the name of the node to get information for
66+
* \param[out] topic_names_and_types list of topic names and their types the node_name is publishing
67+
* \return `RMW_RET_OK` if the query was successful, or
68+
* \return `RMW_RET_INVALID_ARGUMENT` if the node is invalid, or
69+
* \return `RMW_RET_INVALID_ARGUMENT` if any arguments are invalid, or
70+
* \return `RMW_RET_BAD_ALLOC` if memory allocation fails, or
71+
* \return `RMW_RET_ERROR` if an unspecified error occurs.
72+
*/
73+
RMW_PUBLIC
74+
RMW_WARN_UNUSED
75+
rmw_ret_t
76+
rmw_get_publisher_names_and_types_by_node(
77+
const rmw_node_t * node,
78+
rcutils_allocator_t * allocator,
79+
const char * node_name,
80+
rmw_names_and_types_t * topic_names_and_types);
81+
82+
/// Return a list of service topic names and their types.
83+
/**
84+
* This function returns a list of service topic names and their types.
85+
*
86+
* The node parameter must not be `NULL`, and must point to a valid node.
87+
*
88+
* The topic_names_and_types parameter must be allocated and zero initialized.
89+
* The topic_names_and_types is the output for this function, and contains
90+
* allocated memory.
91+
* Therefore, it should be passed to rmw_names_and_types_fini() when
92+
* it is no longer needed.
93+
* Failing to do so will result in leaked memory.
94+
*
95+
* \param[in] node the handle to the node being used to query the ROS graph
96+
* \param[in] allocator allocator to be used when allocating space for strings
97+
* \param[in] node_name the name of the node to get information for
98+
* \param[out] topic_names_and_types list of topic names and their types the node_name has created a service for
99+
* \return `RMW_RET_OK` if the query was successful, or
100+
* \return `RMW_RET_INVALID_ARGUMENT` if the node is invalid, or
101+
* \return `RMW_RET_INVALID_ARGUMENT` if any arguments are invalid, or
102+
* \return `RMW_RET_BAD_ALLOC` if memory allocation fails, or
103+
* \return `RMW_RET_ERROR` if an unspecified error occurs.
104+
*/
105+
RMW_PUBLIC
106+
RMW_WARN_UNUSED
107+
rmw_ret_t
108+
rmw_get_service_names_and_types_by_node(
109+
const rmw_node_t * node,
110+
rcutils_allocator_t * allocator,
111+
const char * node_name,
112+
rmw_names_and_types_t * service_names_and_types);
113+
114+
#ifdef __cplusplus
115+
}
116+
#endif
117+
#endif //RMW_GET_NODE_INFO_AND_TYPES_H

0 commit comments

Comments
 (0)