From 245c0b2359aa556e877b9007f0af19c0b132930b Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Fri, 29 Jul 2016 21:36:31 +0200 Subject: [PATCH] update remaining automata to components2 --- alib2data/src/automaton/TA/DFTA.cpp | 85 ++++++------ alib2data/src/automaton/TA/DFTA.h | 4 +- alib2data/src/automaton/TA/NFTA.cpp | 87 ++++++------ alib2data/src/automaton/TA/NFTA.h | 4 +- alib2data/src/automaton/TM/OneTapeDTM.cpp | 162 ++++++++++------------ alib2data/src/automaton/TM/OneTapeDTM.h | 4 +- 6 files changed, 166 insertions(+), 180 deletions(-) diff --git a/alib2data/src/automaton/TA/DFTA.cpp b/alib2data/src/automaton/TA/DFTA.cpp index ce461570ef..c0eb0a32f3 100644 --- a/alib2data/src/automaton/TA/DFTA.cpp +++ b/alib2data/src/automaton/TA/DFTA.cpp @@ -19,7 +19,7 @@ namespace automaton { -DFTA::DFTA ( std::set < State > states, std::set < alphabet::RankedSymbol > inputAlphabet, std::set < State > finalStates ) : std::Components < DFTA, alphabet::RankedSymbol, std::tuple < InputAlphabet >, std::tuple < >, automaton::State, std::tuple < States, FinalStates >, std::tuple < > > ( std::make_tuple ( std::move ( inputAlphabet ) ), std::tuple < > ( ), std::make_tuple ( std::move ( states ), std::move ( finalStates ) ), std::tuple < > ( ) ) { +DFTA::DFTA ( std::set < State > states, std::set < alphabet::RankedSymbol > inputAlphabet, std::set < State > finalStates ) : std::Components2 < DFTA, alphabet::RankedSymbol, std::tuple < InputAlphabet >, std::tuple < >, automaton::State, std::tuple < States, FinalStates >, std::tuple < > > ( std::make_tuple ( std::move ( inputAlphabet ) ), std::tuple < > ( ), std::make_tuple ( std::move ( states ), std::move ( finalStates ) ), std::tuple < > ( ) ) { } DFTA::DFTA() : DFTA ( std::set < State > { }, std::set < alphabet::RankedSymbol > { }, std::set < State > { } ) { @@ -155,63 +155,60 @@ void DFTA::composeTransitions(std::deque<sax::Token>& out) const { namespace std { template < > -bool automaton::DFTA::Component < automaton::DFTA, alphabet::RankedSymbol, automaton::InputAlphabet >::used ( const alphabet::RankedSymbol & symbol ) const { - const automaton::DFTA * automaton = static_cast < const automaton::DFTA * > ( this ); +class ComponentConstraint2< automaton::DFTA, alphabet::RankedSymbol, automaton::InputAlphabet > { +public: + static bool used ( const automaton::DFTA & automaton, const alphabet::RankedSymbol & symbol ) { + for (const std::pair<const std::pair<alphabet::RankedSymbol, std::vector<automaton::State> >, automaton::State>& t : automaton.getTransitions()) + if (t.first.first == symbol) + return true; - for (const std::pair<const std::pair<alphabet::RankedSymbol, std::vector<automaton::State> >, automaton::State>& t : automaton->getTransitions()) - if (t.first.first == symbol) - return true; - - return false; -} + return false; + } -template < > -bool automaton::DFTA::Component < automaton::DFTA, alphabet::RankedSymbol, automaton::InputAlphabet >::available ( const alphabet::RankedSymbol & ) const { - return true; -} + static bool available ( const automaton::DFTA &, const alphabet::RankedSymbol & ) { + return true; + } -template < > -void automaton::DFTA::Component < automaton::DFTA, alphabet::RankedSymbol, automaton::InputAlphabet >::valid ( const alphabet::RankedSymbol & ) const { -} + static void valid ( const automaton::DFTA &, const alphabet::RankedSymbol & ) { + } +}; template < > -bool automaton::DFTA::Component < automaton::DFTA, automaton::State, automaton::States >::used ( const automaton::State & state ) const { - const automaton::DFTA * automaton = static_cast < const automaton::DFTA * > ( this ); - - if ( automaton->getFinalStates ( ).count ( state ) ) - return true; - - for (const std::pair<const std::pair<alphabet::RankedSymbol, std::vector<automaton::State> >, automaton::State>& t : automaton->getTransitions()) - if(std::contains(t.first.second.begin(), t.first.second.end(), state ) || t.second == state) +class ComponentConstraint2< automaton::DFTA, automaton::State, automaton::States > { +public: + static bool used ( const automaton::DFTA & automaton, const automaton::State & state ) { + if ( automaton.getFinalStates ( ).count ( state ) ) return true; - return false; -} + for (const std::pair<const std::pair<alphabet::RankedSymbol, std::vector<automaton::State> >, automaton::State>& t : automaton.getTransitions()) + if(std::contains(t.first.second.begin(), t.first.second.end(), state ) || t.second == state) + return true; -template < > -bool automaton::DFTA::Component < automaton::DFTA, automaton::State, automaton::States >::available ( const automaton::State & ) const { - return true; -} + return false; + } -template < > -void automaton::DFTA::Component < automaton::DFTA, automaton::State, automaton::States >::valid ( const automaton::State & ) const { -} + static bool available ( const automaton::DFTA &, const automaton::State & ) { + return true; + } -template < > -bool automaton::DFTA::Component < automaton::DFTA, automaton::State, automaton::FinalStates >::used ( const automaton::State & ) const { - return false; -} + static void valid ( const automaton::DFTA &, const automaton::State & ) { + } +}; template < > -bool automaton::DFTA::Component < automaton::DFTA, automaton::State, automaton::FinalStates >::available ( const automaton::State & state ) const { - const automaton::DFTA * automaton = static_cast < const automaton::DFTA * > ( this ); +class ComponentConstraint2< automaton::DFTA, automaton::State, automaton::FinalStates > { +public: + static bool used ( const automaton::DFTA &, const automaton::State & ) { + return false; + } - return automaton->accessComponent < automaton::States > ( ).get ( ).count ( state ); -} + static bool available ( const automaton::DFTA & automaton, const automaton::State & state ) { + return automaton.accessComponent < automaton::States > ( ).get ( ).count ( state ); + } -template < > -void automaton::DFTA::Component < automaton::DFTA, automaton::State, automaton::FinalStates >::valid ( const automaton::State & ) const { -} + static void valid ( const automaton::DFTA &, const automaton::State & ) { + } +}; } /* namespace std */ diff --git a/alib2data/src/automaton/TA/DFTA.h b/alib2data/src/automaton/TA/DFTA.h index 9f313cfca7..93d2cfd123 100644 --- a/alib2data/src/automaton/TA/DFTA.h +++ b/alib2data/src/automaton/TA/DFTA.h @@ -10,7 +10,7 @@ #include <map> #include <vector> -#include <core/components.hpp> +#include <core/components2.hpp> #include "../AutomatonBase.h" #include "../common/State.h" #include "../../alphabet/RankedSymbol.h" @@ -25,7 +25,7 @@ class FinalStates; * Represents Finite Tree Automaton. * Can store nondeterministic finite automaton without epsilon transitions. */ -class DFTA : public AutomatonBase, public std::Components < DFTA, alphabet::RankedSymbol, std::tuple < InputAlphabet >, std::tuple < >, automaton::State, std::tuple < States, FinalStates >, std::tuple < > > { +class DFTA : public AutomatonBase, public std::Components2 < DFTA, alphabet::RankedSymbol, std::tuple < InputAlphabet >, std::tuple < >, automaton::State, std::tuple < States, FinalStates >, std::tuple < > > { std::map < std::pair < alphabet::RankedSymbol, std::vector < State > >, State > transitions; public: diff --git a/alib2data/src/automaton/TA/NFTA.cpp b/alib2data/src/automaton/TA/NFTA.cpp index 484e7b81e8..e90e5958f0 100644 --- a/alib2data/src/automaton/TA/NFTA.cpp +++ b/alib2data/src/automaton/TA/NFTA.cpp @@ -19,7 +19,7 @@ namespace automaton { -NFTA::NFTA ( std::set < State > states, std::set < alphabet::RankedSymbol > inputAlphabet, std::set < State > finalStates ) : std::Components < NFTA, alphabet::RankedSymbol, std::tuple < InputAlphabet >, std::tuple < >, automaton::State, std::tuple < States, FinalStates >, std::tuple < > > ( std::make_tuple ( std::move ( inputAlphabet ) ), std::tuple < > ( ), std::make_tuple ( std::move ( states ), std::move ( finalStates ) ), std::tuple < > ( ) ) { +NFTA::NFTA ( std::set < State > states, std::set < alphabet::RankedSymbol > inputAlphabet, std::set < State > finalStates ) : std::Components2 < NFTA, alphabet::RankedSymbol, std::tuple < InputAlphabet >, std::tuple < >, automaton::State, std::tuple < States, FinalStates >, std::tuple < > > ( std::make_tuple ( std::move ( inputAlphabet ) ), std::tuple < > ( ), std::make_tuple ( std::move ( states ), std::move ( finalStates ) ), std::tuple < > ( ) ) { } NFTA::NFTA() : NFTA ( std::set < State > { }, std::set < alphabet::RankedSymbol > { }, std::set < State > { } ) { @@ -164,63 +164,60 @@ void NFTA::composeTransitions(std::deque<sax::Token>& out) const { namespace std { template < > -bool automaton::NFTA::Component < automaton::NFTA, alphabet::RankedSymbol, automaton::InputAlphabet >::used ( const alphabet::RankedSymbol & symbol ) const { - const automaton::NFTA * automaton = static_cast < const automaton::NFTA * > ( this ); - - for (const std::pair<const std::pair<alphabet::RankedSymbol, std::vector<automaton::State> >, std::set<automaton::State>>& t : automaton->getTransitions()) - if (t.first.first == symbol) - return true; - - return false; -} +class ComponentConstraint2< automaton::NFTA, alphabet::RankedSymbol, automaton::InputAlphabet > { +public: + static bool used ( const automaton::NFTA & automaton, const alphabet::RankedSymbol & symbol ) { + for (const std::pair<const std::pair<alphabet::RankedSymbol, std::vector<automaton::State> >, std::set<automaton::State>>& t : automaton.getTransitions()) + if (t.first.first == symbol) + return true; + + return false; + } -template < > -bool automaton::NFTA::Component < automaton::NFTA, alphabet::RankedSymbol, automaton::InputAlphabet >::available ( const alphabet::RankedSymbol & ) const { - return true; -} + static bool available ( const automaton::NFTA &, const alphabet::RankedSymbol & ) { + return true; + } -template < > -void automaton::NFTA::Component < automaton::NFTA, alphabet::RankedSymbol, automaton::InputAlphabet >::valid ( const alphabet::RankedSymbol & ) const { -} + static void valid ( const automaton::NFTA &, const alphabet::RankedSymbol & ) { + } +}; template < > -bool automaton::NFTA::Component < automaton::NFTA, automaton::State, automaton::States >::used ( const automaton::State & state ) const { - const automaton::NFTA * automaton = static_cast < const automaton::NFTA * > ( this ); - - if ( automaton->getFinalStates ( ).count ( state ) ) - return true; - - for (const std::pair<const std::pair<alphabet::RankedSymbol, std::vector<automaton::State> >, std::set<automaton::State>>& t : automaton->getTransitions()) - if(std::contains(t.first.second.begin(), t.first.second.end(), state ) || t . second.count ( state ) ) +class ComponentConstraint2< automaton::NFTA, automaton::State, automaton::States > { +public: + static bool used ( const automaton::NFTA & automaton, const automaton::State & state ) { + if ( automaton.getFinalStates ( ).count ( state ) ) return true; - return false; -} + for (const std::pair<const std::pair<alphabet::RankedSymbol, std::vector<automaton::State> >, std::set<automaton::State>>& t : automaton.getTransitions()) + if(std::contains(t.first.second.begin(), t.first.second.end(), state ) || t . second.count ( state ) ) + return true; -template < > -bool automaton::NFTA::Component < automaton::NFTA, automaton::State, automaton::States >::available ( const automaton::State & ) const { - return true; -} + return false; + } -template < > -void automaton::NFTA::Component < automaton::NFTA, automaton::State, automaton::States >::valid ( const automaton::State & ) const { -} + static bool available ( const automaton::NFTA &, const automaton::State & ) { + return true; + } -template < > -bool automaton::NFTA::Component < automaton::NFTA, automaton::State, automaton::FinalStates >::used ( const automaton::State & ) const { - return false; -} + static void valid ( const automaton::NFTA &, const automaton::State & ) { + } +}; template < > -bool automaton::NFTA::Component < automaton::NFTA, automaton::State, automaton::FinalStates >::available ( const automaton::State & state ) const { - const automaton::NFTA * automaton = static_cast < const automaton::NFTA * > ( this ); +class ComponentConstraint2< automaton::NFTA, automaton::State, automaton::FinalStates > { +public: + static bool used ( const automaton::NFTA &, const automaton::State & ) { + return false; + } - return automaton->accessComponent < automaton::States > ( ).get ( ).count ( state ); -} + static bool available ( const automaton::NFTA & automaton, const automaton::State & state ) { + return automaton.accessComponent < automaton::States > ( ).get ( ).count ( state ); + } -template < > -void automaton::NFTA::Component < automaton::NFTA, automaton::State, automaton::FinalStates >::valid ( const automaton::State & ) const { -} + static void valid ( const automaton::NFTA &, const automaton::State & ) { + } +}; } /* namespace std */ diff --git a/alib2data/src/automaton/TA/NFTA.h b/alib2data/src/automaton/TA/NFTA.h index 8b736aeff0..3e74762962 100644 --- a/alib2data/src/automaton/TA/NFTA.h +++ b/alib2data/src/automaton/TA/NFTA.h @@ -10,7 +10,7 @@ #include <map> #include <vector> -#include <core/components.hpp> +#include <core/components2.hpp> #include "../AutomatonBase.h" #include "../common/State.h" #include "../../alphabet/RankedSymbol.h" @@ -27,7 +27,7 @@ class FinalStates; * Represents Finite Tree Automaton. * Can store nondeterministic finite tree automaton without epsilon transitions. */ -class NFTA : public AutomatonBase, public std::Components < NFTA, alphabet::RankedSymbol, std::tuple < InputAlphabet >, std::tuple < >, automaton::State, std::tuple < States, FinalStates >, std::tuple < > > { +class NFTA : public AutomatonBase, public std::Components2 < NFTA, alphabet::RankedSymbol, std::tuple < InputAlphabet >, std::tuple < >, automaton::State, std::tuple < States, FinalStates >, std::tuple < > > { std::map < std::pair < alphabet::RankedSymbol, std::vector < State > >, std::set < State > > transitions; public: diff --git a/alib2data/src/automaton/TM/OneTapeDTM.cpp b/alib2data/src/automaton/TM/OneTapeDTM.cpp index d52d7046a5..88c4caf5e5 100644 --- a/alib2data/src/automaton/TM/OneTapeDTM.cpp +++ b/alib2data/src/automaton/TM/OneTapeDTM.cpp @@ -18,7 +18,7 @@ namespace automaton { -OneTapeDTM::OneTapeDTM ( std::set < State > states, std::set < alphabet::Symbol > tapeAlphabet, alphabet::Symbol blankSymbol, std::set< alphabet::Symbol > inputAlphabet, State initialState, std::set < State > finalStates ) : std::Components < OneTapeDTM, alphabet::Symbol, std::tuple < TapeAlphabet, InputAlphabet >, std::tuple < BlankSymbol >, automaton::State, std::tuple < States, FinalStates >, std::tuple < InitialState > > ( std::make_tuple ( std::move ( tapeAlphabet), std::move ( inputAlphabet ) ), std::make_tuple ( blankSymbol ), std::make_tuple ( std::move ( states ), std::move ( finalStates ) ), std::make_tuple ( std::move ( initialState ) ) ) { +OneTapeDTM::OneTapeDTM ( std::set < State > states, std::set < alphabet::Symbol > tapeAlphabet, alphabet::Symbol blankSymbol, std::set< alphabet::Symbol > inputAlphabet, State initialState, std::set < State > finalStates ) : std::Components2 < OneTapeDTM, alphabet::Symbol, std::tuple < TapeAlphabet, InputAlphabet >, std::tuple < BlankSymbol >, automaton::State, std::tuple < States, FinalStates >, std::tuple < InitialState > > ( std::make_tuple ( std::move ( tapeAlphabet), std::move ( inputAlphabet ) ), std::make_tuple ( blankSymbol ), std::make_tuple ( std::move ( states ), std::move ( finalStates ) ), std::make_tuple ( std::move ( initialState ) ) ) { } @@ -180,119 +180,111 @@ void OneTapeDTM::composeTransitions(std::deque<sax::Token>& out) const { namespace std { template < > -bool automaton::OneTapeDTM::Component < automaton::OneTapeDTM, alphabet::Symbol, automaton::TapeAlphabet >::used ( const alphabet::Symbol & symbol ) const { - const automaton::OneTapeDTM * automaton = static_cast < const automaton::OneTapeDTM * > ( this ); - - if ( automaton->getBlankSymbol ( ) == symbol ) - return true; - - if ( automaton->getInputAlphabet().count(symbol)) - return true; - - for (const std::pair<const std::pair<automaton::State, alphabet::Symbol>, std::tuple<automaton::State, alphabet::Symbol, automaton::Shift> >& transition : automaton->getTransitions()) - if (symbol == transition.first.second || symbol == std::get<1>(transition.second)) +class ComponentConstraint2< automaton::OneTapeDTM, alphabet::Symbol, automaton::TapeAlphabet > { +public: + static bool used ( const automaton::OneTapeDTM & automaton, const alphabet::Symbol & symbol ) { + if ( automaton.getBlankSymbol ( ) == symbol ) return true; - return false; - -} + if ( automaton.getInputAlphabet().count(symbol)) + return true; -template < > -bool automaton::OneTapeDTM::Component < automaton::OneTapeDTM, alphabet::Symbol, automaton::TapeAlphabet >::available ( const alphabet::Symbol &) const { - return true; -} + for (const std::pair<const std::pair<automaton::State, alphabet::Symbol>, std::tuple<automaton::State, alphabet::Symbol, automaton::Shift> >& transition : automaton.getTransitions()) + if (symbol == transition.first.second || symbol == std::get<1>(transition.second)) + return true; -template < > -void automaton::OneTapeDTM::Component < automaton::OneTapeDTM, alphabet::Symbol, automaton::TapeAlphabet >::valid ( const alphabet::Symbol & ) const { -} + return false; -template < > -bool automaton::OneTapeDTM::Component < automaton::OneTapeDTM, alphabet::Symbol, automaton::InputAlphabet >::used ( const alphabet::Symbol & ) const { - return false; -} + } -template < > -bool automaton::OneTapeDTM::Component < automaton::OneTapeDTM, alphabet::Symbol, automaton::InputAlphabet >::available ( const alphabet::Symbol & symbol ) const { - const automaton::OneTapeDTM * automaton = static_cast < const automaton::OneTapeDTM * > ( this ); + static bool available ( const automaton::OneTapeDTM &, const alphabet::Symbol & ) { + return true; + } - return automaton->accessComponent < automaton::TapeAlphabet > ( ).get ( ).count ( symbol ); -} + static void valid ( const automaton::OneTapeDTM &, const alphabet::Symbol & ) { + } +}; template < > -void automaton::OneTapeDTM::Component < automaton::OneTapeDTM, alphabet::Symbol, automaton::InputAlphabet >::valid ( const alphabet::Symbol & symbol ) const { - const automaton::OneTapeDTM * automaton = static_cast < const automaton::OneTapeDTM * > ( this ); - - if (symbol == automaton->getBlankSymbol()) - throw automaton::AutomatonException("Input symbol \"" + (std::string) symbol + "\" cannot be blank symbol."); -} +class ComponentConstraint2< automaton::OneTapeDTM, alphabet::Symbol, automaton::InputAlphabet > { +public: + static bool used ( const automaton::OneTapeDTM &, const alphabet::Symbol & ) { + return false; + } -template < > -bool automaton::OneTapeDTM::Element < automaton::OneTapeDTM, alphabet::Symbol, automaton::BlankSymbol >::available ( const alphabet::Symbol & symbol ) const { - const automaton::OneTapeDTM * automaton = static_cast < const automaton::OneTapeDTM * > ( this ); + static bool available ( const automaton::OneTapeDTM & automaton, const alphabet::Symbol & symbol ) { + return automaton.accessComponent < automaton::TapeAlphabet > ( ).get ( ).count ( symbol ); + } - return automaton->accessComponent < automaton::TapeAlphabet > ( ).get ( ).count ( symbol ); -} + static void valid ( const automaton::OneTapeDTM & automaton, const alphabet::Symbol & symbol ) { + if (symbol == automaton.getBlankSymbol()) + throw automaton::AutomatonException("Input symbol \"" + (std::string) symbol + "\" cannot be blank symbol."); + } +}; template < > -void automaton::OneTapeDTM::Element < automaton::OneTapeDTM, alphabet::Symbol, automaton::BlankSymbol >::valid ( const alphabet::Symbol & symbol ) const { - const automaton::OneTapeDTM * automaton = static_cast < const automaton::OneTapeDTM * > ( this ); +class ElementConstraint2< automaton::OneTapeDTM, alphabet::Symbol, automaton::BlankSymbol > { +public: + static bool available ( const automaton::OneTapeDTM & automaton, const alphabet::Symbol & symbol ) { + return automaton.accessComponent < automaton::TapeAlphabet > ( ).get ( ).count ( symbol ); + } - if (automaton->getInputAlphabet().count( symbol )) - throw automaton::AutomatonException("Blank symbol \"" + (std::string) symbol + "\" cannot be in input alphabet."); -} + static void valid ( const automaton::OneTapeDTM & automaton, const alphabet::Symbol & symbol ) { + if (automaton.getInputAlphabet().count( symbol )) + throw automaton::AutomatonException("Blank symbol \"" + (std::string) symbol + "\" cannot be in input alphabet."); + } +}; template < > -bool automaton::OneTapeDTM::Component < automaton::OneTapeDTM, automaton::State, automaton::States >::used ( const automaton::State & state ) const { - const automaton::OneTapeDTM * automaton = static_cast < const automaton::OneTapeDTM * > ( this ); - - if ( automaton->getInitialState ( ) == state ) - return true; - - if ( automaton->getFinalStates ( ).count ( state ) ) - return true; +class ComponentConstraint2< automaton::OneTapeDTM, automaton::State, automaton::States > { +public: + static bool used ( const automaton::OneTapeDTM & automaton, const automaton::State & state ) { + if ( automaton.getInitialState ( ) == state ) + return true; - for (const std::pair<const std::pair<automaton::State, alphabet::Symbol>, std::tuple<automaton::State, alphabet::Symbol, automaton::Shift> >& transition : automaton->getTransitions ( ) ) - if ( state == transition.first.first || state == std::get < 0 > ( transition.second ) ) + if ( automaton.getFinalStates ( ).count ( state ) ) return true; - return false; -} + for (const std::pair<const std::pair<automaton::State, alphabet::Symbol>, std::tuple<automaton::State, alphabet::Symbol, automaton::Shift> >& transition : automaton.getTransitions ( ) ) + if ( state == transition.first.first || state == std::get < 0 > ( transition.second ) ) + return true; -template < > -bool automaton::OneTapeDTM::Component < automaton::OneTapeDTM, automaton::State, automaton::States >::available ( const automaton::State & ) const { - return true; -} + return false; + } -template < > -void automaton::OneTapeDTM::Component < automaton::OneTapeDTM, automaton::State, automaton::States >::valid ( const automaton::State & ) const { -} + static bool available ( const automaton::OneTapeDTM &, const automaton::State & ) { + return true; + } -template < > -bool automaton::OneTapeDTM::Component < automaton::OneTapeDTM, automaton::State, automaton::FinalStates >::used ( const automaton::State & ) const { - return false; -} + static void valid ( const automaton::OneTapeDTM &, const automaton::State & ) { + } +}; template < > -bool automaton::OneTapeDTM::Component < automaton::OneTapeDTM, automaton::State, automaton::FinalStates >::available ( const automaton::State & state ) const { - const automaton::OneTapeDTM * automaton = static_cast < const automaton::OneTapeDTM * > ( this ); +class ComponentConstraint2< automaton::OneTapeDTM, automaton::State, automaton::FinalStates > { +public: + static bool used ( const automaton::OneTapeDTM &, const automaton::State & ) { + return false; + } - return automaton->accessComponent < automaton::States > ( ).get ( ).count ( state ); -} + static bool available ( const automaton::OneTapeDTM & automaton, const automaton::State & state ) { + return automaton.accessComponent < automaton::States > ( ).get ( ).count ( state ); + } -template < > -void automaton::OneTapeDTM::Component < automaton::OneTapeDTM, automaton::State, automaton::FinalStates >::valid ( const automaton::State & ) const { -} + static void valid ( const automaton::OneTapeDTM &, const automaton::State & ) { + } +}; template < > -bool automaton::OneTapeDTM::Element < automaton::OneTapeDTM, automaton::State, automaton::InitialState >::available ( const automaton::State & state ) const { - const automaton::OneTapeDTM * automaton = static_cast < const automaton::OneTapeDTM * > ( this ); - - return automaton->accessComponent < automaton::States > ( ).get ( ).count ( state ); -} +class ElementConstraint2< automaton::OneTapeDTM, automaton::State, automaton::InitialState > { +public: + static bool available ( const automaton::OneTapeDTM & automaton, const automaton::State & state ) { + return automaton.accessComponent < automaton::States > ( ).get ( ).count ( state ); + } -template < > -void automaton::OneTapeDTM::Element < automaton::OneTapeDTM, automaton::State, automaton::InitialState >::valid ( const automaton::State & ) const { -} + static void valid ( const automaton::OneTapeDTM &, const automaton::State & ) { + } +}; } /* namespace std */ diff --git a/alib2data/src/automaton/TM/OneTapeDTM.h b/alib2data/src/automaton/TM/OneTapeDTM.h index 2fd9ae681a..fca58dab5d 100644 --- a/alib2data/src/automaton/TM/OneTapeDTM.h +++ b/alib2data/src/automaton/TM/OneTapeDTM.h @@ -9,7 +9,7 @@ #define ONE_TAPE_DTM_H_ #include "../AutomatonBase.h" -#include <core/components.hpp> +#include <core/components2.hpp> #include "../common/State.h" #include "../../alphabet/Symbol.h" #include "../common/Shift.h" @@ -30,7 +30,7 @@ class InitialState; /** * One tape turing machine */ -class OneTapeDTM : public AutomatonBase, public std::Components < OneTapeDTM, alphabet::Symbol, std::tuple < TapeAlphabet, InputAlphabet >, std::tuple < BlankSymbol >, automaton::State, std::tuple < States, FinalStates >, std::tuple < InitialState > > { +class OneTapeDTM : public AutomatonBase, public std::Components2 < OneTapeDTM, alphabet::Symbol, std::tuple < TapeAlphabet, InputAlphabet >, std::tuple < BlankSymbol >, automaton::State, std::tuple < States, FinalStates >, std::tuple < InitialState > > { protected: std::map < std::pair < State, alphabet::Symbol >, std::tuple < State, alphabet::Symbol, Shift > > transitions; -- GitLab