Skip to content
This repository was archived by the owner on Nov 16, 2025. It is now read-only.

FiniteStateMachine ctor()

ged edited this page Sep 9, 2024 · 10 revisions

Initializes a FiniteStateMachine<TContext> instance that has a specified context.

FiniteStateMachine(TContext* context)

Parameters

  • context: The context to be used by the state machine.

Remarks

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.

Usage

// primitive context
int foo = 5;
FiniteStateMachine<int> fooSM1(&foo);

// user-defined context
struct FooContext; // implementation omitted for brevity
auto fooContext = FooContext();
auto fooSM2 = FiniteStateMachine<FooContext>(&fooContext);

Clone this wiki locally