rclcpp  beta1
C++ ROS Client Library API
node_graph.hpp
Go to the documentation of this file.
1 // Copyright 2016 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 <vector>
24 
25 #include "rcl/guard_condition.h"
26 
27 #include "rclcpp/event.hpp"
28 #include "rclcpp/macros.hpp"
32 
33 namespace rclcpp
34 {
35 
36 namespace graph_listener
37 {
38 class GraphListener;
39 } // namespace graph_listener
40 
41 namespace node_interfaces
42 {
43 
46 {
47 public:
49 
52 
54  virtual
55  ~NodeGraph();
56 
58  virtual
60  get_topic_names_and_types() const;
61 
63  virtual
64  size_t
65  count_publishers(const std::string & topic_name) const;
66 
68  virtual
69  size_t
70  count_subscribers(const std::string & topic_name) const;
71 
73  virtual
74  const rcl_guard_condition_t *
75  get_graph_guard_condition() const;
76 
78  virtual
79  void
80  notify_graph_change();
81 
83  virtual
84  void
85  notify_shutdown();
86 
88  virtual
89  rclcpp::event::Event::SharedPtr
90  get_graph_event();
91 
93  virtual
94  void
95  wait_for_graph_change(
96  rclcpp::event::Event::SharedPtr event,
97  std::chrono::nanoseconds timeout);
98 
100  virtual
101  size_t
102  count_graph_users();
103 
104 private:
105  RCLCPP_DISABLE_COPY(NodeGraph)
106 
107 
109 
113  std::atomic_bool should_add_to_graph_listener_;
114 
116  mutable std::mutex graph_mutex_;
118  std::condition_variable graph_cv_;
122 
123  std::atomic_size_t graph_users_count_;
124 };
125 
126 } // namespace node_interfaces
127 } // namespace rclcpp
128 
129 #endif // RCLCPP__NODE_INTERFACES__NODE_GRAPH_HPP_
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
Implementation the NodeGraph part of the Node API.
Definition: node_graph.hpp:45
#define RCLCPP_SMART_PTR_ALIASES_ONLY(...)
Definition: macros.hpp:66
Definition: allocator_common.hpp:24
Pure virtual interface class for the NodeGraph part of the Node API.
Definition: node_graph_interface.hpp:34
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
Pure virtual interface class for the NodeBase part of the Node API.
Definition: node_base_interface.hpp:36