rclcpp  master
C++ ROS Client Library API
waitable.hpp
Go to the documentation of this file.
1 // Copyright 2018 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__WAITABLE_HPP_
16 #define RCLCPP__WAITABLE_HPP_
17 
18 #include <atomic>
19 
20 #include "rclcpp/macros.hpp"
22 
23 #include "rcl/wait.h"
24 
25 namespace rclcpp
26 {
27 
28 class Waitable
29 {
30 public:
32 
34  virtual ~Waitable() = default;
35 
37 
43  virtual
44  size_t
46 
48 
54  virtual
55  size_t
57 
59 
65  virtual
66  size_t
68 
70 
76  virtual
77  size_t
79 
81 
87  virtual
88  size_t
90 
92 
98  virtual
99  size_t
101 
103 
109  virtual
110  bool
111  add_to_wait_set(rcl_wait_set_t * wait_set) = 0;
112 
114 
124  virtual
125  bool
126  is_ready(rcl_wait_set_t * wait_set) = 0;
127 
129 
150  virtual
151  void
152  execute() = 0;
153 
155 
165  bool
166  exchange_in_use_by_wait_set_state(bool in_use_state);
167 
168 private:
169  std::atomic<bool> in_use_by_wait_set_{false};
170 }; // class Waitable
171 
172 } // namespace rclcpp
173 
174 #endif // RCLCPP__WAITABLE_HPP_
rclcpp::Waitable::exchange_in_use_by_wait_set_state
bool exchange_in_use_by_wait_set_state(bool in_use_state)
Exchange the "in use by wait set" state for this timer.
rclcpp::Waitable::get_number_of_ready_subscriptions
virtual size_t get_number_of_ready_subscriptions()
Get the number of ready subscriptions.
rclcpp::Waitable::get_number_of_ready_timers
virtual size_t get_number_of_ready_timers()
Get the number of ready timers.
rclcpp::Waitable::execute
virtual void execute()=0
Execute any entities of the Waitable that are ready.
rclcpp::Waitable::is_ready
virtual bool is_ready(rcl_wait_set_t *wait_set)=0
Check if the Waitable is ready.
rclcpp::Waitable
Definition: waitable.hpp:28
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
rclcpp::Waitable::get_number_of_ready_events
virtual size_t get_number_of_ready_events()
Get the number of ready events.
RCLCPP_PUBLIC
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
rclcpp::Waitable::get_number_of_ready_services
virtual size_t get_number_of_ready_services()
Get the number of ready services.
rclcpp::Waitable::get_number_of_ready_clients
virtual size_t get_number_of_ready_clients()
Get the number of ready clients.
macros.hpp
rcl_wait_set_t
std::atomic< bool >
visibility_control.hpp
rclcpp::Waitable::~Waitable
virtual ~Waitable()=default
rclcpp::Waitable::add_to_wait_set
virtual bool add_to_wait_set(rcl_wait_set_t *wait_set)=0
Add the Waitable to a wait set.
RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE
#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...)
Definition: macros.hpp:51
rclcpp::Waitable::get_number_of_ready_guard_conditions
virtual size_t get_number_of_ready_guard_conditions()
Get the number of ready guard_conditions.