Implementation using a close approximation of https://www.w3.org/TR/2015/REC-scxml-20150901, including the suggested algorithm in that document, translated as closely as possible to CLJC. Future versions of the specification will appear as new namespaces to maintain compatibility through time.
::sc/k in the docstrings of this namespace assumes the alias [com.fulcrologic.statecharts :as sc]
, which
can be generated as only an alias, though an empty namespace of that name does exist.
Implementation using a close approximation of https://www.w3.org/TR/2015/REC-scxml-20150901, including the suggested algorithm in that document, translated as closely as possible to CLJC. Future versions of the specification will appear as new namespaces to maintain compatibility through time. ::sc/k in the docstrings of this namespace assumes the alias `[com.fulcrologic.statecharts :as sc]`, which can be generated as only an alias, though an empty namespace of that name does exist.
(all-descendants machine s)
Returns a set of IDs of the (recursive) descendants (children) of s
Returns a set of IDs of the (recursive) descendants (children) of s
(child-states machine element-or-id)
Find all of the immediate children (IDs) of element-or-id
that are states
(final, element-or-id, or parallel)
Find all of the immediate children (IDs) of `element-or-id` that are states (final, element-or-id, or parallel)
(compound-state? machine element-or-id)
Returns true if the given state contains other states.
Returns true if the given state contains other states.
(element machine element-or-id)
Find the node in the machine that has the given ID (of any type)
Find the node in the machine that has the given ID (of any type)
(exit-handlers machine element-or-id)
Returns the immediate child elements that are on-exit.
Returns the immediate child elements that are on-exit.
(find-least-common-compound-ancestor machine states)
Returns the ELEMENT that is the common compound ancestor of all the states
. NOTE: This may be
the state machine itself. The compound state returned will be the one closest to all of the states.
Returns the ELEMENT that is the common compound ancestor of all the `states`. NOTE: This may be the state machine itself. The compound state returned will be the one closest to all of the states.
(get-children machine element-or-id type)
Returns the ID of the child nodes of the given element-or-id
which
have the given type.
Returns the ID of the child nodes of the given `element-or-id` which have the given type.
(get-parent machine element-or-id)
Get the immediate parent (id) of the given element-or-id. Returns :ROOT if the parent is the root, and nil if the element queried is already the root.
Get the immediate parent (id) of the given element-or-id. Returns :ROOT if the parent is the root, and nil if the element queried is already the root.
[machine element-or-id]
Alias for nearest-ancestor-state
.
[machine element-or-id] Alias for `nearest-ancestor-state`.
(get-proper-ancestors machine element-or-id)
(get-proper-ancestors machine element-or-id stopping-element-or-id)
Returns the node ids from machine
that are proper ancestors of element-or-id
(an id or actual element-or-id). If stopping-element-or-id-or-id
is included, then that will stop the retrieval (not including the stopping element-or-id). The results are
in the ancestry order (i.e. deepest element-or-id first).
Returns the node ids from `machine` that are proper ancestors of `element-or-id` (an id or actual element-or-id). If `stopping-element-or-id-or-id` is included, then that will stop the retrieval (not including the stopping element-or-id). The results are in the ancestry order (i.e. deepest element-or-id first).
(ids-in-document-order machine)
(ids-in-document-order
{desired-order :com.fulcrologic.statecharts/document-order :as machine}
{:keys [id] :as node})
Returns the IDs of the states in the given node, in document order (not including the node itself).
You can specify ::sc/document-order :breadth-first
on the top-level machine definition to get a
depth-first interpretation vs. breadth.
Returns the IDs of the states in the given node, in document order (not including the node itself). You can specify `::sc/document-order :breadth-first` on the top-level machine definition to get a depth-first interpretation vs. breadth.
(in-document-order machine nodes-or-ids)
Given a set/sequence of actual nodes-or-ids (as maps), returns a vector of those nodes-or-ids, but in document order.
Given a set/sequence of actual nodes-or-ids (as maps), returns a vector of those nodes-or-ids, but in document order.
[machine nodes]
Same as in-document-order.
[machine nodes] Same as in-document-order.
(in-exit-order machine nodes)
The reverse of in-document-order.
The reverse of in-document-order.
(initial-element machine element-or-id)
Returns the element that represents the <initial> element of a compound state element-or-id. Returns nil if the element isn't a compound state.
Returns the element that represents the <initial> element of a compound state element-or-id. Returns nil if the element isn't a compound state.
(invalid-history-elements machine)
Returns a sequence of history elements from machine
that have errors. Each node will contain a :msgs
key
with the problem descriptions. This is a static check.
Returns a sequence of history elements from `machine` that have errors. Each node will contain a `:msgs` key with the problem descriptions. This is a static check.
(invocations machine element-or-id)
Returns the IDs of the nodes that are invocations within element-or-id
Returns the IDs of the nodes that are invocations within `element-or-id`
(machine {:keys [initial name binding] :as attrs} & children)
Create a new state machine definition that mimics the structure and semantics of SCXML.
Attributes:
::sc/document-order - :breadth-first or :depth-first (default). See Conformance.adoc.
:initial - ID(s) of initial state(s) of the machine. Default is the top-most initial
element,
or the first element in document order.
:name - Optional name
:binding - :late or :early (default is :early)
Create a new state machine definition that mimics the structure and semantics of SCXML. Attributes: ::sc/document-order - :breadth-first or :depth-first (default). See Conformance.adoc. :initial - ID(s) of initial state(s) of the machine. Default is the top-most `initial` element, or the first element in document order. :name - Optional name :binding - :late or :early (default is :early)
(nearest-ancestor-state machine element-or-id)
Returns the ID of the state (if any) that encloses the given element-or-id, or nil if there is no ancestor state.
Returns the ID of the state (if any) that encloses the given element-or-id, or nil if there is no ancestor state.
See machine
. SCXML-compliant name for top-level element.
See `machine`. SCXML-compliant name for top-level element.
[machine element-or-id] Returns the source (nearest ancestor that is a state element) of an element (meant to be used for transitions).
[machine element-or-id] Returns the source (nearest ancestor that is a state element) of an element (meant to be used for transitions).
(transition-element machine element-or-id)
Returns the element that represents the first transition of element-or-id. This should only be used on nodes that have a single required transition, such as <initial> and <history> nodes.
Returns the element that represents the first transition of element-or-id. This should only be used on nodes that have a single required transition, such as <initial> and <history> nodes.
(with-default-initial-state {:keys [id initial] :as parent} children)
Scans children for an initial state. If no such state is found then it creates one and sets the target to the first child that is a state.
Scans children for an initial state. If no such state is found then it creates one and sets the target to the first child that is a state.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close