Loading...
Searching...
No Matches
ml::StateManager< void > Class Reference

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ StateManager()

ml::StateManager< void >::StateManager ( std::enable_if_t<!std::is_void_v< T >, T > initialState)
explicit

Construct with an explicit initial state.

Parameters
initialStateThe state to start in. The enter callback is not fired during construction.

Member Function Documentation

◆ getState()

std::enable_if_t<!std::is_void_v< T >, T > ml::StateManager< void >::getState ( ) const

Return the current state value.

Returns
The active StateEnum value.

◆ isState()

std::enable_if_t<!std::is_void_v< T >, bool > ml::StateManager< void >::isState ( T state) const

Return true if currently in state.

Parameters
stateThe state value to compare against.
Returns
true if the current state equals state.

◆ onStateEnter()

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.

Parameters
callbackFunction called with the new state after each transition.

◆ onStateExit()

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.

Parameters
callbackFunction called with the old state before each transition.

◆ setState()

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.

Parameters
newStateThe state to transition into.

The documentation for this class was generated from the following file: