-
Notifications
You must be signed in to change notification settings - Fork 1
StateMachineHandler
A generic state machine handler class that manages state transitions and execution for a state machine.
Can be used as the core handler for different types of state machines, including Finite State Machines (FSM) and Hierarchical State Machines (HSM). It queues and processes state transitions and provides hooks for entering, updating, and exiting states.
Uses a queue that holds the type of callback to execute, a pointer to the reference of a state, and a pointer to the destination state. The size of the queue depends on the value of SZ + 1.
class StateMachineHandler-
StateMachineHandler(TContext* context)- Initializes a
StateMachineHandlerclass with a specified context.
- Initializes a
-
getNextState()- Retrieves the next state to which the state machine will transition.
-
getActiveState()- Retrieves the currently active state.
-
isInState(StateBase<TContext>&)- Checks if the current state of the state machine is the specified state.
-
setNextState(StateBase<TContext>*)- Sets the next state for the state machine to transition to.
-
queueTransition(StateStatus status, StateBase<TContext>*)- Queues a state transition with a specified state status to execute.
-
beginTransitionQueue()- Begins a new transition queue.
-
endTransitionQueue(StateBase<TContext>*)- Queues the final transition, marking the end of the transition queue.
-
execute()- executes all queued state transitions, calling the appropriate callbacks for each state.
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()