15 #ifndef RCLCPP__EXPERIMENTAL__BUFFERS__INTRA_PROCESS_BUFFER_HPP_ 16 #define RCLCPP__EXPERIMENTAL__BUFFERS__INTRA_PROCESS_BUFFER_HPP_ 19 #include <type_traits> 29 namespace experimental
41 virtual void clear() = 0;
86 std::shared_ptr<Alloc> allocator =
nullptr)
97 message_allocator_ = std::make_shared<MessageAlloc>();
99 message_allocator_ = std::make_shared<MessageAlloc>(*allocator.get());
107 add_shared_impl<BufferT>(
std::move(msg));
117 return consume_shared_impl<BufferT>();
122 return consume_unique_impl<BufferT>();
127 return buffer_->has_data();
146 template<
typename DestinationT>
156 template<
typename DestinationT>
166 MessageDeleter * deleter = std::get_deleter<MessageDeleter, const MessageT>(shared_msg);
167 auto ptr = MessageAllocTraits::allocate(*message_allocator_.
get(), 1);
168 MessageAllocTraits::construct(*message_allocator_.
get(), ptr, *shared_msg);
179 template<
typename OriginT>
184 consume_shared_impl()
186 return buffer_->dequeue();
190 template<
typename OriginT>
195 consume_shared_impl()
198 return buffer_->dequeue();
202 template<
typename OriginT>
204 (std::is_same<OriginT, MessageSharedPtr>::value),
207 consume_unique_impl()
212 MessageDeleter * deleter = std::get_deleter<MessageDeleter, const MessageT>(buffer_msg);
213 auto ptr = MessageAllocTraits::allocate(*message_allocator_.
get(), 1);
214 MessageAllocTraits::construct(*message_allocator_.
get(), ptr, *buffer_msg);
225 template<
typename OriginT>
230 consume_unique_impl()
232 return buffer_->dequeue();
241 #endif // RCLCPP__EXPERIMENTAL__BUFFERS__INTRA_PROCESS_BUFFER_HPP_ Definition: intra_process_buffer.hpp:73
void add_unique(MessageUniquePtr msg) override
Definition: intra_process_buffer.hpp:110
bool use_take_shared_method() const override
Definition: intra_process_buffer.hpp:135
#define RCLCPP_SMART_PTR_ALIASES_ONLY(...)
Definition: macros.hpp:66
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
MessageUniquePtr consume_unique() override
Definition: intra_process_buffer.hpp:120
void add_shared(MessageSharedPtr msg) override
Definition: intra_process_buffer.hpp:105
void clear() override
Definition: intra_process_buffer.hpp:130
virtual ~TypedIntraProcessBuffer()
Definition: intra_process_buffer.hpp:103
typename std::allocator_traits< Alloc >::template rebind_traits< T > AllocRebind
Definition: allocator_common.hpp:30
bool has_data() const override
Definition: intra_process_buffer.hpp:125
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
Definition: intra_process_buffer.hpp:34
MessageSharedPtr consume_shared() override
Definition: intra_process_buffer.hpp:115
allocator::AllocRebind< MessageT, Alloc > MessageAllocTraits
Definition: intra_process_buffer.hpp:78
virtual bool has_data() const =0
Definition: buffer_implementation_base.hpp:26
typename MessageAllocTraits::allocator_type MessageAlloc
Definition: intra_process_buffer.hpp:79
virtual bool use_take_shared_method() const =0
Definition: intra_process_buffer.hpp:51