Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Events::FSM::FSM< DataType, StateType, TransitionType, Reactor > Class Template Reference

Generic Finite State Machine. More...

#include <fsm.hpp>

Inheritance diagram for Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >:

Public Member Functions

 FSM ()=delete
 
 FSM (const std::shared_ptr< DataType > &data_to_mutate, const StateType &begin_state, Subject *subject)
 Finite state machine constructor. More...
 
 FSM (const std::shared_ptr< DataType > &data_to_mutate, const StateType &begin_state, const StateType &end_state, Subject *subject)
 Finite state machine constructor for a terminated FSM. More...
 
void transition (const TransitionType transition_type)
 Sends a transition value to the FSM, causing the current state to react, and possible transition. More...
 
constexpr bool inFinalState () const noexcept
 Check to see if the FSM is in it's final state. More...
 
void start ()
 Starts the FSM. More...
 
void update (const double delta)
 Update is called once per update loop in the engine. More...
 
void stop ()
 Stops the FSM. More...
 

Detailed Description

template<typename DataType, typename StateType, typename TransitionType, typename... Reactor>
class Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >

Generic Finite State Machine.

Template Parameters
DataTypeThe Data to be mutated by this finite state machine.
StateTypeThe Enum that holds all possible states for the FSM.
TransitionTypeThe Enum that holds all possible transitions for the FSM.
ReactorVariadic. One reactor for each State in StateType

Constructor & Destructor Documentation

template<typename DataType , typename StateType , typename TransitionType , typename... Reactor>
Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >::FSM ( )
delete
template<typename DataType , typename StateType , typename TransitionType , typename... Reactor>
Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >::FSM ( const std::shared_ptr< DataType > &  data_to_mutate,
const StateType &  begin_state,
Subject subject 
)
inline

Finite state machine constructor.

Parameters
[in]data_to_mutateThe data to mutate
[in]subjectThe subject
[in]begin_stateThe begin state
template<typename DataType , typename StateType , typename TransitionType , typename... Reactor>
Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >::FSM ( const std::shared_ptr< DataType > &  data_to_mutate,
const StateType &  begin_state,
const StateType &  end_state,
Subject subject 
)
inline

Finite state machine constructor for a terminated FSM.

Parameters
[in]data_to_mutateThe data to mutate
[in]subjectThe subject
[in]begin_stateThe begin state
[in]end_stateThe end state

Member Function Documentation

template<typename DataType , typename StateType , typename TransitionType , typename... Reactor>
constexpr bool Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >::inFinalState ( ) const
inlinenoexcept

Check to see if the FSM is in it's final state.

Returns
Returns true if this is a terminated FSM and it is in its final state. False otherwise.
template<typename DataType , typename StateType , typename TransitionType , typename... Reactor>
void Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >::start ( )
inline

Starts the FSM.

template<typename DataType , typename StateType , typename TransitionType , typename... Reactor>
void Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >::stop ( )
inline

Stops the FSM.

template<typename DataType , typename StateType , typename TransitionType , typename... Reactor>
void Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >::transition ( const TransitionType  transition_type)
inline

Sends a transition value to the FSM, causing the current state to react, and possible transition.

Parameters
[in]transition_typeThe transition type

Referenced by Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >::update().

template<typename DataType , typename StateType , typename TransitionType , typename... Reactor>
void Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >::update ( const double  delta)
inline

Update is called once per update loop in the engine.

Parameters
[in]deltaThe frame delta

References Events::FSM::FSM< DataType, StateType, TransitionType, Reactor >::transition().


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