rclcpp  master
C++ ROS Client Library API
node_graph_interface.hpp
Go to the documentation of this file.
1 // Copyright 2016-2017 Open Source Robotics Foundation, Inc.
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 RCLCPP__NODE_INTERFACES__NODE_GRAPH_INTERFACE_HPP_
16 #define RCLCPP__NODE_INTERFACES__NODE_GRAPH_INTERFACE_HPP_
17 
18 #include <chrono>
19 #include <map>
20 #include <string>
21 #include <vector>
22 
23 #include "rcl/guard_condition.h"
24 
25 #include "rclcpp/event.hpp"
26 #include "rclcpp/macros.hpp"
28 
29 namespace rclcpp
30 {
31 namespace node_interfaces
32 {
33 
36 {
37 public:
39 
40 
41 
48  virtual
49  std::map<std::string, std::vector<std::string>>
50  get_topic_names_and_types(bool no_demangle = false) const = 0;
51 
53 
59  virtual
60  std::map<std::string, std::vector<std::string>>
61  get_service_names_and_types() const = 0;
62 
65  virtual
66  std::vector<std::string>
67  get_node_names() const = 0;
68 
71  virtual
72  size_t
73  count_publishers(const std::string & topic_name) const = 0;
74 
77  virtual
78  size_t
79  count_subscribers(const std::string & topic_name) const = 0;
80 
83  virtual
84  const rcl_guard_condition_t *
85  get_graph_guard_condition() const = 0;
86 
88 
98  virtual
99  void
100  notify_graph_change() = 0;
101 
104  virtual
105  void
106  notify_shutdown() = 0;
107 
109 
115  virtual
116  rclcpp::event::Event::SharedPtr
117  get_graph_event() = 0;
118 
120 
128  virtual
129  void
131  rclcpp::event::Event::SharedPtr event,
132  std::chrono::nanoseconds timeout) = 0;
133 
135 
139  virtual
140  size_t
141  count_graph_users() = 0;
142 };
143 
144 } // namespace node_interfaces
145 } // namespace rclcpp
146 
147 #endif // RCLCPP__NODE_INTERFACES__NODE_GRAPH_INTERFACE_HPP_
virtual void notify_graph_change()=0
Notify threads waiting on graph changes.
virtual rclcpp::event::Event::SharedPtr get_graph_event()=0
Return a graph event, which will be set anytime a graph change occurs.
virtual const rcl_guard_condition_t * get_graph_guard_condition() const =0
Return the rcl guard condition which is triggered when the ROS graph changes.
virtual void notify_shutdown()=0
Notify any and all blocking node actions that shutdown has occurred.
#define RCLCPP_SMART_PTR_ALIASES_ONLY(...)
Definition: macros.hpp:66
virtual size_t count_publishers(const std::string &topic_name) const =0
Return the number of publishers that are advertised on a given topic.
virtual size_t count_graph_users()=0
Return the number of on loan graph events, see get_graph_event().
Definition: allocator_common.hpp:24
virtual size_t count_subscribers(const std::string &topic_name) const =0
Return the number of subscribers who have created a subscription for a given topic.
virtual std::map< std::string, std::vector< std::string > > get_topic_names_and_types(bool no_demangle=false) const =0
Return a map of existing topic names to list of topic types.
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
Pure virtual interface class for the NodeGraph part of the Node API.
Definition: node_graph_interface.hpp:35
virtual std::vector< std::string > get_node_names() const =0
Return a vector of existing node names (string).
virtual std::map< std::string, std::vector< std::string > > get_service_names_and_types() const =0
Return a map of existing service names to list of service types.
virtual void wait_for_graph_change(rclcpp::event::Event::SharedPtr event, std::chrono::nanoseconds timeout)=0
Wait for a graph event to occur by waiting on an Event to become set.