|
CPP-TOOLBOX
|
A state machine wrapper that binds actions (callbacks/lambdas) to state lifecycle events. More...
#include <state_machine.hpp>
Classes | |
| struct | State |
Public Types | |
| using | Action = std::function<void()> |
| using | Condition = std::function<bool()> |
| using | Pure = PureStateMachine<StateType> |
Public Member Functions | |
| StateMachine (StateType initial_state) | |
| void | add_state (StateType state, std::optional< Action > on_enter=std::nullopt, std::optional< Action > on_update=std::nullopt, std::optional< Action > on_exit=std::nullopt) |
| void | add_transition (StateType from, StateType to, Condition condition) |
| void | update () |
| Performs one update tick: | |
| StateType | get_state () const |
| const Pure & | get_pure_fsm () const |
A state machine wrapper that binds actions (callbacks/lambdas) to state lifecycle events.
This class wraps a PureStateMachine and executes side effects (callbacks) corresponding to the emitted events from the pure FSM. It’s suitable for real-time or game logic, where on_enter, on_update, and on_exit actions should trigger immediate effects.
| StateType | Enum or integral type representing states. |
| using StateMachine< StateType >::Action = std::function<void()> |
| using StateMachine< StateType >::Condition = std::function<bool()> |
| using StateMachine< StateType >::Pure = PureStateMachine<StateType> |
|
inlineexplicit |
|
inline |
|
inline |
|
inlinenodiscard |
|
inlinenodiscard |
|
inline |
Performs one update tick: