3 #include <machine/FSM/simpleFiniteStateMachine.h>
4 #include <transition/FSM/simpleFiniteStateMachineTransition.h>
49 using typename SimpleFiniteStateMachine_::StateType;
50 using typename SimpleFiniteStateMachine_::SymbolType;
51 using typename SimpleFiniteStateMachine_::IsAccepting;
52 using typename SimpleFiniteStateMachine_::StorageType;
53 using typename SimpleFiniteStateMachine_::IsAlternating;
54 using typename SimpleFiniteStateMachine_::TransitionType;
55 using typename SimpleFiniteStateMachine_::ApplyHelperType;
56 using typename SimpleFiniteStateMachine_::IsDeterministic;
57 using typename SimpleFiniteStateMachine_::TransitionContainer;
58 using typename SimpleFiniteStateMachine_::InitialStateContainer;
59 using typename SimpleFiniteStateMachine_::OptionalHelpedTransition;
61 static_assert(std::is_same_v<StateType, typename TransitionType::StateType>);
62 static_assert(std::is_same_v<StorageType, typename TransitionType::StorageType>);
63 static_assert(std::is_same_v<TransitionType, TransitionType_>);
64 static_assert(std::is_same_v<ApplyHelperType, typename TransitionType::ApplyHelperType>);
65 static_assert(std::is_same_v<ApplyHelperType, std::monostate>);
66 static_assert(std::is_same_v<IsDeterministic, std::true_type>);
67 static_assert(std::is_same_v<TransitionContainer, std::set<std::pair<const TransitionType&, ApplyHelperType>>>);
68 static_assert(std::is_same_v<InitialStateContainer, std::set<StateType>>);
69 static_assert(std::is_same_v<OptionalHelpedTransition, std::optional<std::pair<const TransitionType&, ApplyHelperType>>>);
72 "StorageType should be a word.");
73 static_assert(std::is_same_v<TransitionType_, TransitionType>,
74 "TransitionType must be SimpleFiniteStateMachineTransition");
76 "The only valid value for AcceptingConstructorArgs is the default parameter.");
87 const StateType& initialState,
88 const std::vector<TransitionType>& transitions,
92 initialState(initialState),
95 for(
const TransitionType& transition: transitions) {
96 this->transitions[transition.getPreState()].insert({transition.getPreLetter(), transition});
141 return {{transitions.at(state).at(letter.value()), std::monostate()}};
143 catch(std::out_of_range) {
144 return {std::nullopt};
146 catch(std::bad_optional_access) {
147 return {std::nullopt};
158 std::map<StateType, std::map<SymbolType, TransitionType>>
transitions;