TuringSim
C++ framework to simulate abstract computing models
Public Types | Public Member Functions | List of all members
TuringSim::State::StatePattern< StateType_, MatcherType_ > Class Template Referenceabstract

The base class of all state patterns. More...

#include <state/statePattern.h>

Public Types

typedef StateType_ StateType
 The type of states matched.
 
typedef MatcherType_ MatcherType
 The type returned when a state matches the pattern.
 

Public Member Functions

constexpr StatePattern ()=default
 Default constructor.
 
constexpr StatePattern (const StatePattern &other)=default
 Copy a state pattern. More...
 
constexpr StatePattern (StatePattern &&other)=default
 Move a state pattern. More...
 
constexpr StatePatternoperator= (const StatePattern &other)=default
 Copy a state pattern. More...
 
constexpr StatePatternoperator= (StatePattern &&other)=default
 Move a state pattern. More...
 
virtual ~StatePattern ()=default
 Destructor.
 
virtual std::optional< MatcherTypematch (const StateType &state) const noexcept=0
 Test if a state matches. More...
 

Detailed Description

template<typename StateType_, typename MatcherType_>
class TuringSim::State::StatePattern< StateType_, MatcherType_ >

The base class of all state patterns.

Template Parameters
StateType_The type of matched states.
MatcherType_The type returned when a state matches the pattern, and helps the transition.

Definition at line 15 of file statePattern.h.

Constructor & Destructor Documentation

◆ StatePattern() [1/2]

template<typename StateType_ , typename MatcherType_ >
constexpr TuringSim::State::StatePattern< StateType_, MatcherType_ >::StatePattern ( const StatePattern< StateType_, MatcherType_ > &  other)
constexprdefault

Copy a state pattern.

Parameters
[in]otherthe state pattern to copy.

◆ StatePattern() [2/2]

template<typename StateType_ , typename MatcherType_ >
constexpr TuringSim::State::StatePattern< StateType_, MatcherType_ >::StatePattern ( StatePattern< StateType_, MatcherType_ > &&  other)
constexprdefault

Move a state pattern.

Parameters
[in,out]otherthe state pattern to move.

Member Function Documentation

◆ match()

template<typename StateType_ , typename MatcherType_ >
virtual std::optional<MatcherType> TuringSim::State::StatePattern< StateType_, MatcherType_ >::match ( const StateType state) const
pure virtualnoexcept

Test if a state matches.

Parameters
[in]stateThe state to match.
Returns
an empty option if the state does not match, otherwise, a MatcherType the transition may use.

Implemented in TuringSim::State::SimpleStatePattern< T >, and TuringSim::State::SimpleStatePattern< StateType >.

◆ operator=() [1/2]

template<typename StateType_ , typename MatcherType_ >
constexpr StatePattern& TuringSim::State::StatePattern< StateType_, MatcherType_ >::operator= ( const StatePattern< StateType_, MatcherType_ > &  other)
constexprdefault

Copy a state pattern.

Parameters
[in]otherthe state pattern to copy.
Returns
a reference to *this.

◆ operator=() [2/2]

template<typename StateType_ , typename MatcherType_ >
constexpr StatePattern& TuringSim::State::StatePattern< StateType_, MatcherType_ >::operator= ( StatePattern< StateType_, MatcherType_ > &&  other)
constexprdefault

Move a state pattern.

Parameters
[in,out]otherthe state pattern to move.
Returns
a reference to *this.

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