rclcpp  master
C++ ROS Client Library API
node_graph.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_HPP_
16 #define RCLCPP__NODE_INTERFACES__NODE_GRAPH_HPP_
17 
18 #include <chrono>
19 #include <map>
20 #include <memory>
21 #include <mutex>
22 #include <string>
23 #include <utility>
24 #include <vector>
25 
26 #include "rcl/guard_condition.h"
27 
28 #include "rclcpp/event.hpp"
29 #include "rclcpp/macros.hpp"
33 
34 namespace rclcpp
35 {
36 
37 namespace graph_listener
38 {
39 class GraphListener;
40 } // namespace graph_listener
41 
42 namespace node_interfaces
43 {
44 
47 {
48 public:
50 
53 
55  virtual
56  ~NodeGraph();
57 
59  virtual
61  get_topic_names_and_types(bool no_demangle = false) const;
62 
64  virtual
66  get_service_names_and_types() const;
67 
69  virtual
71  get_node_names() const;
72 
74  virtual
76  get_node_names_and_namespaces() const;
77 
79  virtual
80  size_t
81  count_publishers(const std::string & topic_name) const;
82 
84  virtual
85  size_t
86  count_subscribers(const std::string & topic_name) const;
87 
89  virtual
90  const rcl_guard_condition_t *
91  get_graph_guard_condition() const;
92 
94  virtual
95  void
96  notify_graph_change();
97 
99  virtual
100  void
101  notify_shutdown();
102 
104  virtual
106  get_graph_event();
107 
109  virtual
110  void
111  wait_for_graph_change(
113  std::chrono::nanoseconds timeout);
114 
116  virtual
117  size_t
118  count_graph_users();
119 
120 private:
121  RCLCPP_DISABLE_COPY(NodeGraph)
122 
123 
125 
129  std::atomic_bool should_add_to_graph_listener_;
130 
132  mutable std::mutex graph_mutex_;
134  std::condition_variable graph_cv_;
138 
139  std::atomic_size_t graph_users_count_;
140 };
141 
142 } // namespace node_interfaces
143 } // namespace rclcpp
144 
145 #endif // RCLCPP__NODE_INTERFACES__NODE_GRAPH_HPP_
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
#define RCLCPP_SMART_PTR_ALIASES_ONLY(...)
Definition: macros.hpp:66
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
Implementation the NodeGraph part of the Node API.
Definition: node_graph.hpp:46
Pure virtual interface class for the NodeBase part of the Node API.
Definition: node_base_interface.hpp:36
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
Set the data type used in the intra-process buffer as std::shared_ptr<MessageT>
Pure virtual interface class for the NodeGraph part of the Node API.
Definition: node_graph_interface.hpp:36