15 #ifndef RCLCPP__EXECUTORS__EXECUTOR_ENTITIES_COLLECTION_HPP_
16 #define RCLCPP__EXECUTORS__EXECUTOR_ENTITIES_COLLECTION_HPP_
20 #include <unordered_map>
23 #include <rclcpp/any_executable.hpp>
24 #include <rclcpp/node_interfaces/node_base.hpp>
25 #include <rclcpp/callback_group.hpp>
26 #include <rclcpp/executors/executor_notify_waitable.hpp>
27 #include <rclcpp/visibility_control.hpp>
28 #include <rclcpp/wait_result.hpp>
29 #include <rclcpp/wait_set.hpp>
37 template<
typename EntityValueType>
67 template<
typename CollectionType>
69 const CollectionType & update_from,
70 CollectionType & update_to,
71 std::function<
void(
const typename CollectionType::EntitySharedPtr &)> on_added,
72 std::function<
void(
const typename CollectionType::EntitySharedPtr &)> on_removed
75 for (
auto it = update_to.begin(); it != update_to.end(); ) {
76 if (update_from.count(it->first) == 0) {
77 auto entity = it->second.entity.lock();
81 it = update_to.erase(it);
86 for (
auto it = update_from.begin(); it != update_from.end(); ++it) {
87 if (update_to.count(it->first) == 0) {
88 auto entity = it->second.entity.lock();
92 update_to.insert(*it);
98 template<
typename EntityKeyType,
typename EntityValueType>
100 :
public std::unordered_map<const EntityKeyType *, CollectionEntry<EntityValueType>>
104 using Key =
const EntityKeyType *;
126 update_entities(other, *
this, on_added, on_removed);
197 build_entities_collection(
198 const std::vector<rclcpp::CallbackGroup::WeakPtr> & callback_groups,
214 std::deque<rclcpp::AnyExecutable> & executables
Interface for introspecting a wait set after waiting on it.
A collection of entities, indexed by their corresponding handles.
typename EntityValueType::WeakPtr EntityWeakPtr
Weak pointer to entity type.
const EntityKeyType * Key
Key type of the map.
typename EntityValueType::SharedPtr EntitySharedPtr
Shared pointer to entity type.
void update(const EntityCollection< EntityKeyType, EntityValueType > &other, std::function< void(const EntitySharedPtr &)> on_added, std::function< void(const EntitySharedPtr &)> on_removed)
Update this collection based on the contents of another collection.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
Structure to represent a single entity's entry in a collection.
EntityWeakPtr entity
The entity.
rclcpp::CallbackGroup::WeakPtr callback_group
If relevant, the entity's corresponding callback_group.
typename EntityValueType::WeakPtr EntityWeakPtr
Weak pointer to entity type.
typename EntityValueType::SharedPtr EntitySharedPtr
Shared pointer to entity type.
Represent the total set of entities for a single executor.
TimerCollection timers
Collection of timers currently in use by the executor.
size_t remove_expired_entities()
Remove entities that have expired weak ownership.
GuardConditionCollection guard_conditions
Collection of guard conditions currently in use by the executor.
void clear()
Clear the entities collection.
ServiceCollection services
Collection of services currently in use by the executor.
SubscriptionCollection subscriptions
Collection of subscriptions currently in use by the executor.
WaitableCollection waitables
Collection of waitables currently in use by the executor.
bool empty() const
Check if the entities collection is empty.
ClientCollection clients
Collection of clients currently in use by the executor.