SC.Configuration (sc v1.0.2)

View Source

Represents the current active states in an SCXML state chart.

Only stores leaf (atomic) states - parent states are considered active when any of their children are active. Use active_ancestors/2 to compute the full set of active states including ancestors.

Summary

Functions

Check if a specific leaf state is active.

Compute all active states including ancestors for the given document.

Get the set of active leaf states.

Add a leaf state to the active configuration.

Create a new configuration with the given active states.

Remove a leaf state from the active configuration.

Types

t()

@type t() :: %SC.Configuration{active_states: MapSet.t(String.t())}

Functions

active?(config, state_id)

@spec active?(t(), String.t()) :: boolean()

Check if a specific leaf state is active.

active_ancestors(config, document)

@spec active_ancestors(t(), SC.Document.t()) :: MapSet.t(String.t())

Compute all active states including ancestors for the given document.

Uses parent pointers for O(d) performance per state instead of O(n×d) tree traversal, where d is the maximum depth and n is the number of states. This optimization is critical since active configuration is computed frequently during interpretation.

active_states(configuration)

@spec active_states(t()) :: MapSet.t(String.t())

Get the set of active leaf states.

add_state(config, state_id)

@spec add_state(t(), String.t()) :: t()

Add a leaf state to the active configuration.

new(state_ids)

@spec new([String.t()]) :: t()

Create a new configuration with the given active states.

remove_state(config, state_id)

@spec remove_state(t(), String.t()) :: t()

Remove a leaf state from the active configuration.