DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Util::StateMachineState< CallableT, > Class Template Reference

State machine state as used by class StateMachine. A state mainly wraps a state function of the member function pointer type CallableT to be invoked by the state machine. More...

Public Types

using StateEnumType = return_of_t< CallableT >
 
using CallableType = CallableT
 

Public Member Functions

constexpr StateMachineState (StateEnumType State, CallableT StateFunction, const char *Description="", const bool IsFinal=false) noexcept
 Constructs a state machine state and assigns fixed parameters to it. More...
 
constexpr StateEnumType GetState () const noexcept
 Returns the state's unique identifier. More...
 
constexpr auto GetDescription () const noexcept
 Returns the state's description. More...
 
constexpr bool IsFinal () const noexcept
 Returns whether this is a final state. More...
 
template<typename... ArgTs>
StateEnumType Invoke (instance_of_t< CallableT > &Instance, ArgTs &&... Args) const
 Invokes the state function associated with this state on an instance of the class the state function is a member functions of. More...
 

Private Attributes

const StateEnumType State
 
const std::decay_t< CallableT > StateFunction
 
const char * Description
 
const bool Final
 For final states, it is ensured that the state's state function can delete the state machine. No memory assigned to the state machine will be accessed after the call to Invoke(). More...
 

Detailed Description

template<typename CallableT, std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
class Util::StateMachineState< CallableT, >

State machine state as used by class StateMachine. A state mainly wraps a state function of the member function pointer type CallableT to be invoked by the state machine.

Template Parameters
CallableTType of the state function associated with the state machine state. The state function is expected to be a member function of the class also managing the state machine. It can accept an arbitrary amount of arguments (such as a reference to DynExp::ModuleInstance). Furthermore, it is expected to return a value of type StateEnumType as the identifier of the next state machine state. StateEnumType is an enum class type of elements being identifiers of all states associated with a state machine.

Definition at line 1304 of file Util.h.

Member Typedef Documentation

◆ CallableType

template<typename CallableT , std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
using Util::StateMachineState< CallableT, >::CallableType = CallableT

Definition at line 1308 of file Util.h.

◆ StateEnumType

template<typename CallableT , std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
using Util::StateMachineState< CallableT, >::StateEnumType = return_of_t<CallableT>

Definition at line 1307 of file Util.h.

Constructor & Destructor Documentation

◆ StateMachineState()

template<typename CallableT , std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
constexpr Util::StateMachineState< CallableT, >::StateMachineState ( StateEnumType  State,
CallableT  StateFunction,
const char *  Description = "",
const bool  IsFinal = false 
)
inlineconstexprnoexcept

Constructs a state machine state and assigns fixed parameters to it.

Parameters
StateUnique identifier of the state
StateFunctionFunction pointer to the state's state function
DescriptionHuman-readable description of what the state does
IsFinalIndicates whether this is a final state. Refer to field StateMachineState::Final.

Definition at line 1317 of file Util.h.

Member Function Documentation

◆ GetDescription()

template<typename CallableT , std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
constexpr auto Util::StateMachineState< CallableT, >::GetDescription ( ) const
inlineconstexprnoexcept

Returns the state's description.

Definition at line 1322 of file Util.h.

◆ GetState()

template<typename CallableT , std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
constexpr StateEnumType Util::StateMachineState< CallableT, >::GetState ( ) const
inlineconstexprnoexcept

Returns the state's unique identifier.

Definition at line 1321 of file Util.h.

◆ Invoke()

template<typename CallableT , std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
template<typename... ArgTs>
StateEnumType Util::StateMachineState< CallableT, >::Invoke ( instance_of_t< CallableT > &  Instance,
ArgTs &&...  Args 
) const
inline

Invokes the state function associated with this state on an instance of the class the state function is a member functions of.

Template Parameters
...ArgTsType of the parameter pack to forward to the state function
Parameters
InstanceInstance to invoke the state function on
...ArgsParameters to forward to the state function
Returns
Returns the identifer of the next state machine state to transition into.

Definition at line 1334 of file Util.h.

◆ IsFinal()

template<typename CallableT , std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
constexpr bool Util::StateMachineState< CallableT, >::IsFinal ( ) const
inlineconstexprnoexcept

Returns whether this is a final state.

Definition at line 1323 of file Util.h.

Member Data Documentation

◆ Description

template<typename CallableT , std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
const char* Util::StateMachineState< CallableT, >::Description
private

Definition at line 1342 of file Util.h.

◆ Final

template<typename CallableT , std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
const bool Util::StateMachineState< CallableT, >::Final
private

For final states, it is ensured that the state's state function can delete the state machine. No memory assigned to the state machine will be accessed after the call to Invoke().

Definition at line 1348 of file Util.h.

◆ State

template<typename CallableT , std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
const StateEnumType Util::StateMachineState< CallableT, >::State
private

Definition at line 1340 of file Util.h.

◆ StateFunction

template<typename CallableT , std::enable_if_t< std::is_enum_v< return_of_t< CallableT >>, int > = 0>
const std::decay_t<CallableT> Util::StateMachineState< CallableT, >::StateFunction
private

Definition at line 1341 of file Util.h.


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