StateManager Class Template
Manages state transitions using a rule-based system. More...
Declaration
Public Member Typedefs Index
template <typename StateType> | |
| using | EngineRoleTag = helios::engine::runtime::world::tags::ManagerRole |
Public Constructors Index
template <typename StateType> | |
| StateManager (std::span< const StateTransitionRule< StateType > > rules) | |
|
Constructs a state manager with transition rules. More... | |
Public Member Functions Index
template <typename StateType> | |
| StateManager & | addStateListener (std::unique_ptr< StateTransitionListener< StateType > > listener) noexcept |
|
Registers a state transition listener. More... | |
template <typename StateType> | |
| void | flush (helios::engine::runtime::world::UpdateContext &updateContext) noexcept |
|
Processes pending state commands. More... | |
template <typename StateType> | |
| bool | submit (StateCommand< StateType > &&stateCommand) noexcept |
|
Submits a state command for processing. More... | |
template <typename StateType> | |
| bool | submit (DelayedStateCommand< StateType > &&stateCommand) noexcept |
|
Submits a delayed state command for processing. More... | |
template <typename StateType> | |
| void | init (helios::engine::runtime::messaging::command::CommandHandlerRegistry &commandHandlerRegistry) |
|
Initializes the manager and registers command handlers. More... | |
template <typename StateType> | |
| void | reset () |
|
Clears all pending commands. More... | |
Private Member Functions Index
template <typename StateType> | |
| void | signalExit (const StateType from, const StateType to, const StateTransitionIdType< StateType > transitionId, helios::engine::runtime::world::UpdateContext &updateContext) |
|
Notifies listeners of state exit. More... | |
template <typename StateType> | |
| void | signalTransition (const StateType from, const StateType to, const StateTransitionIdType< StateType > transitionId, helios::engine::runtime::world::UpdateContext &updateContext) |
|
Notifies listeners of the transition. More... | |
template <typename StateType> | |
| void | signalEnter (const StateType from, const StateType to, const StateTransitionIdType< StateType > transitionId, helios::engine::runtime::world::UpdateContext &updateContext) |
|
Notifies listeners of state entry. More... | |
Private Member Attributes Index
template <typename StateType> | |
| std::vector< StateCommand< StateType > > | pending_ |
|
Queue of pending state commands. More... | |
template <typename StateType> | |
| std::vector< std::unique_ptr< StateTransitionListener< StateType > > > | listeners_ |
|
Registered transition listeners. More... | |
template <typename StateType> | |
| std::vector< StateTransitionRule< StateType > > | rules_ |
|
Transition rules defining valid state changes. More... | |
Description
Manages state transitions using a rule-based system.
Implements both Manager and TypedStateCommandHandler interfaces. Processes state transition commands by matching against registered rules, executing guards, and notifying listeners.
Definition at line 69 of file StateManager.ixx.
Public Member Typedefs
EngineRoleTag
|
Definition at line 149 of file StateManager.ixx.
Public Constructors
StateManager()
| inline explicit |
Constructs a state manager with transition rules.
- Parameters
-
rules Span of valid transition rules.
Definition at line 156 of file StateManager.ixx.
Public Member Functions
addStateListener()
| inline noexcept |
Registers a state transition listener.
- Parameters
-
listener The listener to add.
- Returns
Reference to this manager for chaining.
Definition at line 166 of file StateManager.ixx.
Reference helios::registerComponents.
flush()
| inline noexcept |
Processes pending state commands.
Processes the last pending command, finds matching rules, executes guards, and triggers the transition if valid.
- Parameters
-
updateContext The current frame's update context.
Definition at line 179 of file StateManager.ixx.
References helios::engine::state::types::StateTransitionContext< StateType >::from and helios::registerComponents.
init()
| inline |
Initializes the manager and registers command handlers.
- Parameters
-
commandHandlerRegistry The command-handler registry to register with.
Definition at line 261 of file StateManager.ixx.
Reference helios::engine::runtime::messaging::command::CommandHandlerRegistry::registerHandler.
reset()
| inline |
Clears all pending commands.
Definition at line 269 of file StateManager.ixx.
submit()
| inline noexcept |
Submits a state command for processing.
- Parameters
-
stateCommand The command to queue.
- Returns
True (always accepts commands).
Definition at line 229 of file StateManager.ixx.
Reference helios::registerComponents.
submit()
| inline noexcept |
Submits a delayed state command for processing.
Extracts the transition request from the delayed command and queues it as a regular StateCommand. The timer ID is not retained by the manager. The delayed command is guaranteed to be ready for processing when submitted here.
- Parameters
-
stateCommand The delayed command to queue.
- Returns
True (always accepts commands).
Definition at line 249 of file StateManager.ixx.
Reference helios::registerComponents.
Private Member Functions
signalEnter()
| inline |
Notifies listeners of state entry.
- Parameters
-
from The source state.
to The state being entered.
transitionId The transition identifier.
updateContext The current frame's update context.
Definition at line 135 of file StateManager.ixx.
signalExit()
| inline |
Notifies listeners of state exit.
- Parameters
-
from The state being exited.
to The target state.
transitionId The transition identifier.
updateContext The current frame's update context.
Definition at line 94 of file StateManager.ixx.
signalTransition()
| inline |
Notifies listeners of the transition.
- Parameters
-
from The source state.
to The target state.
transitionId The transition identifier.
updateContext The current frame's update context.
Definition at line 113 of file StateManager.ixx.
Private Member Attributes
listeners_
|
Registered transition listeners.
Definition at line 79 of file StateManager.ixx.
pending_
|
Queue of pending state commands.
Definition at line 74 of file StateManager.ixx.
rules_
|
Transition rules defining valid state changes.
Definition at line 84 of file StateManager.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.