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 <memory>
19 #include <vector>
20 
21 #include "rcl/allocator.h"
22 #include "rcl/wait.h"
23 
25 #include "rclcpp/macros.hpp"
28 
29 namespace rclcpp
30 {
31 namespace memory_strategy
32 {
33 
35 
41 {
42 public:
44  using WeakNodeVector = std::vector<rclcpp::node_interfaces::NodeBaseInterface::WeakPtr>;
45 
46  virtual bool collect_entities(const WeakNodeVector & weak_nodes) = 0;
47 
48  virtual size_t number_of_ready_subscriptions() const = 0;
49  virtual size_t number_of_ready_services() const = 0;
50  virtual size_t number_of_ready_clients() const = 0;
51  virtual size_t number_of_ready_timers() const = 0;
52  virtual size_t number_of_guard_conditions() const = 0;
53 
54  virtual bool add_handles_to_waitset(rcl_wait_set_t * wait_set) = 0;
55  virtual void clear_handles() = 0;
56  virtual void remove_null_handles(rcl_wait_set_t * wait_set) = 0;
57 
59  // \return Shared pointer to the fresh executable.
60  virtual rclcpp::executor::AnyExecutable::SharedPtr instantiate_next_executable() = 0;
61 
62  virtual void add_guard_condition(const rcl_guard_condition_t * guard_condition) = 0;
63 
64  virtual void remove_guard_condition(const rcl_guard_condition_t * guard_condition) = 0;
65 
66  virtual void
67  get_next_subscription(rclcpp::executor::AnyExecutable::SharedPtr any_exec,
68  const WeakNodeVector & weak_nodes) = 0;
69 
70  virtual void
71  get_next_service(rclcpp::executor::AnyExecutable::SharedPtr any_exec,
72  const WeakNodeVector & weak_nodes) = 0;
73 
74  virtual void
75  get_next_client(rclcpp::executor::AnyExecutable::SharedPtr any_exec,
76  const WeakNodeVector & weak_nodes) = 0;
77 
78  virtual rcl_allocator_t
79  get_allocator() = 0;
80 
81  static rclcpp::subscription::SubscriptionBase::SharedPtr
82  get_subscription_by_handle(const rcl_subscription_t * subscriber_handle,
83  const WeakNodeVector & weak_nodes);
84 
85  static rclcpp::service::ServiceBase::SharedPtr
86  get_service_by_handle(const rcl_service_t * service_handle, const WeakNodeVector & weak_nodes);
87 
88  static rclcpp::client::ClientBase::SharedPtr
89  get_client_by_handle(const rcl_client_t * client_handle, const WeakNodeVector & weak_nodes);
90 
91  static rclcpp::node_interfaces::NodeBaseInterface::SharedPtr
92  get_node_by_group(rclcpp::callback_group::CallbackGroup::SharedPtr group,
93  const WeakNodeVector & weak_nodes);
94 
95  static rclcpp::callback_group::CallbackGroup::SharedPtr
96  get_group_by_subscription(
97  rclcpp::subscription::SubscriptionBase::SharedPtr subscription,
98  const WeakNodeVector & weak_nodes);
99 
100  static rclcpp::callback_group::CallbackGroup::SharedPtr
101  get_group_by_service(
102  rclcpp::service::ServiceBase::SharedPtr service,
103  const WeakNodeVector & weak_nodes);
104 
105  static rclcpp::callback_group::CallbackGroup::SharedPtr
106  get_group_by_client(rclcpp::client::ClientBase::SharedPtr client,
107  const WeakNodeVector & weak_nodes);
108 };
109 
110 } // namespace memory_strategy
111 } // namespace rclcpp
112 
113 #endif // RCLCPP__MEMORY_STRATEGY_HPP_
std::vector< rclcpp::node_interfaces::NodeBaseInterface::WeakPtr > WeakNodeVector
Definition: memory_strategy.hpp:44
Delegate for handling memory allocations while the Executor is executing.
Definition: memory_strategy.hpp:40
Definition: allocator_common.hpp:24
Definition: parameter.hpp:235
Definition: subscription.hpp:53
#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...)
Definition: macros.hpp:51
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50