This repository was archived by the owner on Nov 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
FiniteStateMachine isInState()
ged edited this page Sep 9, 2024
·
5 revisions
Checks if the state machine is currently in the specified state.
template<class TContext>
bool isInState(FiniteStateMachine<TContext>::State& state) const-
TContext: The type of the context, which holds data or behavior relevant to the state machine.
-
state: The state to be compared.
true if the state is the current state, otherwise false.
This function allows querying whether the current state matches the provided state.
Useful for controlling flow based on the state machine's active state.
auto ctx = static_cast<int>(5);
auto fsm = FiniteStateMachine<int>(&ctx);
auto state1 = FiniteStateMachine<int>::State(state1_enter, state1_update, state1_exit);
auto state2 = FiniteStateMachine<int>::State(state2_enter, state2_update, nullptr);
...
if (fsm.isInState(state1))
{
/* do something */
}
else if (fsm.isInState(state2))
{
/* do something */
}Common Types
→ StateStatus (enum)
→ StateCallback (alias)
Finite State Machine (FSM)
→ State
→ ctor()
→ isInState()
→ transitionTo()
→ update()
Hierarchical State Machine (HSM)
→ State
→ ctor()
→ isInState()
→ transitionTo()
→ update()
State Base
→ ctor()
→ is()
→ enter()
→ update()
→ exit()
State Machine Handler
→ ctor()
→ getNextState()
→ getActiveState()
→ isInState()
→ setNextState()
→ queueTransition()
→ beginTransitionQueue()
→ endTransitionQueue()
→ execute()