hierarchical_state_machine library

A hierarchical state machine (HSM) implementation for dart.

Classes

BasicBlueprint<S, E>
Base class for all state definitions in a MachineBlueprint.
ChoiceBlueprint<S, E>
A pseudostate that chooses a transition based on guards.
CompletionBlueprint<S, E>
Defines a completion transition (no event).
CompositeBlueprint<S, E>
A compound state that may contain children.
DefaultTransitionBlueprint<S, E>
Specialized transition for choice states (no guard).
DuplicateStateIdError<S>
Thrown when multiple states share the same ID.
FinalBlueprint<S, E>
A state representing a final node in a region.
ForkBlueprint<S, E>
A pseudostate that splits a transition into multiple simultaneous paths targeting different regions of a ParallelBlueprint.
ForkTransitionBlueprint<S, E>
Specialized transition for fork states.
ForkValidationError<S>
Thrown when a ForkState fails structural validation.
HsmState<S, E>
The read-only view of a state within a Machine.
InvalidInitialStateError<S>
Thrown when an initial state is not a proper descendant of its parent state.
InvalidRootError
Thrown when the root state is not a composite or parallel state.
Machine<S, E>
A hierarchical state machine (HSM) container of S states that accepts E events.
MachineBlueprint<S, E>
The root entry point for a state machine definition.
MachineObserver<S, E>
Observer interface for monitoring state machine execution.
MissingStateError<S>
Thrown when a transition or initial state targets a non-existent state.
ParallelBlueprint<S, E>
A compound state in which each direct child forms a region.
PrintObserver<S, E>
A default observer that prints machine activity to the console.
Serializer<S, E extends Object>
Serialize a hierarchial state machine for storage.
TerminateBlueprint<S, E>
A state representing a terminate node for the whole machine.
TransitionBlueprint<S, E>
Defines a transition to a target state.
UnknownDefinitionTypeError<S>
Thrown when an unknown definition type is encountered.
ValidationError
Base class for validation errors.

Enums

HistoryType
Defines the type of history restoration to apply during a transition.
StateType
The type of a state within a Machine.
TransitionKind
Defines whether a transition is local or external.

Extensions

StateTypeExtension on HsmState
Provides access to the StateType of an HsmState.

Typedefs

ActionFunction<E, D extends Object?> = void Function(E event, D data)
Function signature for transition effect behaviors.
GuardFunction<E, D extends Object?> = bool Function(E event, D data)
Function signature for guard conditions.
StateFunction = void Function()
Function signature for state entrance/exit behaviors.

Exceptions / Errors

FingerprintException
Thrown when fingerprints of serialized machines and new blueprints do not match.