Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::fsm::StateMachine< Table, InitialState, OtherStates > Class Template Reference

Zero-heap, compile-time Finite State Machine. More...

#include <StateMachine.hpp>

+ Collaboration diagram for corium::fsm::StateMachine< Table, InitialState, OtherStates >:

Public Types

using StateVariant = std::variant< InitialState, OtherStates... >
 
using TransitionTableType = Table
 

Public Member Functions

template<typename State >
constexpr State & as ()
 Access reference to current state as type State (throws std::bad_variant_access if mismatch).
 
template<typename State >
constexpr const State & as () const
 Access const reference to current state as type State.
 
template<typename State >
constexpr bool is () const noexcept
 Check if current active state matches type State.
 
template<typename Event >
bool process_event (const Event &event)
 Process an incoming event through the state machine transition table.
 
constexpr const StateVariantstate () const noexcept
 Access active state variant.
 
constexpr StateVariantstate () noexcept
 Access active state variant.
 
constexpr StateMachine ()
 
template<typename State >
requires (std::is_constructible_v<StateVariant, State>)
constexpr StateMachine (State &&initial)
 

Detailed Description

template<typename Table, typename InitialState, typename... OtherStates>
class corium::fsm::StateMachine< Table, InitialState, OtherStates >

Zero-heap, compile-time Finite State Machine.

Template Parameters
TableTransitionTable defining valid state transitions.
InitialStateDefault initial active state.
OtherStatesAdditional valid states in the FSM state set.

Member Typedef Documentation

◆ StateVariant

template<typename Table , typename InitialState , typename... OtherStates>
using corium::fsm::StateMachine< Table, InitialState, OtherStates >::StateVariant = std::variant<InitialState, OtherStates...>

◆ TransitionTableType

template<typename Table , typename InitialState , typename... OtherStates>
using corium::fsm::StateMachine< Table, InitialState, OtherStates >::TransitionTableType = Table

Constructor & Destructor Documentation

◆ StateMachine() [1/2]

template<typename Table , typename InitialState , typename... OtherStates>
constexpr corium::fsm::StateMachine< Table, InitialState, OtherStates >::StateMachine ( )
inlineconstexpr
+ Here is the call graph for this function:

◆ StateMachine() [2/2]

template<typename Table , typename InitialState , typename... OtherStates>
template<typename State >
requires (std::is_constructible_v<StateVariant, State>)
constexpr corium::fsm::StateMachine< Table, InitialState, OtherStates >::StateMachine ( State &&  initial)
inlineexplicitconstexpr
+ Here is the call graph for this function:

Member Function Documentation

◆ as() [1/2]

template<typename Table , typename InitialState , typename... OtherStates>
template<typename State >
constexpr State & corium::fsm::StateMachine< Table, InitialState, OtherStates >::as ( )
inlineconstexpr

Access reference to current state as type State (throws std::bad_variant_access if mismatch).

◆ as() [2/2]

template<typename Table , typename InitialState , typename... OtherStates>
template<typename State >
constexpr const State & corium::fsm::StateMachine< Table, InitialState, OtherStates >::as ( ) const
inlineconstexpr

Access const reference to current state as type State.

◆ is()

template<typename Table , typename InitialState , typename... OtherStates>
template<typename State >
constexpr bool corium::fsm::StateMachine< Table, InitialState, OtherStates >::is ( ) const
inlineconstexprnoexcept

Check if current active state matches type State.

◆ process_event()

template<typename Table , typename InitialState , typename... OtherStates>
template<typename Event >
bool corium::fsm::StateMachine< Table, InitialState, OtherStates >::process_event ( const Event event)
inline

Process an incoming event through the state machine transition table.

Template Parameters
EventTrigger event type.
Parameters
eventEvent instance to evaluate.
Returns
true if a transition was matched and executed; false if no transition applied.

◆ state() [1/2]

template<typename Table , typename InitialState , typename... OtherStates>
constexpr const StateVariant & corium::fsm::StateMachine< Table, InitialState, OtherStates >::state ( ) const
inlineconstexprnoexcept

Access active state variant.

◆ state() [2/2]

template<typename Table , typename InitialState , typename... OtherStates>
constexpr StateVariant & corium::fsm::StateMachine< Table, InitialState, OtherStates >::state ( )
inlineconstexprnoexcept

Access active state variant.


The documentation for this class was generated from the following file: