Skip to main content

ReadBuffer Class Template

Read-only buffer for consuming messages in a double-buffered system. More...

Declaration

template <typename T> class helios::core::container::buffer::ReadBuffer<T> { ... }

Friends Index

template <typename T>
classReadWriteDoubleBuffer< T >

Public Member Functions Index

template <typename T>
auto read () const noexcept -> std::span< const T >

Returns a read-only view of all buffered messages. More...

template <typename T>
ReadBuffer &reserve (size_t size)

Pre-allocates memory for the specified number of messages. More...

template <typename T>
ReadBuffer &clear ()

Removes all messages from the buffer. More...

Private Member Functions Index

template <typename T>
auto bufferData () -> std::vector< T > &

Returns a mutable reference to the internal buffer. More...

Private Member Attributes Index

template <typename T>
std::vector< T >bufferData_

Internal storage for buffered messages. More...

Description

Read-only buffer for consuming messages in a double-buffered system.

ReadBuffer is the consumer-side of a double-buffered message system. After a swap operation, this buffer contains messages that were pushed to the corresponding WriteBuffer during the previous frame. Consumers iterate over these messages via the read() method.

The internal storage is only accessible to ReadWriteDoubleBuffer for swap operations.

Template Parameters
T

The message type stored in the buffer.

Definition at line 31 of file ReadBuffer.ixx.

Friends

ReadWriteDoubleBuffer< T >

friend class ReadWriteDoubleBuffer< T >

Definition at line 1 of file ReadBuffer.ixx.

33 friend class ReadWriteDoubleBuffer<T>;

Public Member Functions

clear()

template <typename T>
ReadBuffer & helios::core::container::buffer::ReadBuffer< T >::clear ()
inline

Removes all messages from the buffer.

Returns

Reference to this buffer for method chaining.

Definition at line 79 of file ReadBuffer.ixx.

80 bufferData_.clear();
81 return *this;
82 }

Reference helios::core::container::buffer::ReadBuffer< T >::clear.

Referenced by helios::core::container::buffer::ReadBuffer< T >::clear.

read()

template <typename T>
std::span< const T > helios::core::container::buffer::ReadBuffer< T >::read ()
inline noexcept

Returns a read-only view of all buffered messages.

Returns

A span over all messages in the buffer.

Definition at line 58 of file ReadBuffer.ixx.

58 std::span<const T> read() const noexcept {
59 return bufferData_;
60 }

reserve()

template <typename T>
ReadBuffer & helios::core::container::buffer::ReadBuffer< T >::reserve (size_t size)
inline

Pre-allocates memory for the specified number of messages.

Parameters
size

The number of messages to reserve capacity for.

Returns

Reference to this buffer for method chaining.

Definition at line 69 of file ReadBuffer.ixx.

69 ReadBuffer& reserve(size_t size) {
70 bufferData_.reserve(size);
71 return *this;
72 }

Reference helios::core::container::buffer::ReadBuffer< T >::reserve.

Referenced by helios::core::container::buffer::ReadBuffer< T >::reserve.

Private Member Functions

bufferData()

template <typename T>
std::vector< T > & helios::core::container::buffer::ReadBuffer< T >::bufferData ()
inline nodiscard

Returns a mutable reference to the internal buffer.

Only accessible to ReadWriteDoubleBuffer for swap operations.

Returns

Reference to the internal vector.

Definition at line 47 of file ReadBuffer.ixx.

47 [[nodiscard]] std::vector<T>& bufferData() {
48 return bufferData_;
49 }

Private Member Attributes

bufferData_

template <typename T>
std::vector<T> helios::core::container::buffer::ReadBuffer< T >::bufferData_

Internal storage for buffered messages.

Definition at line 38 of file ReadBuffer.ixx.

38 std::vector<T> bufferData_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.