View Source Protean.Node (Protean v0.1.0-alpha.0)
Internal representation of an individual node in a Protean.MachineConfig
struct.
Link to this section Summary
Types
An atomic node is a node without child states.
A compound node is a node that defines children, of which only one can be
active. It must additionally define an :initial
attribute, the id of the
child state that should default to active if the compound state is entered.
A final node is a type of atomic node that represents some form of completion, and can therefore define no transitions itself. Note, however, that activating a final node causes an event to be dispatched that a parent node can choose to handle.
ID encompasses the node and all its ancestors. For example, a node :child_a
defined as a child of a node :parent_a
might have the id [:child_a, :parent_a]
A leaf Node is one that cannot have child states.
A parallel node defines children, all of which are entered when the parallel node is entered.
A Node is a node in a nested state machine. See the type docs for individual nodes for more details.
Functions
Given a Node id, return a list containing that id and all of its ancestors.
Tests whether descendant_id
is in fact a descendant of ancestor_id
.
Returns false if they are the same node.
Return the entry actions associated with the node.
Sort the given nodes in entry order.
Return the exit actions associated with the node.
Sort the given nodes in exit order.
Given a Node id, return its parent's id. Returns nil if the Node is the root.
Resolve a Node to its leaves (atomic or final) by either returning the given node or following the node's children.
Link to this section Types
@type atomic() :: %Protean.Node{ automatic_transitions: [Protean.Transition.t()], entry: [Protean.Action.t()], exit: [Protean.Action.t()], id: id(), initial: nil, order: non_neg_integer() | nil, states: nil, transitions: [Protean.Transition.t()], type: :atomic }
An atomic node is a node without child states.
A complex Node
is one that has child nodes.
@type compound() :: %Protean.Node{ automatic_transitions: [Protean.Transition.t()], entry: [Protean.Action.t()], exit: [Protean.Action.t()], id: id(), initial: id(), order: non_neg_integer() | nil, states: [t(), ...], transitions: [Protean.Transition.t()], type: :compound }
A compound node is a node that defines children, of which only one can be
active. It must additionally define an :initial
attribute, the id of the
child state that should default to active if the compound state is entered.
@type final() :: %Protean.Node{ automatic_transitions: [], entry: [Protean.Action.t()], exit: [Protean.Action.t()], id: id(), initial: nil, order: non_neg_integer() | nil, states: nil, transitions: [], type: :final }
A final node is a type of atomic node that represents some form of completion, and can therefore define no transitions itself. Note, however, that activating a final node causes an event to be dispatched that a parent node can choose to handle.
@opaque id()
ID encompasses the node and all its ancestors. For example, a node :child_a
defined as a child of a node :parent_a
might have the id [:child_a, :parent_a]
A leaf Node is one that cannot have child states.
@type nodes() :: [t()]
@type parallel() :: %Protean.Node{ automatic_transitions: [Protean.Transition.t()], entry: [Protean.Action.t()], exit: [Protean.Action.t()], id: id(), initial: nil, order: non_neg_integer() | nil, states: [t(), ...], transitions: [Protean.Transition.t()], type: :parallel }
A parallel node defines children, all of which are entered when the parallel node is entered.
A simple Node
is one that cannot have child nodes.
A Node is a node in a nested state machine. See the type docs for individual nodes for more details.
Link to this section Functions
Given a Node id, return a list containing that id and all of its ancestors.
Tests whether descendant_id
is in fact a descendant of ancestor_id
.
Returns false if they are the same node.
@spec entry_actions(t()) :: [Protean.Action.t()]
Return the entry actions associated with the node.
Sort the given nodes in entry order.
@spec exit_actions(t()) :: [Protean.Action.t()]
Return the exit actions associated with the node.
Sort the given nodes in exit order.
Given a Node id, return its parent's id. Returns nil if the Node is the root.
Resolve a Node to its leaves (atomic or final) by either returning the given node or following the node's children.