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 #include <memory>
20 
21 #include "rclcpp/macros.hpp"
23 
24 #include "rcl/wait.h"
25 
26 namespace rclcpp
27 {
28 
29 class Waitable
30 {
31 public:
33 
35  virtual ~Waitable() = default;
36 
38 
44  virtual
45  size_t
47 
49 
55  virtual
56  size_t
58 
60 
66  virtual
67  size_t
69 
71 
77  virtual
78  size_t
80 
82 
88  virtual
89  size_t
91 
93 
99  virtual
100  size_t
102 
104 
110  virtual
111  bool
112  add_to_wait_set(rcl_wait_set_t * wait_set) = 0;
113 
115 
125  virtual
126  bool
127  is_ready(rcl_wait_set_t * wait_set) = 0;
128 
130 
160  virtual
162  take_data() = 0;
163 
165 
188  virtual
189  void
190  execute(std::shared_ptr<void> & data) = 0;
191 
193 
203  bool
204  exchange_in_use_by_wait_set_state(bool in_use_state);
205 
206 private:
207  std::atomic<bool> in_use_by_wait_set_{false};
208 }; // class Waitable
209 
210 } // namespace rclcpp
211 
212 #endif // RCLCPP__WAITABLE_HPP_
std::shared_ptr< void >
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(std::shared_ptr< void > &data)=0
Execute data that is passed in.
wait.h
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:29
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 >
rclcpp::Waitable::take_data
virtual std::shared_ptr< void > take_data()=0
Take the data so that it can be consumed with execute.
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.