TypedCommandBuffer Class Template
Compile-time typed command buffer with per-type queues and handler routing. More...
Declaration
Public Member Typedefs Index
template <typename... CommandTypes> | |
| using | EngineRoleTag = helios::engine::runtime::world::tags::CommandBufferRole |
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 | init (CommandHandlerRegistry &commandHandlerRegistry, TimerManager &timerManager) noexcept |
template <typename... CommandTypes> | |
| void | clear () noexcept |
|
Discards all queued commands without executing them. More... | |
template <typename... CommandTypes> | |
| void | flush (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> | |
| auto | delayedQueue () noexcept -> std::vector< CommandType > & |
|
Returns the delayed scratch queue for a specific command type. More... | |
template <typename... CommandTypes> | |
| bool | shouldDelayCommand (const TimerState state) const noexcept |
|
Determines whether a delayed command should be deferred. More... | |
template <typename... CommandTypes> | |
| bool | shouldDiscardCommand (const TimerState state) const noexcept |
|
Determines whether a delayed command should be discarded. More... | |
template <typename... CommandTypes> | |
| bool | isDelayedCommandReady (const TimerState state) const noexcept |
|
Determines whether a delayed command is ready for dispatch. More... | |
template <typename CommandType> | |
| void | flushCommandQueue (UpdateContext &updateContext) noexcept |
|
Flushes a single command queue. More... | |
Private Member Attributes Index
template <typename... CommandTypes> | |
| TimerManager * | timerManager_ |
template <typename... CommandTypes> | |
| CommandHandlerRegistry * | commandHandlerRegistry_ |
template <typename... CommandTypes> | |
| std::tuple< std::vector< CommandTypes >... > | commandQueues_ |
|
Per-type command queues stored as a tuple of vectors. More... | |
template <typename... CommandTypes> | |
| std::tuple< std::vector< CommandTypes >... > | delayedQueues_ |
|
Scratch queues for timer-gated commands surviving a flush cycle. 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).
Definition at line 94 of file TypedCommandBuffer.ixx.
Public Member Typedefs
EngineRoleTag
|
Definition at line 289 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 300 of file TypedCommandBuffer.ixx.
Reference helios::engine::runtime::registerComponents.
clear()
| inline noexcept |
Discards all queued commands without executing them.
Definition at line 313 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 326 of file TypedCommandBuffer.ixx.
Reference helios::engine::runtime::registerComponents.
init()
| inline noexcept |
Definition at line 305 of file TypedCommandBuffer.ixx.
Reference helios::engine::runtime::registerComponents.
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 122 of file TypedCommandBuffer.ixx.
delayedQueue()
| inline noexcept |
Returns the delayed scratch queue for a specific command type.
- Template Parameters
-
CommandType The command type.
- Returns
Reference to the delayed scratch queue.
Definition at line 134 of file TypedCommandBuffer.ixx.
flushCommandQueue()
| inline noexcept |
Flushes a single command queue.
Processing follows two branches depending on whether a handler is registered for CommandType:
Handler registered (CommandHandlerRegistry::has<CommandType>()):
- Each command is forwarded via commandHandlerRegistry.submit<CommandType>(cmd).
No handler registered (fallback):
- The command must satisfy ExecutableCommand; otherwise an assertion fires at runtime.
- Each command is dispatched via cmd.execute(updateContext).
In both branches, if CommandType satisfies DelayedCommandLike, an additional timer check is performed per command:
- The associated Timer is looked up via the command's timerId().
- If the timer is still running (shouldDelayCommand returns true), the command is moved into the scratch queue and survives the current flush cycle.
- If the timer has finished (isDelayedCommandReady returns true), the command is dispatched normally.
- If the timer state is Undefined (e.g. timer was removed), the command is silently dropped.
After all commands have been processed the primary queue is cleared, the scratch queue contents are swapped back in as the new primary queue, and the scratch queue is cleared.
- Template Parameters
-
CommandType The command type to flush.
- Parameters
-
gameWorld The game world providing the CommandHandlerRegistry and TimerManager.
updateContext The current frame's update context.
Definition at line 214 of file TypedCommandBuffer.ixx.
isDelayedCommandReady()
| inline noexcept |
Determines whether a delayed command is ready for dispatch.
- Parameters
-
state The current timer state.
- Returns
True if the associated timer has finished.
Definition at line 172 of file TypedCommandBuffer.ixx.
shouldDelayCommand()
| inline noexcept |
Determines whether a delayed command should be deferred.
Returns true when the timer is still running - i.e. its state is neither Finished nor Undefined.
- Parameters
-
state The current timer state.
- Returns
True if the command must remain in the scratch queue.
Definition at line 148 of file TypedCommandBuffer.ixx.
shouldDiscardCommand()
| inline noexcept |
Determines whether a delayed command should be discarded.
Returns true when the timer is not in state Running or Finished..
- Parameters
-
state The current timer state.
- Returns
True if the command should be discarded.
Definition at line 161 of file TypedCommandBuffer.ixx.
Private Member Attributes
commandHandlerRegistry_
|
Definition at line 98 of file TypedCommandBuffer.ixx.
commandQueues_
|
Per-type command queues stored as a tuple of vectors.
Definition at line 103 of file TypedCommandBuffer.ixx.
delayedQueues_
|
Scratch queues for timer-gated commands surviving a flush cycle.
Commands satisfying DelayedCommandLike whose timer has not yet finished are moved here during flush and swapped back into the primary queues afterwards.
Definition at line 112 of file TypedCommandBuffer.ixx.
timerManager_
|
Definition at line 96 of file TypedCommandBuffer.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.