fsm
Classes | Variables
state.h File Reference

This file contains the definition of the state class and related helper templates. More...

#include <optional>
#include <type_traits>
#include "../base/type_traits.h"
#include "transition.h"
Include dependency graph for state.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  escad::new_fsm::detail::NoContext
 
struct  escad::new_fsm::detail::InternalEvent
 
struct  escad::new_fsm::detail::has_onEnter< Target, typename >
 Default case of helper for detecting if type Target has a onEnter() method. More...
 
struct  escad::new_fsm::detail::has_onEnter< Target, std::void_t< decltype(std::declval< Target >().onEnter())> >
 Specialization for detecting if type Target has a onEnter() method. More...
 
struct  escad::new_fsm::detail::has_onEnterWithEvent< Target, Event, typename >
 Default case of helper for detecting if type Target has a onEnter(const Event &) method. More...
 
struct  escad::new_fsm::detail::has_onEnterWithEvent< Target, Event, std::void_t< decltype(std::declval< Target >().onEnter(std::declval< Event >()))> >
 Specialization for detecting if type Target has a onEnter(const Event &) method. More...
 
struct  escad::new_fsm::detail::has_onExit< Target, typename >
 
struct  escad::new_fsm::detail::has_onExit< Target, std::void_t< decltype(std::declval< Target >().onExit())> >
 
struct  escad::new_fsm::detail::has_transitionTo< Target, Event, typename >
 Default case of helper for detecting if type Target has a transitionTo(const Event &) method. More...
 
struct  escad::new_fsm::detail::has_transitionTo< Target, Event, std::void_t< decltype(std::declval< Target >().transitionTo(std::declval< Event >()))> >
 Specialization for detecting if type Target has a transitionTo(const Event &) method. More...
 
struct  escad::new_fsm::detail::has_transitionInternalTo< Target, typename >
 
struct  escad::new_fsm::detail::has_transitionInternalTo< Target, std::void_t< decltype(std::declval< Target >().transitionInternalTo())> >
 
struct  escad::new_fsm::states< S >
 Defines a set of states. More...
 
struct  escad::new_fsm::state< Derived, Context >
 state is a CRTP base class for states. More...
 

Variables

template<class T >
constexpr bool escad::new_fsm::detail::has_onEnter_v = has_onEnter<T>::value
 Helper helper template to access the value of has_onEnter. More...
 
template<class T , class E >
constexpr bool escad::new_fsm::detail::has_onEnterWithEvent_v
 Helper helper template to access the value of has_onEnterWithEvent. More...
 
template<class T >
constexpr bool escad::new_fsm::detail::has_onExit_v = has_onExit<T>::value
 
template<class T , class E >
constexpr bool escad::new_fsm::detail::has_transitionTo_v = has_transitionTo<T, E>::value
 Helper helper template to access the value of has_transitionTo. More...
 
template<class T >
constexpr bool escad::new_fsm::detail::has_transitionInternalTo_v
 

Detailed Description

This file contains the definition of the state class and related helper templates.

Defines the state class and helper templates for state management in a finite state machine.

The state class is a CRTP (Curiously Recurring Template Pattern) base class for states in a finite state machine. It provides methods for handling state entry, event dispatching, and state transitions. The helper templates in this file are used for detecting if a state has specific methods, such as onEnter() and transitionTo(). This file is part of the FSM (Finite State Machine) library.

Author
Martin Heubuch (marti.nosp@m.n.he.nosp@m.ubuch.nosp@m.@esc.nosp@m.ad.de)
Version
0.1
Date
2023-02-23

This file contains the implementation of the state class, which is a CRTP (Curiously Recurring Template Pattern) base class for states in a finite state machine. It also includes helper templates for detecting the presence of certain methods in derived state classes.

The state class provides methods for handling state entry, event dispatching, and state transitions. It uses SFINAE (Substitution Failure Is Not An Error) and type traits to conditionally call methods based on their existence in the derived state class.

The helper templates in the details namespace are used to detect the presence of the following methods in the derived state class:

The state class also includes a handle_result() method for handling the result of state transitions and a dispatch() method for dispatching events to the state.

This file is part of the new_fsm namespace.

Variable Documentation

◆ has_onEnter_v

template<class T >
constexpr bool escad::new_fsm::detail::has_onEnter_v = has_onEnter<T>::value
inline

Helper helper template to access the value of has_onEnter.

Template Parameters
TThe type to check for the presence of onEnter() method.

◆ has_onEnterWithEvent_v

template<class T , class E >
constexpr bool escad::new_fsm::detail::has_onEnterWithEvent_v
inline
Initial value:
=
has_onEnterWithEvent<T, E>::value

Helper helper template to access the value of has_onEnterWithEvent.

Template Parameters
TThe type to check for the presence of onEnter(const Event &) method.
EThe event type.

◆ has_transitionInternalTo_v

template<class T >
constexpr bool escad::new_fsm::detail::has_transitionInternalTo_v
inline
Initial value:
=
has_transitionInternalTo<T>::value

◆ has_transitionTo_v

template<class T , class E >
constexpr bool escad::new_fsm::detail::has_transitionTo_v = has_transitionTo<T, E>::value
inline

Helper helper template to access the value of has_transitionTo.

Template Parameters
TThe type to check for the presence of transitionTo(const Event &) method.
EThe event type.