rclcpp  master
C++ ROS Client Library API
memory_strategy.hpp
Go to the documentation of this file.
1 // Copyright 2015 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__MEMORY_STRATEGY_HPP_
16 #define RCLCPP__MEMORY_STRATEGY_HPP_
17 
18 #include <list>
19 #include <memory>
20 
21 #include "rcl/allocator.h"
22 #include "rcl/wait.h"
23 
25 #include "rclcpp/macros.hpp"
28 #include "rclcpp/waitable.hpp"
29 
30 namespace rclcpp
31 {
32 namespace memory_strategy
33 {
34 
36 
42 {
43 public:
45  using WeakNodeList = std::list<rclcpp::node_interfaces::NodeBaseInterface::WeakPtr>;
46 
47  virtual ~MemoryStrategy() = default;
48 
49  virtual bool collect_entities(const WeakNodeList & weak_nodes) = 0;
50 
51  virtual size_t number_of_ready_subscriptions() const = 0;
52  virtual size_t number_of_ready_services() const = 0;
53  virtual size_t number_of_ready_clients() const = 0;
54  virtual size_t number_of_ready_events() const = 0;
55  virtual size_t number_of_ready_timers() const = 0;
56  virtual size_t number_of_guard_conditions() const = 0;
57  virtual size_t number_of_waitables() const = 0;
58 
59  virtual void add_waitable_handle(const rclcpp::Waitable::SharedPtr & waitable) = 0;
60  virtual bool add_handles_to_wait_set(rcl_wait_set_t * wait_set) = 0;
61  virtual void clear_handles() = 0;
62  virtual void remove_null_handles(rcl_wait_set_t * wait_set) = 0;
63 
64  virtual void add_guard_condition(const rcl_guard_condition_t * guard_condition) = 0;
65 
66  virtual void remove_guard_condition(const rcl_guard_condition_t * guard_condition) = 0;
67 
68  virtual void
69  get_next_subscription(
70  rclcpp::AnyExecutable & any_exec,
71  const WeakNodeList & weak_nodes) = 0;
72 
73  virtual void
74  get_next_service(
75  rclcpp::AnyExecutable & any_exec,
76  const WeakNodeList & weak_nodes) = 0;
77 
78  virtual void
79  get_next_client(
80  rclcpp::AnyExecutable & any_exec,
81  const WeakNodeList & weak_nodes) = 0;
82 
83  virtual void
84  get_next_timer(
85  rclcpp::AnyExecutable & any_exec,
86  const WeakNodeList & weak_nodes) = 0;
87 
88  virtual void
89  get_next_waitable(
90  rclcpp::AnyExecutable & any_exec,
91  const WeakNodeList & weak_nodes) = 0;
92 
93  virtual rcl_allocator_t
94  get_allocator() = 0;
95 
96  static rclcpp::SubscriptionBase::SharedPtr
97  get_subscription_by_handle(
98  std::shared_ptr<const rcl_subscription_t> subscriber_handle,
99  const WeakNodeList & weak_nodes);
100 
101  static rclcpp::ServiceBase::SharedPtr
102  get_service_by_handle(
103  std::shared_ptr<const rcl_service_t> service_handle,
104  const WeakNodeList & weak_nodes);
105 
106  static rclcpp::ClientBase::SharedPtr
107  get_client_by_handle(
108  std::shared_ptr<const rcl_client_t> client_handle,
109  const WeakNodeList & weak_nodes);
110 
111  static rclcpp::TimerBase::SharedPtr
112  get_timer_by_handle(
113  std::shared_ptr<const rcl_timer_t> timer_handle,
114  const WeakNodeList & weak_nodes);
115 
116  static rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
117  get_node_by_group(
118  rclcpp::CallbackGroup::SharedPtr group,
119  const WeakNodeList & weak_nodes);
120 
121  static rclcpp::CallbackGroup::SharedPtr
122  get_group_by_subscription(
123  rclcpp::SubscriptionBase::SharedPtr subscription,
124  const WeakNodeList & weak_nodes);
125 
126  static rclcpp::CallbackGroup::SharedPtr
127  get_group_by_service(
128  rclcpp::ServiceBase::SharedPtr service,
129  const WeakNodeList & weak_nodes);
130 
131  static rclcpp::CallbackGroup::SharedPtr
132  get_group_by_client(
133  rclcpp::ClientBase::SharedPtr client,
134  const WeakNodeList & weak_nodes);
135 
136  static rclcpp::CallbackGroup::SharedPtr
137  get_group_by_timer(
138  rclcpp::TimerBase::SharedPtr timer,
139  const WeakNodeList & weak_nodes);
140 
141  static rclcpp::CallbackGroup::SharedPtr
142  get_group_by_waitable(
143  rclcpp::Waitable::SharedPtr waitable,
144  const WeakNodeList & weak_nodes);
145 };
146 
147 } // namespace memory_strategy
148 } // namespace rclcpp
149 
150 #endif // RCLCPP__MEMORY_STRATEGY_HPP_
rclcpp::memory_strategy::MemoryStrategy
Delegate for handling memory allocations while the Executor is executing.
Definition: memory_strategy.hpp:41
rcl_timer_t
std::list< rclcpp::node_interfaces::NodeBaseInterface::WeakPtr >
rcl_client_t
any_executable.hpp
rclcpp::SubscriptionBase
Definition: subscription_base.hpp:59
rcl_guard_condition_t
rclcpp::Waitable
Definition: waitable.hpp:28
rclcpp::TimerBase
Definition: timer.hpp:46
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
RCLCPP_PUBLIC
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
macros.hpp
rclcpp::ClientBase
Definition: client.hpp:53
node_base_interface.hpp
rcl_wait_set_t
rclcpp::AnyExecutable
Definition: any_executable.hpp:33
rcl_subscription_t
visibility_control.hpp
std
RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE
#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...)
Definition: macros.hpp:51
rclcpp::CallbackGroup
Definition: callback_group.hpp:49
rcl_service_t
rclcpp::ServiceBase
Definition: service.hpp:42
waitable.hpp