rclcpp  master
C++ ROS Client Library API
static_executor_entities_collector.hpp
Go to the documentation of this file.
1 // Copyright 2020 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__EXECUTORS__STATIC_EXECUTOR_ENTITIES_COLLECTOR_HPP_
16 #define RCLCPP__EXECUTORS__STATIC_EXECUTOR_ENTITIES_COLLECTOR_HPP_
17 
18 #include <chrono>
19 #include <list>
20 #include <memory>
21 
22 #include "rcl/guard_condition.h"
23 #include "rcl/wait.h"
24 
26 #include "rclcpp/macros.hpp"
29 #include "rclcpp/waitable.hpp"
30 
31 namespace rclcpp
32 {
33 namespace executors
34 {
35 
37  : public rclcpp::Waitable,
38  public std::enable_shared_from_this<StaticExecutorEntitiesCollector>
39 {
40 public:
42 
43  // Constructor
46 
47  // Destructor
50 
52 
59  void
60  init(
61  rcl_wait_set_t * p_wait_set,
62  rclcpp::memory_strategy::MemoryStrategy::SharedPtr & memory_strategy,
63  rcl_guard_condition_t * executor_guard_condition);
64 
66  void
67  execute() override;
68 
70  void
72 
74  void
76 
78 
82  void
84 
86 
92  void
94 
99  bool
100  add_to_wait_set(rcl_wait_set_t * wait_set) override;
101 
103  size_t
105 
111  void
112  add_node(
113  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr);
114 
120  bool
121  remove_node(
122  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr);
123 
125 
131  bool
132  is_ready(rcl_wait_set_t * wait_set) override;
133 
135 
139  size_t
140  get_number_of_timers() {return exec_list_.number_of_timers;}
141 
143 
147  size_t
149 
151 
155  size_t
157 
159 
163  size_t
165 
167 
171  size_t
173 
180  rclcpp::SubscriptionBase::SharedPtr
181  get_subscription(size_t i) {return exec_list_.subscription[i];}
182 
189  rclcpp::TimerBase::SharedPtr
190  get_timer(size_t i) {return exec_list_.timer[i];}
191 
198  rclcpp::ServiceBase::SharedPtr
199  get_service(size_t i) {return exec_list_.service[i];}
200 
207  rclcpp::ClientBase::SharedPtr
208  get_client(size_t i) {return exec_list_.client[i];}
209 
216  rclcpp::Waitable::SharedPtr
217  get_waitable(size_t i) {return exec_list_.waitable[i];}
218 
219 private:
222 
224  rclcpp::memory_strategy::MemoryStrategy::SharedPtr memory_strategy_;
225 
228 
230  rcl_wait_set_t * p_wait_set_ = nullptr;
231 
234 };
235 
236 } // namespace executors
237 } // namespace rclcpp
238 
239 #endif // RCLCPP__EXECUTORS__STATIC_EXECUTOR_ENTITIES_COLLECTOR_HPP_
rclcpp::executors::StaticExecutorEntitiesCollector::add_to_wait_set
bool add_to_wait_set(rcl_wait_set_t *wait_set) override
rclcpp::executors::StaticExecutorEntitiesCollector::get_number_of_clients
size_t get_number_of_clients()
Return number of clients.
Definition: static_executor_entities_collector.hpp:164
rclcpp::executors::StaticExecutorEntitiesCollector::~StaticExecutorEntitiesCollector
~StaticExecutorEntitiesCollector()
rclcpp::experimental::ExecutableList::waitable
std::vector< rclcpp::Waitable::SharedPtr > waitable
Definition: executable_list.hpp:84
rclcpp::executors::StaticExecutorEntitiesCollector::add_node
void add_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
rclcpp::executors::StaticExecutorEntitiesCollector::is_ready
bool is_ready(rcl_wait_set_t *wait_set) override
Complete all available queued work without blocking.
std::list< const rcl_guard_condition_t * >
std::chrono::nanoseconds
rclcpp::executors::StaticExecutorEntitiesCollector::execute
void execute() override
Execute any entities of the Waitable that are ready.
rclcpp::executors::StaticExecutorEntitiesCollector::get_waitable
rclcpp::Waitable::SharedPtr get_waitable(size_t i)
Definition: static_executor_entities_collector.hpp:217
rcl_guard_condition_t
executable_list.hpp
rclcpp::experimental::ExecutableList::number_of_clients
size_t number_of_clients
Definition: executable_list.hpp:82
rclcpp::executors::StaticExecutorEntitiesCollector::get_timer
rclcpp::TimerBase::SharedPtr get_timer(size_t i)
Definition: static_executor_entities_collector.hpp:190
rclcpp::Waitable
Definition: waitable.hpp:28
rclcpp::executors::StaticExecutorEntitiesCollector::refresh_wait_set
void refresh_wait_set(std::chrono::nanoseconds timeout=std::chrono::nanoseconds(-1))
Function to add_handles_to_wait_set and wait for work and.
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
rclcpp::experimental::ExecutableList::service
std::vector< rclcpp::ServiceBase::SharedPtr > service
Definition: executable_list.hpp:76
RCLCPP_PUBLIC
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
rclcpp::executors::StaticExecutorEntitiesCollector::get_service
rclcpp::ServiceBase::SharedPtr get_service(size_t i)
Definition: static_executor_entities_collector.hpp:199
rclcpp::experimental::ExecutableList
This class contains subscriptionbase, timerbase, etc. which can be used to run callbacks.
Definition: executable_list.hpp:34
RCLCPP_SMART_PTR_DEFINITIONS
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
macros.hpp
rclcpp::executors::StaticExecutorEntitiesCollector::prepare_wait_set
void prepare_wait_set()
Function to reallocate space for entities in the wait set.
rclcpp::executors::StaticExecutorEntitiesCollector::fill_memory_strategy
void fill_memory_strategy()
rclcpp::executors::StaticExecutorEntitiesCollector::get_client
rclcpp::ClientBase::SharedPtr get_client(size_t i)
Definition: static_executor_entities_collector.hpp:208
rclcpp::executors::StaticExecutorEntitiesCollector::get_number_of_services
size_t get_number_of_services()
Return number of services.
Definition: static_executor_entities_collector.hpp:156
rclcpp::experimental::ExecutableList::client
std::vector< rclcpp::ClientBase::SharedPtr > client
Definition: executable_list.hpp:80
rclcpp::experimental::ExecutableList::subscription
std::vector< rclcpp::SubscriptionBase::SharedPtr > subscription
Definition: executable_list.hpp:68
std::enable_shared_from_this
rcl_wait_set_t
rclcpp::experimental::ExecutableList::number_of_waitables
size_t number_of_waitables
Definition: executable_list.hpp:86
rclcpp::executors::StaticExecutorEntitiesCollector::get_subscription
rclcpp::SubscriptionBase::SharedPtr get_subscription(size_t i)
Definition: static_executor_entities_collector.hpp:181
rclcpp::executors::StaticExecutorEntitiesCollector::get_number_of_subscriptions
size_t get_number_of_subscriptions()
Return number of subscriptions.
Definition: static_executor_entities_collector.hpp:148
rclcpp::executors::StaticExecutorEntitiesCollector::init
void init(rcl_wait_set_t *p_wait_set, rclcpp::memory_strategy::MemoryStrategy::SharedPtr &memory_strategy, rcl_guard_condition_t *executor_guard_condition)
Initialize StaticExecutorEntitiesCollector.
rclcpp::executors::StaticExecutorEntitiesCollector::get_number_of_ready_guard_conditions
size_t get_number_of_ready_guard_conditions() override
Get the number of ready guard_conditions.
rclcpp::executors::StaticExecutorEntitiesCollector::get_number_of_waitables
size_t get_number_of_waitables()
Return number of waitables.
Definition: static_executor_entities_collector.hpp:172
rclcpp::executors::StaticExecutorEntitiesCollector::fill_executable_list
void fill_executable_list()
rclcpp::executors::StaticExecutorEntitiesCollector
Definition: static_executor_entities_collector.hpp:36
rclcpp::executors::StaticExecutorEntitiesCollector::get_number_of_timers
size_t get_number_of_timers()
Return number of timers.
Definition: static_executor_entities_collector.hpp:140
visibility_control.hpp
rclcpp::experimental::ExecutableList::number_of_timers
size_t number_of_timers
Definition: executable_list.hpp:74
rclcpp::experimental::ExecutableList::number_of_services
size_t number_of_services
Definition: executable_list.hpp:78
rclcpp::executors::StaticExecutorEntitiesCollector::remove_node
bool remove_node(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr)
waitable.hpp
rclcpp::experimental::ExecutableList::timer
std::vector< rclcpp::TimerBase::SharedPtr > timer
Definition: executable_list.hpp:72
memory_strategy.hpp
rclcpp::experimental::ExecutableList::number_of_subscriptions
size_t number_of_subscriptions
Definition: executable_list.hpp:70
rclcpp::executors::StaticExecutorEntitiesCollector::StaticExecutorEntitiesCollector
StaticExecutorEntitiesCollector()=default