fsm
Public Types | Public Member Functions | List of all members
escad::state_machine< States, Events, Context, Tracer > Class Template Reference

Public Types

using context_type = Context
 
using states_type = States
 
using events_type = Events
 
using tracer_type = Tracer
 

Public Member Functions

template<class T = Context, std::enable_if_t< std::is_constructible_v< T >, bool > = true>
 state_machine ()
 Creates a state machine. More...
 
template<class T = Context, std::enable_if_t< std::is_lvalue_reference_v< T >, bool > = true>
 state_machine (Context &ctx)
 Creates a state machine with a reference to a context. More...
 
template<class T = Context, std::enable_if_t<!std::is_lvalue_reference_v< T >, bool > = true>
 state_machine (Context &&ctx)
 
template<class S , class E , class C >
 state_machine (S, E, C &&ctx)
 Creates a state machine with a context. More...
 
 state_machine (States, Events, Context &ctx, Tracer &&tracer)
 Creates a state machine with a context and a tracer.
 
template<class E >
auto dispatch (E const &e)
 Dispatch an event to a current state.
 
template<class E >
auto dispatch (E const &e) const
 Dispatch an event to a current state.
 
auto & tracer ()
 Gets a reference to a tracer object.
 
auto const & tracer () const
 Gets a reference to a tracer object.
 
auto & context ()
 Gets a reference to a context.
 
auto const & context () const
 Gets a reference to a context.
 

Constructor & Destructor Documentation

◆ state_machine() [1/3]

template<class States , class Events , class Context , class Tracer = detail::NullTracer>
template<class T = Context, std::enable_if_t< std::is_constructible_v< T >, bool > = true>
escad::state_machine< States, Events, Context, Tracer >::state_machine ( )
inline

Creates a state machine.

All template parameters must by provided explicitly, Context will be created internally as regular data member.

◆ state_machine() [2/3]

template<class States , class Events , class Context , class Tracer = detail::NullTracer>
template<class T = Context, std::enable_if_t< std::is_lvalue_reference_v< T >, bool > = true>
escad::state_machine< States, Events, Context, Tracer >::state_machine ( Context ctx)
inline

Creates a state machine with a reference to a context.

This construct is to be used when user does not rely on CTAD and is providing all state_machine<> template arguments explicitly.

◆ state_machine() [3/3]

template<class States , class Events , class Context , class Tracer = detail::NullTracer>
template<class S , class E , class C >
escad::state_machine< States, Events, Context, Tracer >::state_machine ( ,
,
C &&  ctx 
)
inline

Creates a state machine with a context.

When using this constructor all class template arguments can be deduced automatically.


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