TypedCommandBuffer Class Template
Compile-time typed command buffer with per-type queues and handler routing. More...
Declaration
Public Member Functions Index
template <typename T, typename... Args> | |
| void | add (Args &&... args) |
|
Enqueues a command of the specified type. More... | |
template <typename... CommandTypes> | |
| void | clear () noexcept |
|
Discards all queued commands without executing them. More... | |
template <typename... CommandTypes> | |
| void | flush (GameWorld &gameWorld, UpdateContext &updateContext) noexcept |
|
Flushes all command queues in template parameter order. More... | |
Private Member Functions Index
template <typename CommandType> | |
| auto | commandQueue () noexcept -> std::vector< CommandType > & |
|
Returns the queue for a specific command type. More... | |
template <typename CommandType> | |
| void | flushCommandQueue (GameWorld &gameWorld, UpdateContext &updateContext) noexcept |
|
Flushes a single command queue. More... | |
Private Member Attributes Index
template <typename... CommandTypes> | |
| std::tuple< std::vector< CommandTypes >... > | commandQueues_ |
|
Per-type command queues stored as a tuple of vectors. More... | |
Description
Compile-time typed command buffer with per-type queues and handler routing.
TypedCommandBuffer stores commands in separate `std::vector` queues, one per command type, packed into a `std::tuple`. This provides:
- **Zero-overhead dispatch:** Command types are known at compile time, eliminating virtual dispatch for queue access.
- **Deterministic ordering:** Commands are flushed in the order of the template parameter list, ensuring reproducible execution.
- **Handler-or-execute routing:** During flush, each command is either routed to a registered handler or executed directly via its `execute()` method (if it satisfies ExecutableCommand).
## Flush Routing
For each command type in the parameter pack: 1. If a handler for `Cmd` is registered → `handler.submit(cmd)` 2. Else if `Cmd` satisfies `ExecutableCommand` → `cmd.execute(ctx)` 3. Else → assertion failure (misconfiguration)
- Template Parameters
-
CommandTypes The command types this buffer manages.
- See Also
- See Also
- See Also
- See Also
ExecutableCommand
Definition at line 69 of file TypedCommandBuffer.ixx.
Public Member Functions
add()
| inline |
Enqueues a command of the specified type.
- Template Parameters
-
T The command type. Must be one of the CommandTypes.
Args Constructor argument types.
- Parameters
-
args Arguments forwarded to the command constructor.
Definition at line 139 of file TypedCommandBuffer.ixx.
clear()
| inline noexcept |
Discards all queued commands without executing them.
Definition at line 147 of file TypedCommandBuffer.ixx.
flush()
| inline noexcept |
Flushes all command queues in template parameter order.
Iterates through each command type using a fold expression, flushing queues in the order specified by the template parameters.
- Parameters
-
gameWorld The game world for which the queue should be flushed.
updateContext The current frame's update context.
Definition at line 160 of file TypedCommandBuffer.ixx.
Private Member Functions
commandQueue()
| inline noexcept |
Returns the queue for a specific command type.
- Template Parameters
-
CommandType The command type.
- Returns
Reference to the command queue.
Definition at line 84 of file TypedCommandBuffer.ixx.
flushCommandQueue()
| inline noexcept |
Flushes a single command queue.
Routes each command to its registered handler, or executes it directly if no handler is registered and the command satisfies ExecutableCommand.
- Template Parameters
-
CommandType The command type to flush.
- Parameters
-
gameWorld The game world for which the queue should be flushed.
updateContext The current frame's update context.
Definition at line 101 of file TypedCommandBuffer.ixx.
Private Member Attributes
commandQueues_
|
Per-type command queues stored as a tuple of vectors.
Definition at line 74 of file TypedCommandBuffer.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.