rclcpp  master
C++ ROS Client Library API
static_storage.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__WAIT_SET_POLICIES__STATIC_STORAGE_HPP_
16 #define RCLCPP__WAIT_SET_POLICIES__STATIC_STORAGE_HPP_
17 
18 #include <array>
19 #include <memory>
20 #include <utility>
21 
22 #include "rclcpp/client.hpp"
24 #include "rclcpp/macros.hpp"
25 #include "rclcpp/service.hpp"
28 #include "rclcpp/timer.hpp"
31 #include "rclcpp/waitable.hpp"
32 
33 namespace rclcpp
34 {
35 namespace wait_set_policies
36 {
37 
39 
43 template<
44  std::size_t NumberOfSubscriptions,
45  std::size_t NumberOfGuardCondtions,
46  std::size_t NumberOfTimers,
47  std::size_t NumberOfClients,
48  std::size_t NumberOfServices,
49  std::size_t NumberOfWaitables
50 >
52 {
53 protected:
55 
57  {
58 public:
61 
64  std::shared_ptr<rclcpp::SubscriptionBase> subscription_in = nullptr,
66  : subscription(std::move(subscription_in)),
67  mask(mask_in)
68  {}
69  };
71  SubscriptionEntry,
72  NumberOfSubscriptions
73  >;
75 
78  NumberOfGuardCondtions
79  >;
81 
82  using ArrayOfTimers = std::array<
84  NumberOfTimers
85  >;
87 
88  using ArrayOfClients = std::array<
90  NumberOfClients
91  >;
93 
96  NumberOfServices
97  >;
99 
101  {
104  std::shared_ptr<rclcpp::Waitable> waitable_in = nullptr,
105  std::shared_ptr<void> associated_entity_in = nullptr) noexcept
106  : waitable(std::move(waitable_in)),
107  associated_entity(std::move(associated_entity_in))
108  {}
109 
112  };
115  NumberOfWaitables
116  >;
118 
119  template<class ArrayOfExtraGuardConditions>
120  explicit
122  const ArrayOfSubscriptions & subscriptions,
123  const ArrayOfGuardConditions & guard_conditions,
124  const ArrayOfExtraGuardConditions & extra_guard_conditions,
125  const ArrayOfTimers & timers,
126  const ArrayOfClients & clients,
127  const ArrayOfServices & services,
128  const ArrayOfWaitables & waitables,
129  rclcpp::Context::SharedPtr context
130  )
132  subscriptions,
133  guard_conditions,
134  extra_guard_conditions,
135  timers,
136  clients,
137  services,
138  waitables,
139  context),
140  subscriptions_(subscriptions),
141  guard_conditions_(guard_conditions),
142  timers_(timers),
143  clients_(clients),
144  services_(services),
145  waitables_(waitables)
146  {}
147 
148  ~StaticStorage() = default;
149 
150  template<class ArrayOfExtraGuardConditions>
151  void
152  storage_rebuild_rcl_wait_set(const ArrayOfExtraGuardConditions & extra_guard_conditions)
153  {
157  extra_guard_conditions,
158  timers_,
159  clients_,
160  services_,
161  waitables_
162  );
163  }
164 
165  // storage_add_subscription() explicitly not declared here
166  // storage_remove_subscription() explicitly not declared here
167  // storage_add_guard_condition() explicitly not declared here
168  // storage_remove_guard_condition() explicitly not declared here
169  // storage_add_timer() explicitly not declared here
170  // storage_remove_timer() explicitly not declared here
171  // storage_add_client() explicitly not declared here
172  // storage_remove_client() explicitly not declared here
173  // storage_add_service() explicitly not declared here
174  // storage_remove_service() explicitly not declared here
175  // storage_add_waitable() explicitly not declared here
176  // storage_remove_waitable() explicitly not declared here
177  // storage_prune_deleted_entities() explicitly not declared here
178 
179  void
181  {
182  // Explicitly do nothing.
183  }
184 
185  void
187  {
188  // Explicitly do nothing.
189  }
190 
197 };
198 
199 } // namespace wait_set_policies
200 } // namespace rclcpp
201 
202 #endif // RCLCPP__WAIT_SET_POLICIES__STATIC_STORAGE_HPP_
rclcpp::wait_set_policies::StaticStorage::WaitableEntry::waitable
std::shared_ptr< rclcpp::Waitable > waitable
Definition: static_storage.hpp:110
std::false_type
client.hpp
std::shared_ptr< rclcpp::SubscriptionBase >
std::move
T move(T... args)
rclcpp::wait_set_policies::detail::StoragePolicyCommon
Common structure for storage policies, which provides rcl wait set access.
Definition: storage_policy_common.hpp:39
rclcpp::SubscriptionWaitSetMask
Options used to determine what parts of a subscription get added to or removed from a wait set.
Definition: subscription_wait_set_mask.hpp:24
rclcpp::wait_set_policies::StaticStorage::ArrayOfServices
std::array< std::shared_ptr< rclcpp::ServiceBase >, NumberOfServices > ArrayOfServices
Definition: static_storage.hpp:97
rclcpp::wait_set_policies::StaticStorage::SubscriptionEntry::mask
rclcpp::SubscriptionWaitSetMask mask
Definition: static_storage.hpp:60
rclcpp::wait_set_policies::StaticStorage::ArrayOfSubscriptions
std::array< SubscriptionEntry, NumberOfSubscriptions > ArrayOfSubscriptions
Definition: static_storage.hpp:73
rclcpp::wait_set_policies::StaticStorage::ArrayOfWaitables
std::array< WaitableEntry, NumberOfWaitables > ArrayOfWaitables
Definition: static_storage.hpp:116
rclcpp::wait_set_policies::StaticStorage
WaitSet policy that explicitly provides fixed sized storage only.
Definition: static_storage.hpp:51
subscription_base.hpp
rclcpp::wait_set_policies::StaticStorage::WaitableEntry::associated_entity
std::shared_ptr< void > associated_entity
Definition: static_storage.hpp:111
guard_condition.hpp
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
timer.hpp
rclcpp::wait_set_policies::StaticStorage::WaitableEntry::WaitableEntry
WaitableEntry(std::shared_ptr< rclcpp::Waitable > waitable_in=nullptr, std::shared_ptr< void > associated_entity_in=nullptr) noexcept
Conversion constructor, which is intentionally not marked explicit.
Definition: static_storage.hpp:103
rclcpp::wait_set_policies::StaticStorage::SubscriptionEntry::SubscriptionEntry
SubscriptionEntry(std::shared_ptr< rclcpp::SubscriptionBase > subscription_in=nullptr, rclcpp::SubscriptionWaitSetMask mask_in={})
Conversion constructor, which is intentionally not marked explicit.
Definition: static_storage.hpp:63
rclcpp::wait_set_policies::StaticStorage::~StaticStorage
~StaticStorage()=default
macros.hpp
rclcpp::wait_set_policies::StaticStorage::SubscriptionEntry::subscription
std::shared_ptr< rclcpp::SubscriptionBase > subscription
Definition: static_storage.hpp:59
rclcpp::wait_set_policies::StaticStorage::services_
const ArrayOfServices services_
Definition: static_storage.hpp:195
rclcpp::wait_set_policies::StaticStorage::storage_release_ownerships
void storage_release_ownerships()
Definition: static_storage.hpp:186
rclcpp::wait_set_policies::StaticStorage::subscriptions_
const ArrayOfSubscriptions subscriptions_
Definition: static_storage.hpp:191
rclcpp::wait_set_policies::StaticStorage::guard_conditions_
const ArrayOfGuardConditions guard_conditions_
Definition: static_storage.hpp:192
rclcpp::wait_set_policies::StaticStorage::WaitableEntry
Definition: static_storage.hpp:100
rclcpp::wait_set_policies::StaticStorage::timers_
const ArrayOfTimers timers_
Definition: static_storage.hpp:193
rclcpp::wait_set_policies::StaticStorage::clients_
const ArrayOfClients clients_
Definition: static_storage.hpp:194
subscription_wait_set_mask.hpp
rclcpp::wait_set_policies::StaticStorage::ArrayOfGuardConditions
std::array< std::shared_ptr< rclcpp::GuardCondition >, NumberOfGuardCondtions > ArrayOfGuardConditions
Definition: static_storage.hpp:79
std::array
rclcpp::wait_set_policies::StaticStorage::storage_rebuild_rcl_wait_set
void storage_rebuild_rcl_wait_set(const ArrayOfExtraGuardConditions &extra_guard_conditions)
Definition: static_storage.hpp:152
rclcpp::wait_set_policies::StaticStorage::SubscriptionEntry
Definition: static_storage.hpp:56
rclcpp::wait_set_policies::StaticStorage::waitables_
const ArrayOfWaitables waitables_
Definition: static_storage.hpp:196
rclcpp::wait_set_policies::StaticStorage::ArrayOfClients
std::array< std::shared_ptr< rclcpp::ClientBase >, NumberOfClients > ArrayOfClients
Definition: static_storage.hpp:91
visibility_control.hpp
std
storage_policy_common.hpp
rclcpp::wait_set_policies::detail::StoragePolicyCommon< true >::StoragePolicyCommon
StoragePolicyCommon(const SubscriptionsIterable &subscriptions, const GuardConditionsIterable &guard_conditions, const ExtraGuardConditionsIterable &extra_guard_conditions, const TimersIterable &timers, const ClientsIterable &clients, const ServicesIterable &services, const WaitablesIterable &waitables, rclcpp::Context::SharedPtr context)
Definition: storage_policy_common.hpp:52
std::size_t
rclcpp::wait_set_policies::StaticStorage::storage_acquire_ownerships
void storage_acquire_ownerships()
Definition: static_storage.hpp:180
rclcpp::wait_set_policies::StaticStorage::StaticStorage
StaticStorage(const ArrayOfSubscriptions &subscriptions, const ArrayOfGuardConditions &guard_conditions, const ArrayOfExtraGuardConditions &extra_guard_conditions, const ArrayOfTimers &timers, const ArrayOfClients &clients, const ArrayOfServices &services, const ArrayOfWaitables &waitables, rclcpp::Context::SharedPtr context)
Definition: static_storage.hpp:121
rclcpp::wait_set_policies::detail::StoragePolicyCommon< true >::storage_rebuild_rcl_wait_set_with_sets
void storage_rebuild_rcl_wait_set_with_sets(const SubscriptionsIterable &subscriptions, const GuardConditionsIterable &guard_conditions, const ExtraGuardConditionsIterable &extra_guard_conditions, const TimersIterable &timers, const ClientsIterable &clients, const ServicesIterable &services, const WaitablesIterable &waitables)
Rebuild the wait set, preparing it for the next wait call.
Definition: storage_policy_common.hpp:168
service.hpp
waitable.hpp
rclcpp::wait_set_policies::StaticStorage::ArrayOfTimers
std::array< std::shared_ptr< rclcpp::TimerBase >, NumberOfTimers > ArrayOfTimers
Definition: static_storage.hpp:85