No-op specialization used when Manifest has no State enum.
More...
#include <StateManager.h>
Public Member Functions | |
| StateManager (std::enable_if_t<!std::is_void_v< T >, T > initialState) | |
| Construct with an explicit initial state. | |
| std::enable_if_t<!std::is_void_v< T >, T > | getState () const |
| Return the current state value. | |
| std::enable_if_t<!std::is_void_v< T >, bool > | isState (T state) const |
Return true if currently in state. | |
| std::enable_if_t<!std::is_void_v< T > > | onStateEnter (std::function< void(T)> callback) |
| Register a callback invoked after each state transition. | |
| std::enable_if_t<!std::is_void_v< T > > | onStateExit (std::function< void(T)> callback) |
| Register a callback invoked before each state transition. | |
| std::enable_if_t<!std::is_void_v< T > > | setState (T newState) |
| Transition to a new state. | |
No-op specialization used when Manifest has no State enum.
Declares no members so there is no ambiguity when this base is combined with other StateManager specializations in a multiple-inheritance chain.
Definition at line 173 of file StateManager.h.
|
explicit |
Construct with an explicit initial state.
| initialState | The state to start in. The enter callback is not fired during construction. |
| std::enable_if_t<!std::is_void_v< T >, T > ml::StateManager< void >::getState | ( | ) | const |
Return the current state value.
StateEnum value. | std::enable_if_t<!std::is_void_v< T >, bool > ml::StateManager< void >::isState | ( | T | state | ) | const |
Return true if currently in state.
| state | The state value to compare against. |
true if the current state equals state. | std::enable_if_t<!std::is_void_v< T > > ml::StateManager< void >::onStateEnter | ( | std::function< void(T)> | callback | ) |
Register a callback invoked after each state transition.
The callback receives the newly entered state. Only one enter callback is active at a time; calling this again replaces it.
| callback | Function called with the new state after each transition. |
| std::enable_if_t<!std::is_void_v< T > > ml::StateManager< void >::onStateExit | ( | std::function< void(T)> | callback | ) |
Register a callback invoked before each state transition.
The callback receives the state being left. Only one exit callback is active at a time; calling this again replaces it.
| callback | Function called with the old state before each transition. |
| std::enable_if_t<!std::is_void_v< T > > ml::StateManager< void >::setState | ( | T | newState | ) |
Transition to a new state.
Fires the exit callback with the current state, updates the stored state to newState, then fires the enter callback with the new state. Either callback may be unset (nullptr), in which case it is skipped.
| newState | The state to transition into. |