tin  1.5.9
tsm::core Namespace Reference

Namespaces

 detail
 

Classes

struct  static_path
 
struct  type_set
 
struct  type_set< tsm::detail::type_list< Ts... > >
 
struct  transition_table
 
struct  transition_states
 
struct  get_states
 
struct  get_states< tsm::detail::type_list< TransitionEntries... > >
 
struct  get_events
 
struct  get_events< tsm::detail::type_list< TransitionEntries... > >
 
struct  transition_table< tsm::detail::type_list< TransitionEntries... > >
 
struct  parent
 
struct  initial_child
 
struct  parent_map_from_list
 
struct  parent_map_from_list< tsm::detail::type_list< Parents... > >
 
struct  initial_child_map_from_list
 
struct  initial_child_map_from_list< tsm::detail::type_list< InitialChildren... > >
 
struct  hierarchy
 
struct  infer_hierarchy
 
struct  hierarchy< Root, tsm::detail::type_list< States... >, tsm::detail::type_list< Parents... >, tsm::detail::type_list< InitialChildren... > >
 
struct  transition_sequence
 

Typedefs

template<typename TransitionList >
using get_states_t = typename get_states< TransitionList >::type
 
template<typename TransitionList >
using get_events_t = typename get_events< TransitionList >::type
 
template<typename ParentList >
using parent_map_from_list_t = typename parent_map_from_list< ParentList >::type
 
template<typename InitialChildList >
using initial_child_map_from_list_t = typename initial_child_map_from_list< InitialChildList >::type
 
template<typename Context , typename Root = detail::inferred_root<Context>>
using infer_hierarchy_t = typename infer_hierarchy< Context, Root >::type
 

Functions

template<typename T , typename... Ts>
consteval std::size_t index_in_pack ()
 
template<typename T , typename... Ts>
consteval bool contains_type ()
 
template<typename From , typename Event , typename... TransitionEntries>
consteval std::size_t trigger_count ()
 
template<typename From , typename Event , typename... TransitionEntries>
consteval bool duplicate_group_is_guarded ()
 
template<typename From , typename Event , typename... TransitionEntries>
consteval std::size_t duplicate_group_unguarded_count ()
 
template<typename From , typename Event , typename... TransitionEntries>
consteval bool trigger_group_is_valid ()
 
template<typename... TransitionEntries>
consteval bool transition_triggers_are_valid ()
 
template<typename Hierarchy >
constexpr auto compute_transition_sequence (std::uint16_t source, std::uint16_t destination)
 
template<typename Hierarchy >
constexpr auto compute_local_transition_sequence (std::uint16_t active_leaf, std::uint16_t selected_source, std::uint16_t destination)
 
template<typename Hierarchy >
constexpr auto compute_reentering_transition_sequence (std::uint16_t active_leaf, std::uint16_t selected_source, std::uint16_t destination)
 

Variables

constexpr std::uint16_t npos = 0xFFFFU
 
template<typename TransitionList >
concept transition_list_like
 
template<typename From , typename Event , typename Transition >
constexpr bool same_trigger_v
 

Typedef Documentation

◆ get_events_t

template<typename TransitionList >
using tsm::core::get_events_t = typedef typename get_events<TransitionList>::type

◆ get_states_t

template<typename TransitionList >
using tsm::core::get_states_t = typedef typename get_states<TransitionList>::type

◆ infer_hierarchy_t

template<typename Context , typename Root = detail::inferred_root<Context>>
using tsm::core::infer_hierarchy_t = typedef typename infer_hierarchy<Context, Root>::type

◆ initial_child_map_from_list_t

template<typename InitialChildList >
using tsm::core::initial_child_map_from_list_t = typedef typename initial_child_map_from_list<InitialChildList>::type

◆ parent_map_from_list_t

template<typename ParentList >
using tsm::core::parent_map_from_list_t = typedef typename parent_map_from_list<ParentList>::type

Function Documentation

◆ compute_local_transition_sequence()

template<typename Hierarchy >
constexpr auto tsm::core::compute_local_transition_sequence ( std::uint16_t  active_leaf,
std::uint16_t  selected_source,
std::uint16_t  destination 
)
constexpr

◆ compute_reentering_transition_sequence()

template<typename Hierarchy >
constexpr auto tsm::core::compute_reentering_transition_sequence ( std::uint16_t  active_leaf,
std::uint16_t  selected_source,
std::uint16_t  destination 
)
constexpr

