Skip to content

Commit 1f82550

Browse files
ross-desmondjacobperron
authored andcommitted
Add node graph functions (#158)
* Add node graph interface for information by node cr https://code.amazon.com/reviews/CR-3755115 * Add namespace to graph functions * Runs uncrustify --reformat on all files This commit has been generated by running: ament_uncrustify . * Fix copyright header * Fix cpplint issues
1 parent 4882850 commit 1f82550

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef RMW__GET_NODE_INFO_AND_TYPES_H_
16+
#define RMW__GET_NODE_INFO_AND_TYPES_H_
17+
18+
#ifdef __cplusplus
19+
extern "C"
20+
{
21+
#endif
22+
23+
#include "rmw/macros.h"
24+
#include "rmw/names_and_types.h"
25+
#include "rmw/types.h"
26+
#include "rmw/visibility_control.h"
27+
28+
/// Return a list of subscribed topic names and their types.
29+
/**
30+
* This function returns a list of subscribed topic names and their types.
31+
*
32+
* The node parameter must not be `NULL`, and must point to a valid node.
33+
*
34+
* The topic_names_and_types parameter must be allocated and zero initialized.
35+
* The topic_names_and_types is the output for this function, and contains
36+
* allocated memory.
37+
* Therefore, it should be passed to rmw_names_and_types_fini() when
38+
* it is no longer needed.
39+
* Failing to do so will result in leaked memory.
40+
*
41+
* \param[in] node the handle to the node being used to query the ROS graph
42+
* \param[in] allocator allocator to be used when allocating space for strings
43+
* \param[in] node_name the name of the node to get information for
44+
* \param[in] node_namespace the namespace of the node to get information for
45+
* \param[in] no_demangle if true, list all topics without any demangling
46+
* \param[out] topic_names_and_types list of topic names and their types the node_name is subscribed to
47+
* \return `RMW_RET_OK` if the query was successful, or
48+
* \return `RMW_RET_INVALID_ARGUMENT` if the node is invalid, or
49+
* \return `RMW_RET_INVALID_ARGUMENT` if any arguments are invalid, or
50+
* \return `RMW_RET_BAD_ALLOC` if memory allocation fails, or
51+
* \return `RMW_RET_ERROR` if an unspecified error occurs.
52+
*/
53+
RMW_PUBLIC
54+
RMW_WARN_UNUSED
55+
rmw_ret_t
56+
rmw_get_subscriber_names_and_types_by_node(
57+
const rmw_node_t * node,
58+
rcutils_allocator_t * allocator,
59+
const char * node_name,
60+
const char * node_namespace,
61+
bool demangle,
62+
rmw_names_and_types_t * topics_names_and_types);
63+
64+
/// Return a list of published topic names and their types.
65+
/**
66+
* This function returns a list of published topic names and their types.
67+
*
68+
* The node parameter must not be `NULL`, and must point to a valid node.
69+
*
70+
* The topic_names_and_types parameter must be allocated and zero initialized.
71+
* The topic_names_and_types is the output for this function, and contains
72+
* allocated memory.
73+
* Therefore, it should be passed to rmw_names_and_types_fini() when
74+
* it is no longer needed.
75+
* Failing to do so will result in leaked memory.
76+
*
77+
* \param[in] node the handle to the node being used to query the ROS graph
78+
* \param[in] allocator allocator to be used when allocating space for strings
79+
* \param[in] node_name the name of the node to get information for
80+
* \param[in] node_namespace the namespace of the node to get information for
81+
* \param[in] no_demangle if true, list all topics without any demangling
82+
* \param[out] topic_names_and_types list of topic names and their types the node_name is publishing
83+
* \return `RMW_RET_OK` if the query was successful, or
84+
* \return `RMW_RET_INVALID_ARGUMENT` if the node is invalid, or
85+
* \return `RMW_RET_INVALID_ARGUMENT` if any arguments are invalid, or
86+
* \return `RMW_RET_BAD_ALLOC` if memory allocation fails, or
87+
* \return `RMW_RET_ERROR` if an unspecified error occurs.
88+
*/
89+
RMW_PUBLIC
90+
RMW_WARN_UNUSED
91+
rmw_ret_t
92+
rmw_get_publisher_names_and_types_by_node(
93+
const rmw_node_t * node,
94+
rcutils_allocator_t * allocator,
95+
const char * node_name,
96+
const char * node_namespace,
97+
bool demangle,
98+
rmw_names_and_types_t * topic_names_and_types);
99+
100+
/// Return a list of service topic names and their types.
101+
/**
102+
* This function returns a list of service topic names and their types.
103+
*
104+
* The node parameter must not be `NULL`, and must point to a valid node.
105+
*
106+
* The topic_names_and_types parameter must be allocated and zero initialized.
107+
* The topic_names_and_types is the output for this function, and contains
108+
* allocated memory.
109+
* Therefore, it should be passed to rmw_names_and_types_fini() when
110+
* it is no longer needed.
111+
* Failing to do so will result in leaked memory.
112+
*
113+
* \param[in] node the handle to the node being used to query the ROS graph
114+
* \param[in] allocator allocator to be used when allocating space for strings
115+
* \param[in] node_name the name of the node to get information for
116+
* \param[in] node_namespace the namespace of the node to get information for
117+
* \param[out] topic_names_and_types list of topic names and their types the node_name has created a service for
118+
* \return `RMW_RET_OK` if the query was successful, or
119+
* \return `RMW_RET_INVALID_ARGUMENT` if the node is invalid, or
120+
* \return `RMW_RET_INVALID_ARGUMENT` if any arguments are invalid, or
121+
* \return `RMW_RET_BAD_ALLOC` if memory allocation fails, or
122+
* \return `RMW_RET_ERROR` if an unspecified error occurs.
123+
*/
124+
RMW_PUBLIC
125+
RMW_WARN_UNUSED
126+
rmw_ret_t
127+
rmw_get_service_names_and_types_by_node(
128+
const rmw_node_t * node,
129+
rcutils_allocator_t * allocator,
130+
const char * node_name,
131+
const char * node_namespace,
132+
rmw_names_and_types_t * service_names_and_types);
133+
134+
#ifdef __cplusplus
135+
}
136+
#endif
137+
#endif // RMW__GET_NODE_INFO_AND_TYPES_H_

0 commit comments

Comments
 (0)