15 #ifndef RCLCPP__INTRA_PROCESS_MANAGER_HPP_ 16 #define RCLCPP__INTRA_PROCESS_MANAGER_HPP_ 27 #include <unordered_map> 40 namespace intra_process_manager
187 template<
typename MessageT,
typename Alloc>
190 size_t buffer_size = 0)
192 auto id = IntraProcessManager::get_next_unique_id();
193 size_t size = buffer_size > 0 ? buffer_size : publisher->
get_queue_size();
197 impl_->add_publisher(
id, publisher, mrb, size);
242 template<
typename MessageT,
typename Alloc = std::allocator<
void>,
243 typename Deleter = std::default_delete<MessageT>>
246 uint64_t intra_process_publisher_id,
251 uint64_t message_seq = 0;
252 mapped_ring_buffer::MappedRingBufferBase::SharedPtr buffer = impl_->get_publisher_info_for_id(
253 intra_process_publisher_id, message_seq);
260 bool did_replace = typed_buffer->push_and_replace(message_seq, message);
264 impl_->store_intra_process_message(intra_process_publisher_id, message_seq);
305 template<
typename MessageT,
typename Alloc = std::allocator<
void>,
306 typename Deleter = std::default_delete<MessageT>>
309 uint64_t intra_process_publisher_id,
310 uint64_t message_sequence_number,
311 uint64_t requesting_subscriptions_intra_process_id,
318 size_t target_subs_size = 0;
320 mapped_ring_buffer::MappedRingBufferBase::SharedPtr buffer = impl_->take_intra_process_message(
321 intra_process_publisher_id,
322 message_sequence_number,
323 requesting_subscriptions_intra_process_id,
331 if (target_subs_size) {
333 typed_buffer->get_copy_at_key(message_sequence_number, message);
336 typed_buffer->pop_at_key(message_sequence_number, message);
348 get_next_unique_id();
350 IntraProcessManagerImplBase::SharedPtr impl_;
357 #endif // RCLCPP__INTRA_PROCESS_MANAGER_HPP_
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
void remove_subscription(uint64_t intra_process_subscription_id)
Unregister a subscription using the subscription's unique id.
Definition: allocator_common.hpp:24
Ring buffer container of unique_ptr's of T, which can be accessed by a key.
Definition: mapped_ring_buffer.hpp:59
uint64_t add_subscription(subscription::SubscriptionBase::SharedPtr subscription)
Register a subscription with the manager, returns subscriptions unique id.
uint64_t store_intra_process_message(uint64_t intra_process_publisher_id, std::unique_ptr< MessageT, Deleter > &message)
Store a message in the manager, and return the message sequence number.
Definition: intra_process_manager.hpp:245
void take_intra_process_message(uint64_t intra_process_publisher_id, uint64_t message_sequence_number, uint64_t requesting_subscriptions_intra_process_id, std::unique_ptr< MessageT, Deleter > &message)
Take an intra process message.
Definition: intra_process_manager.hpp:308
typename MessageAllocTraits::allocator_type MessageAlloc
Definition: publisher.hpp:162
IntraProcessManager(IntraProcessManagerImplBase::SharedPtr state=create_default_impl())
void remove_publisher(uint64_t intra_process_publisher_id)
Unregister a publisher using the publisher's unique id.
uint64_t add_publisher(typename publisher::Publisher< MessageT, Alloc >::SharedPtr publisher, size_t buffer_size=0)
Register a publisher with the manager, returns the publisher unique id.
Definition: intra_process_manager.hpp:189
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
bool matches_any_publishers(const rmw_gid_t *id) const
Return true if the given rmw_gid_t matches any stored Publishers.
std::shared_ptr< MessageAlloc > get_allocator() const
Definition: publisher.hpp:285
T static_pointer_cast(T... args)
size_t get_queue_size() const
Get the queue size for this publisher.
This class facilitates intra process communication between nodes.
Definition: intra_process_manager.hpp:122
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
virtual ~IntraProcessManager()
IntraProcessManagerImplBase::SharedPtr create_default_impl()
A publisher publishes messages of any type to a topic.
Definition: publisher.hpp:158