fsm
Public Types | Public Member Functions | Protected Attributes | List of all members
escad::new_fsm::state< Derived, Context > Struct Template Reference

state is a CRTP base class for states. More...

#include <state.h>

Inheritance diagram for escad::new_fsm::state< Derived, Context >:
Inheritance graph
[legend]
Collaboration diagram for escad::new_fsm::state< Derived, Context >:
Collaboration graph
[legend]

Public Types

using ctx = Context
 

Public Member Functions

 state (Context &context)
 
template<class Target = Derived, class Event >
bool enter (const Event &event)
 Calls onEnter(const Event &event) of Derived if it exists. More...
 
template<class Target = Derived>
bool enter ()
 Calls onEnter() of Derived if it exists. More...
 
template<class Target = Derived>
bool exit ()
 
template<class Target = Derived, class Event >
auto transition (const Event &event) -> decltype(std::declval< Target >().transitionTo(event))
 Calls transitionTo(const Event &event) of Derived if it exists. More...
 
template<class Target = Derived>
auto transition (...) -> transitions< detail::none >
 For non-existing transitionTo() methods. More...
 
template<class Target = Derived>
auto transitionInternal () -> decltype(std::declval< Target >().transitionInternalTo())
 Calls transitionInternalTo() of Derived if it exists. More...
 
template<class Event >
bool dispatch (const Event &)
 
const Contextcontext ()
 

Protected Attributes

Contextcontext_
 Reference to the Context.
 

Detailed Description

template<class Derived, class Context = detail::NoContext>
struct escad::new_fsm::state< Derived, Context >

state is a CRTP base class for states.

Template Parameters
Derived
StateContainer

Member Function Documentation

◆ enter() [1/2]

template<class Derived, class Context = detail::NoContext>
template<class Target = Derived, class Event >
bool escad::new_fsm::state< Derived, Context >::enter ( const Event &  event)
inline

Calls onEnter(const Event &event) of Derived if it exists.

Template Parameters
TargetThe Derived type.
EventThe Event type.
Parameters
eventThe event object.
Returns
decltype(std::declval<Target>().onEnter(event), void())

◆ enter() [2/2]

template<class Derived, class Context = detail::NoContext>
template<class Target = Derived>
bool escad::new_fsm::state< Derived, Context >::enter ( )
inline

Calls onEnter() of Derived if it exists.

Template Parameters
TargetThe Derived type.
Returns
decltype(std::declval<Target>().onEnter(), void())
See also
https://arne-mertz.de/2017/01/decltype-declval/

◆ transition() [1/2]

template<class Derived, class Context = detail::NoContext>
template<class Target = Derived, class Event >
auto escad::new_fsm::state< Derived, Context >::transition ( const Event &  event) -> decltype(std::declval<Target>().transitionTo(event))
inline

Calls transitionTo(const Event &event) of Derived if it exists.

Template Parameters
TargetThe Derived type.
EventThe Event type.
Parameters
eventThe event object.
Returns
decltype(std::declval<Target>().transitionTo(event))

◆ transition() [2/2]

template<class Derived, class Context = detail::NoContext>
template<class Target = Derived>
auto escad::new_fsm::state< Derived, Context >::transition (   ...) -> transitions<detail::none>
inline

For non-existing transitionTo() methods.

Template Parameters
TargetThe Derived type.
Parameters
...
Returns
transitions<detail::not_handled>

◆ transitionInternal()

template<class Derived, class Context = detail::NoContext>
template<class Target = Derived>
auto escad::new_fsm::state< Derived, Context >::transitionInternal ( ) -> decltype(std::declval<Target>().transitionInternalTo())
inline

Calls transitionInternalTo() of Derived if it exists.

Template Parameters
TargetThe Derived type.
Returns
decltype(std::declval<Target>().transitionTo())

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