TuringSim
C++ framework to simulate abstract computing models
statePattern.h
1 #pragma once
2 
3 #include <optional>
4 
8 namespace TuringSim::State {
14  template <typename StateType_, typename MatcherType_>
15  class StatePattern {
16  public:
20  typedef StateType_ StateType;
21 
25  typedef MatcherType_ MatcherType;
26 
29  constexpr StatePattern() = default;
30 
34  constexpr StatePattern(const StatePattern& other) = default;
35 
39  constexpr StatePattern(StatePattern&& other) = default;
40 
45  constexpr StatePattern& operator=(const StatePattern& other) = default;
46 
51  constexpr StatePattern& operator=(StatePattern&& other) = default;
52 
55  virtual ~StatePattern() = default;
56 
61  virtual std::optional<MatcherType> match(const StateType& state) const noexcept = 0;
62  };
63 }
TuringSim::State::StatePattern::MatcherType
MatcherType_ MatcherType
The type returned when a state matches the pattern.
Definition: statePattern.h:25
TuringSim::State::StatePattern::StatePattern
constexpr StatePattern(StatePattern &&other)=default
Move a state pattern.
TuringSim::State::StatePattern::match
virtual std::optional< MatcherType > match(const StateType &state) const noexcept=0
Test if a state matches.
TuringSim::State::StatePattern::~StatePattern
virtual ~StatePattern()=default
Destructor.
TuringSim::State::StatePattern::operator=
constexpr StatePattern & operator=(StatePattern &&other)=default
Move a state pattern.
TuringSim::State::StatePattern::StatePattern
constexpr StatePattern()=default
Default constructor.
TuringSim::State::StatePattern
The base class of all state patterns.
Definition: statePattern.h:15
TuringSim::State::StatePattern::StatePattern
constexpr StatePattern(const StatePattern &other)=default
Copy a state pattern.
TuringSim::State::StatePattern::operator=
constexpr StatePattern & operator=(const StatePattern &other)=default
Copy a state pattern.
TuringSim::State::StatePattern::StateType
StateType_ StateType
The type of states matched.
Definition: statePattern.h:20
TuringSim::State
The namespace for states and state patterns.