TuringSim
C++ framework to simulate abstract computing models
Public Member Functions | List of all members
TuringSim::State::SimpleStatePattern< T > Class Template Reference

A simple explicit state pattern. More...

#include <state/simpleStatePattern.h>

Inheritance diagram for TuringSim::State::SimpleStatePattern< T >:
Inheritance graph
[legend]
Collaboration diagram for TuringSim::State::SimpleStatePattern< T >:
Collaboration graph
[legend]

Public Member Functions

constexpr SimpleStatePattern (const T &acceptedState)
 Construct a simple configuration from the letter in parameter. More...
 
constexpr SimpleStatePattern (const SimpleStatePattern &other)
 Copy a state pattern. More...
 
constexpr SimpleStatePattern (SimpleStatePattern &&other)
 Move a state pattern. More...
 
constexpr SimpleStatePatternoperator= (const SimpleStatePattern &other)
 Copy a state pattern. More...
 
constexpr SimpleStatePatternoperator= (SimpleStatePattern &&other)
 Move a state pattern. More...
 
virtual ~SimpleStatePattern () override=default
 Destructor.
 
constexpr const T & getState () const
 get the accepting state More...
 
virtual std::optional< MatcherTypematch (const T &state) const noexcept override
 Test if a state matches. More...
 
bool operator< (const SimpleStatePattern< T > &other) const
 Total ordering of SimpleStatePattern. More...
 
- Public Member Functions inherited from TuringSim::State::StatePattern< T, std::monostate >
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.
 

Additional Inherited Members

- Public Types inherited from TuringSim::State::StatePattern< T, std::monostate >
typedef T StateType
 The type of states matched.
 
typedef std::monostate MatcherType
 The type returned when a state matches the pattern.
 

Detailed Description

template<typename T>
class TuringSim::State::SimpleStatePattern< T >

A simple explicit state pattern.

Template Parameters
TThe type of the state

Such a pattern accept a single explicit state.

Definition at line 15 of file simpleStatePattern.h.

Constructor & Destructor Documentation

◆ SimpleStatePattern() [1/3]

template<typename T >
constexpr TuringSim::State::SimpleStatePattern< T >::SimpleStatePattern ( const T &  acceptedState)
inlineconstexpr

Construct a simple configuration from the letter in parameter.

Parameters
[in]acceptedStatethe only state to accept.

Definition at line 27 of file simpleStatePattern.h.

◆ SimpleStatePattern() [2/3]

template<typename T >
constexpr TuringSim::State::SimpleStatePattern< T >::SimpleStatePattern ( const SimpleStatePattern< T > &  other)
inlineconstexpr

Copy a state pattern.

Parameters
[in]otherthe state pattern to copy.

Definition at line 35 of file simpleStatePattern.h.

◆ SimpleStatePattern() [3/3]

template<typename T >
constexpr TuringSim::State::SimpleStatePattern< T >::SimpleStatePattern ( SimpleStatePattern< T > &&  other)
inlineconstexpr

Move a state pattern.

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

Definition at line 43 of file simpleStatePattern.h.

Member Function Documentation

◆ getState()

template<typename T >
constexpr const T& TuringSim::State::SimpleStatePattern< T >::getState ( ) const
inlineconstexpr

get the accepting state

Returns
a const reference to the accepted state.

This function is useful for optimized containers. See TuringSim::Machine::SimpleTuringMachine and derived classes.

Definition at line 82 of file simpleStatePattern.h.

Here is the caller graph for this function:

◆ match()

template<typename T >
virtual std::optional<MatcherType> TuringSim::State::SimpleStatePattern< T >::match ( const T &  state) const
inlineoverridevirtualnoexcept

Test if a state matches.

Parameters
[in]stateThe state to match.
Returns
an empty option if the state is different from the accepted state. If they are equal, std::monostate is returned.

Implements TuringSim::State::StatePattern< T, std::monostate >.

Definition at line 90 of file simpleStatePattern.h.

Here is the caller graph for this function:

◆ operator<()

template<typename T >
bool TuringSim::State::SimpleStatePattern< T >::operator< ( const SimpleStatePattern< T > &  other) const
inline

Total ordering of SimpleStatePattern.

Parameters
[in]otherthe other SimpleStatePattern to compare with.
Returns
whether *this < other.

Definition at line 101 of file simpleStatePattern.h.

◆ operator=() [1/2]

template<typename T >
constexpr SimpleStatePattern& TuringSim::State::SimpleStatePattern< T >::operator= ( const SimpleStatePattern< T > &  other)
inlineconstexpr

Copy a state pattern.

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

Definition at line 52 of file simpleStatePattern.h.

◆ operator=() [2/2]

template<typename T >
constexpr SimpleStatePattern& TuringSim::State::SimpleStatePattern< T >::operator= ( SimpleStatePattern< T > &&  other)
inlineconstexpr

Move a state pattern.

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

Definition at line 64 of file simpleStatePattern.h.


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