TypeIndexedReadWriteBuffer Class Template
Type-indexed container for immediate-access message buffers. More...
Declaration
Public Constructors Index
template <typename Indexer> | |
| TypeIndexedReadWriteBuffer ()=default | |
|
Default constructor. More... | |
Public Destructor Index
template <typename Indexer> | |
| ~TypeIndexedReadWriteBuffer ()=default | |
|
Default destructor. More... | |
Public Member Functions Index
template <typename T, typename... Args> | |
| void | push (Args &&... args) |
|
Pushes a message of type T to the buffer. More... | |
template <typename T> | |
| auto | read () const noexcept -> std::span< const T > |
|
Returns a read-only view of all messages of type T. More... | |
template <typename T> | |
| void | reserve (size_t size) |
|
Pre-allocates capacity for messages of type T. More... | |
template <typename T> | |
| auto | getOrCreateBuffer () -> ReadWriteBuffer< T > & |
|
Gets or creates the buffer for message type T. More... | |
template <typename Indexer> | |
| void | clear () |
|
Clears all buffers. More... | |
Private Member Attributes Index
template <typename Indexer> | |
| std::vector< std::unique_ptr< Buffer > > | buffers_ |
|
Type-erased storage for message buffers, indexed by type. More... | |
Private Static Functions Index
template <typename T> | |
| static size_t | index () |
|
Returns the buffer index for message type T. More... | |
Description
Type-indexed container for immediate-access message buffers.
Unlike TypeIndexedDoubleBuffer, this container provides immediate visibility of pushed messages within the same frame. Each message type T gets its own dedicated ReadWriteBuffer, indexed via TypeIndexer for O(1) access.
Use this when message producers and consumers operate in the same phase. For cross-phase communication with frame-boundary swapping, prefer TypeIndexedDoubleBuffer.
- Template Parameters
-
Indexer The TypeIndexer used for mapping message types to buffer indices.
Definition at line 36 of file TypeIndexedReadWriteBuffer.ixx.
Public Constructors
TypeIndexedReadWriteBuffer()
| default |
Default constructor.
Definition at line 65 of file TypeIndexedReadWriteBuffer.ixx.
Public Destructor
~TypeIndexedReadWriteBuffer()
| default |
Default destructor.
Definition at line 60 of file TypeIndexedReadWriteBuffer.ixx.
Public Member Functions
clear()
| inline |
getOrCreateBuffer()
| inline |
Gets or creates the buffer for message type T.
- Template Parameters
-
T The message type.
- Returns
Reference to the ReadWriteBuffer for type T.
Definition at line 124 of file TypeIndexedReadWriteBuffer.ixx.
Referenced by helios::core::buffer::TypeIndexedReadWriteBuffer< Indexer >::push and helios::core::buffer::TypeIndexedReadWriteBuffer< Indexer >::reserve.
push()
| inline |
Pushes a message of type T to the buffer.
- Template Parameters
-
T The message type.
Args Constructor argument types for T.
- Parameters
-
args Arguments forwarded to T's constructor.
Definition at line 76 of file TypeIndexedReadWriteBuffer.ixx.
Reference helios::core::buffer::TypeIndexedReadWriteBuffer< Indexer >::getOrCreateBuffer.
read()
| inline noexcept |
Returns a read-only view of all messages of type T.
Returns messages that were written to the buffer. If no messages of type T exist, returns an empty span.
- Template Parameters
-
T The message type to read.
- Returns
A span over all messages of type T in the read buffer.
Definition at line 91 of file TypeIndexedReadWriteBuffer.ixx.
reserve()
| inline |
Pre-allocates capacity for messages of type T.
Call during initialization to avoid allocations during gameplay.
- Template Parameters
-
T The message type.
- Parameters
-
size The number of messages to reserve capacity for.
Definition at line 112 of file TypeIndexedReadWriteBuffer.ixx.
Reference helios::core::buffer::TypeIndexedReadWriteBuffer< Indexer >::getOrCreateBuffer.
Private Member Attributes
buffers_
|
Type-erased storage for message buffers, indexed by type.
Definition at line 41 of file TypeIndexedReadWriteBuffer.ixx.
Private Static Functions
index()
| inline static |
Returns the buffer index for message type T.
- Template Parameters
-
T The message type.
- Returns
The index assigned to type T by the Indexer.
Definition at line 51 of file TypeIndexedReadWriteBuffer.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.