Statifier.Document (statifier v1.9.0)

View Source

Represents a parsed SCXML document.

Summary

Functions

Build lookup maps for efficient O(1) state and transition access.

Find all history states within a parent state.

Find a state by ID using O(1) lookup.

Get all states from the document hierarchy as a flat list.

Get the default transition targets for a history state.

Get all transitions from a given source state using O(1) lookup.

Check if a state is a history state.

Types

t()

@type t() :: %Statifier.Document{
  binding: String.t() | nil,
  binding_location: term(),
  datamodel: String.t() | nil,
  datamodel_elements: [Statifier.Data.t()],
  datamodel_location: map() | nil,
  document_order: integer() | nil,
  hierarchy_cache: Statifier.HierarchyCache.t(),
  initial: [String.t()],
  initial_location: map() | nil,
  name: String.t() | nil,
  name_location: map() | nil,
  source_location: map() | nil,
  state_lookup: %{required(String.t()) => Statifier.State.t()},
  states: [Statifier.State.t()],
  transitions_by_source: %{required(String.t()) => [Statifier.Transition.t()]},
  validated: boolean(),
  version: String.t() | nil,
  version_location: map() | nil,
  xmlns: String.t() | nil
}

Functions

build_lookup_maps(document)

@spec build_lookup_maps(t()) :: t()

Build lookup maps for efficient O(1) state and transition access.

This is typically called after the document structure is built to populate the lookup maps from the state hierarchy.

find_history_states(document, parent_state_id)

@spec find_history_states(t(), String.t()) :: [Statifier.State.t()]

Find all history states within a parent state.

Returns a list of history states that are direct children of the specified parent. Returns an empty list if the parent is not found or has no history children.

find_state(document, state_id)

@spec find_state(t(), String.t()) :: Statifier.State.t() | nil

Find a state by ID using O(1) lookup.

get_all_states(document)

@spec get_all_states(t()) :: [Statifier.State.t()]

Get all states from the document hierarchy as a flat list.

Returns all states including nested children from the document's state hierarchy.

get_history_default_targets(document, history_state_id)

@spec get_history_default_targets(t(), String.t()) :: [String.t()]

Get the default transition targets for a history state.

Returns a list of target state IDs from the history state's default transitions. Returns an empty list if the state is not found, not a history state, or has no transitions.

get_transitions_from_state(document, state_id)

@spec get_transitions_from_state(t(), String.t()) :: [Statifier.Transition.t()]

Get all transitions from a given source state using O(1) lookup.

is_history_state?(document, state_id)

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

Check if a state is a history state.

Returns true if the state exists and has type :history, false otherwise.