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 ctor()
ged edited this page Sep 9, 2024
·
10 revisions
Initializes a FiniteStateMachine<TContext> instance that has a specified context.
template<class TContext>
FiniteStateMachine(TContext* context)-
TContext: The type of the context, which holds data or behavior relevant to the state machine.
-
context: The context to be used by the state machine.
The state machine uses a context of type TContext to share information between states.
The context is passed to each state's callback, allowing the states to modify or query shared data.
// primitive context
int foo1 = 5;
FiniteStateMachine<int> foo1SM(&foo1);
float foo2 = 1.0f;
FiniteStateMachine<float> foo2SM(&foo2);
// user-defined context
struct FooStructContext; // implementation omitted for brevity
auto fooContext1 = FooStructContext();
auto fooContext1SM = FiniteStateMachine<FooStructContext>(&fooContext1);
class FooClassContext; // implementation omitted for brevity
auto fooContext2 = FooClassContext();
auto fooContext2SM = FiniteStateMachine<FooClassContext>(&fooContext2);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()