ROS 2 rclcpp + rcl - humble  humble
ROS 2 C++ Client Library with ROS Client Library
waitable.cpp
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 #include <stdexcept>
16 
17 #include "rclcpp/waitable.hpp"
18 
19 using rclcpp::Waitable;
20 
21 size_t
22 Waitable::get_number_of_ready_subscriptions()
23 {
24  return 0u;
25 }
26 
27 size_t
29 {
30  return 0u;
31 }
32 
33 size_t
35 {
36  return 0u;
37 }
38 
39 size_t
41 {
42  return 0u;
43 }
44 
45 size_t
47 {
48  return 0u;
49 }
50 
51 size_t
53 {
54  return 0u;
55 }
56 
57 std::shared_ptr<void>
59 {
60  (void)id;
61  throw std::runtime_error(
62  "Custom waitables should override take_data_by_entity_id "
63  "if they want to use it.");
64 }
65 
66 bool
68 {
69  return in_use_by_wait_set_.exchange(in_use_state);
70 }
71 
72 void
73 Waitable::set_on_ready_callback(std::function<void(size_t, int)> callback)
74 {
75  (void)callback;
76 
77  throw std::runtime_error(
78  "Custom waitables should override set_on_ready_callback "
79  "if they want to use it.");
80 }
81 
82 void
84 {
85  throw std::runtime_error(
86  "Custom waitables should override clear_on_ready_callback if they "
87  "want to use it and make sure to call it on the waitable destructor.");
88 }
virtual RCLCPP_PUBLIC size_t get_number_of_ready_guard_conditions()
Get the number of ready guard_conditions.
Definition: waitable.cpp:52
virtual RCLCPP_PUBLIC size_t get_number_of_ready_timers()
Get the number of ready timers.
Definition: waitable.cpp:28
virtual RCLCPP_PUBLIC std::shared_ptr< void > take_data_by_entity_id(size_t id)
Take the data so that it can be consumed with execute.
Definition: waitable.cpp:58
virtual RCLCPP_PUBLIC size_t get_number_of_ready_clients()
Get the number of ready clients.
Definition: waitable.cpp:34
virtual RCLCPP_PUBLIC void clear_on_ready_callback()
Unset any callback registered via set_on_ready_callback.
Definition: waitable.cpp:83
virtual RCLCPP_PUBLIC size_t get_number_of_ready_events()
Get the number of ready events.
Definition: waitable.cpp:40
RCLCPP_PUBLIC bool exchange_in_use_by_wait_set_state(bool in_use_state)
Exchange the "in use by wait set" state for this timer.
Definition: waitable.cpp:67
virtual RCLCPP_PUBLIC size_t get_number_of_ready_services()
Get the number of ready services.
Definition: waitable.cpp:46
virtual RCLCPP_PUBLIC void set_on_ready_callback(std::function< void(size_t, int)> callback)
Set a callback to be called whenever the waitable becomes ready.
Definition: waitable.cpp:73