Compute an explicit re-entering external transition sequence.

Normal verified-tsm transitions preserve the least common ancestor. This helper models the UML/SCXML external form selected from a composite state: the selected source is exited and can be entered again on the target path.

(define (reentering-external active source destination hierarchy) (let* ((boundary (parent source hierarchy)) (exits (states-from-leaf-up-to active boundary hierarchy)) (entries (states-from-lca-down-to boundary destination hierarchy))) (transition-sequence destination boundary exits entries ...)))

◆ compute_transition_sequence()

template<typename Hierarchy >
constexpr auto tsm::core::compute_transition_sequence ( std::uint16_t  source,
std::uint16_t  destination 
)
constexpr

Compute a transition execution sequence.

Given a source leaf and destination state, compute the LCA, exit path, entry path, initial-entry descent, and final active path. The result is numeric and fixed-capacity so a runtime backend can execute it deterministically.

(define (transition-sequence source destination hierarchy) (let* ((lca (least-common-ancestor source destination hierarchy)) (exits (states-from-leaf-up-to source lca hierarchy)) (direct-entries (states-from-lca-down-to lca destination hierarchy)) (initial-entries (enter-initial-children destination hierarchy)) (entries (append direct-entries initial-entries)) (final-path (append (path-from-root lca hierarchy) entries))) (transition-sequence destination lca exits entries final-path))

◆ contains_type()

template<typename T , typename... Ts>
consteval bool tsm::core::contains_type ( )

Membership test for a type list.

(define (member? needle haystack) (not (= (index-of needle haystack) npos)))

◆ duplicate_group_is_guarded()

template<typename From , typename Event , typename... TransitionEntries>
consteval bool tsm::core::duplicate_group_is_guarded ( )

◆ duplicate_group_unguarded_count()

template<typename From , typename Event , typename... TransitionEntries>
consteval std::size_t tsm::core::duplicate_group_unguarded_count ( )

◆ index_in_pack()

template<typename T , typename... Ts>
consteval std::size_t tsm::core::index_in_pack ( )

Position of a type in a type list.

This answers: "where does this state/event/transition type appear in the declaration order?" The result is the stable numeric ID used by runtime dispatch and trace records.

(define (index-of needle haystack) (match haystack (() npos) ((needle . _) 0) ((_ . rest) (+ 1 (index-of needle rest)))))

(define (first-index-where predicate haystack) (match haystack (() npos) ((item . rest) (if (predicate item) 0 (let ((rest-index (first-index-where predicate rest))) (if (= rest-index npos) npos (+ 1 rest-index)))))))

The C++ implementation computes the answer at compile time. Callers that require a valid ID turn the failure value into a static assertion.

◆ transition_triggers_are_valid()

template<typename... TransitionEntries>
consteval bool tsm::core::transition_triggers_are_valid ( )

Validate duplicate triggers in an authored transition table.

Normal states may have at most one unguarded (from, event) edge. Multiple edges are allowed only when every candidate has a guard, because runtime dispatch evaluates them in declaration order and takes the first accepted transition.

Choice and junction pseudostates use the same mechanism for automatic transitions, with one extra allowance: a single unguarded fallback branch may appear after guarded branches.

◆ trigger_count()

template<typename From , typename Event , typename... TransitionEntries>
consteval std::size_t tsm::core::trigger_count ( )

◆ trigger_group_is_valid()

template<typename From , typename Event , typename... TransitionEntries>
consteval bool tsm::core::trigger_group_is_valid ( )

Variable Documentation

◆ npos

constexpr std::uint16_t tsm::core::npos = 0xFFFFU
inlineconstexpr

"No state" or "no transition" marker.

This is the value returned when a lookup cannot find a valid state, transition, parent, or initial child. It is encoded as a small integer because the indexed runtime should not carry names or pointers in its active-state representation.

◆ same_trigger_v

template<typename From , typename Event , typename Transition >
constexpr bool tsm::core::same_trigger_v
inlineconstexpr
Initial value:
=
std::is_same_v<typename Transition::from, From> &&
std::is_same_v<typename Transition::event, Event>

◆ transition_list_like

template<typename TransitionList >
concept tsm::core::transition_list_like
Initial value:
=
tsm::detail::type_list_like<TransitionList> &&
tsm::detail::type_list_traits::all_satisfy<
tsm::detail::is_transition,
TransitionList>::value