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

Class for state reactor. More...

#include <fsm.hpp>

Public Member Functions

 StateReactor ()=delete
 
 StateReactor (const StateType &state_type, const std::shared_ptr< DataType > &data_to_mutate, Subject *subject)
 StateReactor constructor. This sets which state this reactor is for and sets the data to be mutated. More...
 
constexpr StateType getStateType () const noexcept
 
virtual void enterState ()
 enterState is called upon triggering of this state More...
 
virtual bool updateState (const double delta, TransitionType &transition_type)
 updateState is called once per engine loop for timed updates More...
 
virtual void leaveState ()
 leaveState is called upon triggering of a new state from this state. More...
 
virtual StateType react (const TransitionType transition)
 This function is used to set up reactions for different types of transitions for this state. More...
 

Protected Attributes

std::shared_ptr< DataType > data
 
Subjectsubject
 
StateType state_type
 

Detailed Description

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

Class for state reactor.

Template Parameters
DataTypeThe type of data that will be mutated by the reactor.
StateTypeThe type of state used by the reactor and fsm.
TransitionTypeThe type of transitions used by the reactor and fsm.

Constructor & Destructor Documentation

template<class DataType, typename StateType, typename TransitionType>
Events::FSM::StateReactor< DataType, StateType, TransitionType >::StateReactor ( )
delete
template<class DataType, typename StateType, typename TransitionType>
Events::FSM::StateReactor< DataType, StateType, TransitionType >::StateReactor ( const StateType &  state_type,
const std::shared_ptr< DataType > &  data_to_mutate,
Subject subject 
)
inline

StateReactor constructor. This sets which state this reactor is for and sets the data to be mutated.

Parameters
[in]state_typeThe state type
[in]data_to_mutateThe data to mutate
[in]subjectThe subject

Member Function Documentation

template<class DataType, typename StateType, typename TransitionType>
virtual void Events::FSM::StateReactor< DataType, StateType, TransitionType >::enterState ( )
inlinevirtual
template<class DataType, typename StateType, typename TransitionType>
constexpr StateType Events::FSM::StateReactor< DataType, StateType, TransitionType >::getStateType ( ) const
inlinenoexcept
template<class DataType, typename StateType, typename TransitionType>
virtual void Events::FSM::StateReactor< DataType, StateType, TransitionType >::leaveState ( )
inlinevirtual

leaveState is called upon triggering of a new state from this state.

template<class DataType, typename StateType, typename TransitionType>
virtual StateType Events::FSM::StateReactor< DataType, StateType, TransitionType >::react ( const TransitionType  transition)
inlinevirtual

This function is used to set up reactions for different types of transitions for this state.

Parameters
[in]transitionThe transition type
Returns
The new state to transition into
template<class DataType, typename StateType, typename TransitionType>
virtual bool Events::FSM::StateReactor< DataType, StateType, TransitionType >::updateState ( const double  delta,
TransitionType &  transition_type 
)
inlinevirtual

updateState is called once per engine loop for timed updates

Parameters
[in]deltaThe frame delta
transition_typeAn optional output transition type
Returns
True if a new transition is provided, false otherwise

Member Data Documentation

template<class DataType, typename StateType, typename TransitionType>
std::shared_ptr<DataType> Events::FSM::StateReactor< DataType, StateType, TransitionType >::data
protected
template<class DataType, typename StateType, typename TransitionType>
StateType Events::FSM::StateReactor< DataType, StateType, TransitionType >::state_type
protected
template<class DataType, typename StateType, typename TransitionType>
Subject* Events::FSM::StateReactor< DataType, StateType, TransitionType >::subject
protected

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