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

HierarchicalStateMachine State ctor()

ged edited this page Sep 9, 2024 · 1 revision

Definition

Initializes a HierarchicalStateMachine<TContext>::State instance that has a specified parent, enter callback, update callback, and exit callback.

template<class TContext>
HierarchicalStateMachine<TContext>::State(HierarchicalStateMachine<TContext>::State* parent, StateCallback<TContext> enter, StateCallback<TContext> update, StateCallback<TContext> exit)

Type Parameters

  • TContext: The type of the context, which holds data or behavior relevant to the state machine.

Parameters

  • parent: The parent state of this state.
  • enter: Callback for entering this state.
  • update: Callback for updating this state.
  • exit: Callback for exiting this state.

Usage

// a root state with 'int' context that has enter, update, and exit callbacks
HierarchicalStateMachine<int>::State state1(nullptr, state1_enter, state1_update, state1_exit); 

// a child state with 'int' context that has enter and exit callbacks
HierarchicalStateMachine<int>::State state2(&state1, state2_enter, nullptr, state2_exit);

HierarchicalStateMachine<int>::State state3(&state1, nullptr, state3_update, state3_exit);

HierarchicalStateMachine<int>::State state4(&state3, state4_enter, nullptr, nullptr);

HierarchicalStateMachine<int>::State state5(&state3, nullptr, state5_update, state5_exit);

the above code produces a state hierarchy diagram: image

Clone this wiki locally