1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//! API in rcl/graph.h

use std::os::raw::c_char;

use crate::*;
pub use crate::{
    rmw_get_zero_initialized_names_and_types as rcl_get_zero_initialized_names_and_types,
    rmw_get_zero_initialized_topic_endpoint_info_array as rcl_get_zero_initialized_topic_endpoint_info_array,
    rmw_names_and_types_t as rcl_names_and_types_t,
    rmw_topic_endpoint_info_array_fini as rcl_topic_endpoint_info_array_fini,
    rmw_topic_endpoint_info_array_t as rcl_topic_endpoint_info_array_t,
    rmw_topic_endpoint_info_t as rcl_topic_endpoint_info_t,
};

extern "C" {
    /// Return a list of topic names and types for publishers associated with a node.
    pub fn rcl_get_publisher_names_and_types_by_node(
        node: *const rcl_node_t,
        allocator: *mut rcl_allocator_t,
        no_demangle: bool,
        node_name: *const c_char,
        node_namespace: *const c_char,
        topic_names_and_types: *mut rcl_names_and_types_t,
    ) -> rcl_ret_t;

    /// Return a list of topic names and types for subscriptions associated with a node.
    pub fn rcl_get_subscriber_names_and_types_by_node(
        node: *const rcl_node_t,
        allocator: *mut rcl_allocator_t,
        no_demangle: bool,
        node_name: *const c_char,
        node_namespace: *const c_char,
        topic_names_and_types: *mut rcl_names_and_types_t,
    ) -> rcl_ret_t;

    /// Return a list of service names and types associated with a node.
    pub fn rcl_get_service_names_and_types_by_node(
        node: *const rcl_node_t,
        allocator: *mut rcl_allocator_t,
        node_name: *const c_char,
        node_namespace: *const c_char,
        service_names_and_types: *mut rcl_names_and_types_t,
    ) -> rcl_ret_t;

    /// Return a list of service client names and types associated with a node.
    pub fn rcl_get_client_names_and_types_by_node(
        node: *const rcl_node_t,
        allocator: *mut rcl_allocator_t,
        node_name: *const c_char,
        node_namespace: *const c_char,
        service_names_and_types: *mut rcl_names_and_types_t,
    ) -> rcl_ret_t;

    /// Return a list of topic names and their types.
    pub fn rcl_get_topic_names_and_types(
        node: *const rcl_node_t,
        allocator: *mut rcl_allocator_t,
        no_demangle: bool,
        topic_names_and_types: *mut rcl_names_and_types_t,
    ) -> rcl_ret_t;

    /// Return a list of service names and their types.
    pub fn rcl_get_service_names_and_types(
        node: *const rcl_node_t,
        allocator: *mut rcl_allocator_t,
        service_names_and_types: *mut rcl_names_and_types_t,
    ) -> rcl_ret_t;

    /// Initialize a rcl_names_and_types_t object.
    pub fn rcl_names_and_types_init(
        names_and_types: *mut rcl_names_and_types_t,
        size: usize,
        allocator: *mut rcl_allocator_t,
    ) -> rcl_ret_t;

    /// Finalize a rcl_names_and_types_t object.
    pub fn rcl_names_and_types_fini(names_and_types: *mut rcl_names_and_types_t) -> rcl_ret_t;

    /// Return a list of available nodes in the ROS graph.
    pub fn rcl_get_node_names(
        node: *const rcl_node_t,
        allocator: rcl_allocator_t,
        node_names: *mut rcutils_string_array_t,
        node_namespaces: *mut rcutils_string_array_t,
    ) -> rcl_ret_t;

    /// Return a list of available nodes in the ROS graph, including their enclave names.
    pub fn rcl_get_node_names_with_enclaves(
        node: *const rcl_node_t,
        allocator: rcl_allocator_t,
        node_names: *mut rcutils_string_array_t,
        node_namespaces: *mut rcutils_string_array_t,
        enclaves: *mut rcutils_string_array_t,
    ) -> rcl_ret_t;

    /// Return the number of publishers on a given topic.
    pub fn rcl_count_publishers(
        node: *const rcl_node_t,
        topic_name: *const c_char,
        count: *mut usize,
    ) -> rcl_ret_t;

    /// Return the number of subscriptions on a given topic.
    pub fn rcl_count_subscribers(
        node: *const rcl_node_t,
        topic_name: *const c_char,
        count: *mut usize,
    ) -> rcl_ret_t;

    /// Return a list of all publishers to a topic.
    pub fn rcl_get_publishers_info_by_topic(
        node: *const rcl_node_t,
        allocator: *mut rcutils_allocator_t,
        topic_name: *const c_char,
        no_mangle: bool,
        publishers_info: *mut rcl_topic_endpoint_info_array_t,
    ) -> rcl_ret_t;

    /// Return a list of all subscriptions to a topic.
    pub fn rcl_get_subscriptions_info_by_topic(
        node: *const rcl_node_t,
        allocator: *mut rcutils_allocator_t,
        topic_name: *const c_char,
        no_mangle: bool,
        subscriptions_info: *mut rcl_topic_endpoint_info_array_t,
    ) -> rcl_ret_t;

    /// Check if a service server is available for the given service client.
    pub fn rcl_service_server_is_available(
        node: *const rcl_node_t,
        client: *const rcl_client_t,
        is_available: *mut bool,
    ) -> rcl_ret_t;
}