Template Class MessageMemoryStrategy

Inheritance Relationships

Derived Type

Class Documentation

template<typename MessageT, typename Alloc = std::allocator<void>>
class MessageMemoryStrategy

Default allocation strategy for messages received by subscriptions.

A message memory strategy must be templated on the type of the subscription it belongs to.

Subclassed by rclcpp::strategies::message_pool_memory_strategy::MessagePoolMemoryStrategy< MessageT, Size, >

Public Types

using MessageAllocTraits = allocator::AllocRebind<MessageT, Alloc>
using MessageAlloc = typename MessageAllocTraits::allocator_type
using MessageDeleter = allocator::Deleter<MessageAlloc, MessageT>
using SerializedMessageAllocTraits = allocator::AllocRebind<rclcpp::SerializedMessage, Alloc>
using SerializedMessageAlloc = typename SerializedMessageAllocTraits::allocator_type
using SerializedMessageDeleter = allocator::Deleter<SerializedMessageAlloc, rclcpp::SerializedMessage>
using BufferAllocTraits = allocator::AllocRebind<char, Alloc>
using BufferAlloc = typename BufferAllocTraits::allocator_type
using BufferDeleter = allocator::Deleter<BufferAlloc, char>

Public Functions

inline MessageMemoryStrategy()
inline explicit MessageMemoryStrategy(std::shared_ptr<Alloc> allocator)
virtual ~MessageMemoryStrategy() = default
inline virtual std::shared_ptr<MessageT> borrow_message()

By default, dynamically allocate a new message.

Returns:

Shared pointer to the new message.

inline virtual std::shared_ptr<rclcpp::SerializedMessage> borrow_serialized_message(size_t capacity)
inline virtual std::shared_ptr<rclcpp::SerializedMessage> borrow_serialized_message()
inline virtual void set_default_buffer_capacity(size_t capacity)
inline virtual void return_message(std::shared_ptr<MessageT> &msg)

Release ownership of the message, which will deallocate it if it has no more owners.

Parameters:

msg[in] Shared pointer to the message we are returning.

inline virtual void return_serialized_message(std::shared_ptr<rclcpp::SerializedMessage> &serialized_msg)

Public Members

std::shared_ptr<MessageAlloc> message_allocator_
MessageDeleter message_deleter_
std::shared_ptr<SerializedMessageAlloc> serialized_message_allocator_
SerializedMessageDeleter serialized_message_deleter_
std::shared_ptr<BufferAlloc> buffer_allocator_
BufferDeleter buffer_deleter_
size_t default_buffer_capacity_ = 0
rcutils_allocator_t rcutils_allocator_

Public Static Functions

static inline SharedPtr create_default()

Default factory method.