Class SerializedMessage
Defined in File serialized_message.hpp
Class Documentation
-
class SerializedMessage
Object oriented version of rcl_serialized_message_t with destructor to avoid memory leaks.
Public Functions
-
explicit SerializedMessage(const rcl_allocator_t &allocator = rcl_get_default_allocator())
Default constructor for a SerializedMessage.
Default constructs a serialized message and initalizes it with initial capacity of 0. The allocator defaults to
rcl_get_default_allocator()
.- Parameters:
allocator – [in] The allocator to be used for the initialization.
-
explicit SerializedMessage(size_t initial_capacity, const rcl_allocator_t &allocator = rcl_get_default_allocator())
Default constructor for a SerializedMessage.
Default constructs a serialized message and initalizes it with the provided capacity. The allocator defaults to
rcl_get_default_allocator()
.- Parameters:
initial_capacity – [in] The amount of memory to be allocated.
allocator – [in] The allocator to be used for the initialization.
-
SerializedMessage(const SerializedMessage &other)
Copy Constructor for a SerializedMessage.
-
explicit SerializedMessage(const rcl_serialized_message_t &other)
Constructor for a SerializedMessage from a rcl_serialized_message_t.
-
SerializedMessage(SerializedMessage &&other)
Move Constructor for a SerializedMessage.
-
explicit SerializedMessage(rcl_serialized_message_t &&other)
Constructor for a SerializedMessage from a moved rcl_serialized_message_t.
-
SerializedMessage &operator=(const SerializedMessage &other)
Copy assignment operator.
-
SerializedMessage &operator=(const rcl_serialized_message_t &other)
Copy assignment operator from a rcl_serialized_message_t.
-
SerializedMessage &operator=(SerializedMessage &&other)
Move assignment operator.
-
SerializedMessage &operator=(rcl_serialized_message_t &&other)
Move assignment operator from a rcl_serialized_message_t.
-
virtual ~SerializedMessage()
Destructor for a SerializedMessage.
-
rcl_serialized_message_t &get_rcl_serialized_message()
Get the underlying rcl_serialized_t handle.
-
const rcl_serialized_message_t &get_rcl_serialized_message() const
-
size_t size() const
Get the size of the serialized data buffer.
Note, this is different from the actual amount of allocated memory. This can be obtained via a call to
capacity
.
-
size_t capacity() const
Get the size of allocated memory for the data buffer.
Note, this is different from the amount of content in the buffer. This can be obtained via a call to
size
.
-
void reserve(size_t capacity)
Allocate memory in the data buffer.
The data buffer of the underlying rcl_serialized_message_t will be resized. This might change the data layout and invalidates all pointers to the data.
-
rcl_serialized_message_t release_rcl_serialized_message()
Release the underlying rcl_serialized_message_t.
The memory (i.e. the data buffer) of the serialized message will no longer be managed by this instance and the memory won’t be deallocated on destruction.
-
explicit SerializedMessage(const rcl_allocator_t &allocator = rcl_get_default_allocator())