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 <utility>
22 #include <vector>
23 
24 #include "rcl/guard_condition.h"
25 
26 #include "rclcpp/event.hpp"
27 #include "rclcpp/macros.hpp"
29 
30 namespace rclcpp
31 {
32 namespace node_interfaces
33 {
34 
37 {
38 public:
40 
42  virtual
43  ~NodeGraphInterface() = default;
44 
46 
53  virtual
55  get_topic_names_and_types(bool no_demangle = false) const = 0;
56 
58 
64  virtual
66  get_service_names_and_types() const = 0;
67 
70  virtual
72  get_node_names() const = 0;
73 
76  virtual
79 
82  virtual
83  size_t
84  count_publishers(const std::string & topic_name) const = 0;
85 
88  virtual
89  size_t
90  count_subscribers(const std::string & topic_name) const = 0;
91 
94  virtual
95  const rcl_guard_condition_t *
96  get_graph_guard_condition() const = 0;
97 
99 
109  virtual
110  void
111  notify_graph_change() = 0;
112 
115  virtual
116  void
117  notify_shutdown() = 0;
118 
120 
126  virtual
128  get_graph_event() = 0;
129 
131 
139  virtual
140  void
143  std::chrono::nanoseconds timeout) = 0;
144 
146 
150  virtual
151  size_t
152  count_graph_users() = 0;
153 };
154 
155 } // namespace node_interfaces
156 } // namespace rclcpp
157 
158 #endif // RCLCPP__NODE_INTERFACES__NODE_GRAPH_INTERFACE_HPP_
virtual void notify_graph_change()=0
Notify threads waiting on graph changes.
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().
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
virtual std::vector< std::pair< std::string, std::string > > get_node_names_and_namespaces() const =0
Return a vector of existing node names and namespaces (pair of string).
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 rclcpp::Event::SharedPtr get_graph_event()=0
Return a graph event, which will be set anytime a graph change occurs.
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
Set the data type used in the intra-process buffer as std::shared_ptr<MessageT>
virtual void wait_for_graph_change(rclcpp::Event::SharedPtr event, std::chrono::nanoseconds timeout)=0
Wait for a graph event to occur by waiting on an Event to become set.
Pure virtual interface class for the NodeGraph part of the Node API.
Definition: node_graph_interface.hpp:36
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.