diff --git a/alib2data/src/automaton/FSM/CompactNFA.h b/alib2data/src/automaton/FSM/CompactNFA.h index ad082df6c58d08f1198126a7484cf93dabde9b35..88ae48c20df5a95965a20d1760ffccadd387b3b8 100644 --- a/alib2data/src/automaton/FSM/CompactNFA.h +++ b/alib2data/src/automaton/FSM/CompactNFA.h @@ -45,10 +45,11 @@ protected: public: explicit CompactNFA ( StateType initialState ); explicit CompactNFA ( std::set < StateType > states, std::set < SymbolType > inputAlphabet, StateType initialState, std::set < StateType > finalStates ); - explicit CompactNFA ( const EpsilonNFA < > & other ); - explicit CompactNFA ( const MultiInitialStateNFA < > & other ); - explicit CompactNFA ( const NFA<> & other ); - explicit CompactNFA ( const DFA<> & other ); + template < class EpsilonType > + explicit CompactNFA ( const EpsilonNFA < SymbolType, EpsilonType, StateType > & other ); + explicit CompactNFA ( const MultiInitialStateNFA < SymbolType, StateType > & other ); + explicit CompactNFA ( const NFA < SymbolType, StateType > & other ); + explicit CompactNFA ( const DFA < SymbolType, StateType > & other ); virtual AutomatonBase * clone ( ) const; @@ -190,20 +191,21 @@ CompactNFA < SymbolType, StateType >::CompactNFA ( StateType initialState ) : Co } template < class SymbolType, class StateType > -CompactNFA < SymbolType, StateType >::CompactNFA ( const EpsilonNFA < > & other ) : CompactNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { +template < class EpsilonType > +CompactNFA < SymbolType, StateType >::CompactNFA ( const EpsilonNFA < SymbolType, EpsilonType, StateType > & other ) : CompactNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { - if ( transition.first.second.is < string::Epsilon < > > ( ) ) { + if ( transition.first.second.template is < EpsilonType > ( ) ) { std::pair < StateType, std::vector < SymbolType > > key = std::make_pair ( transition.first.first, std::vector < SymbolType > { } ); transitions[key] = transition.second; } else { - std::pair < StateType, std::vector < SymbolType > > key = std::make_pair ( transition.first.first, std::vector < SymbolType > { transition.first.second.get < SymbolType > ( ) } ); + std::pair < StateType, std::vector < SymbolType > > key = std::make_pair ( transition.first.first, std::vector < SymbolType > { transition.first.second.template get < SymbolType > ( ) } ); transitions[key] = transition.second; } } } template < class SymbolType, class StateType > -CompactNFA < SymbolType, StateType >::CompactNFA ( const MultiInitialStateNFA < > & other ) : CompactNFA ( other.getStates ( ) + std::set < StateType > { common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ) }, other.getInputAlphabet ( ), common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ), other.getFinalStates ( ) ) { +CompactNFA < SymbolType, StateType >::CompactNFA ( const MultiInitialStateNFA < SymbolType, StateType > & other ) : CompactNFA ( other.getStates ( ) + std::set < StateType > { common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ) }, other.getInputAlphabet ( ), common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { std::pair < StateType, std::vector < SymbolType > > key = std::make_pair ( transition.first.first, std::vector < SymbolType > { transition.first.second } ); transitions[key] = transition.second; @@ -214,7 +216,7 @@ CompactNFA < SymbolType, StateType >::CompactNFA ( const MultiInitialStateNFA < } template < class SymbolType, class StateType > -CompactNFA < SymbolType, StateType >::CompactNFA ( const NFA <> & other ) : CompactNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { +CompactNFA < SymbolType, StateType >::CompactNFA ( const NFA < SymbolType, StateType > & other ) : CompactNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { std::pair < StateType, std::vector < SymbolType > > key = std::make_pair ( transition.first.first, std::vector < SymbolType > { transition.first.second } ); transitions[key] = transition.second; @@ -222,7 +224,7 @@ CompactNFA < SymbolType, StateType >::CompactNFA ( const NFA <> & other ) : Comp } template < class SymbolType, class StateType > -CompactNFA < SymbolType, StateType >::CompactNFA ( const DFA<> & other ) : CompactNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { +CompactNFA < SymbolType, StateType >::CompactNFA ( const DFA < SymbolType, StateType > & other ) : CompactNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { std::pair < StateType, std::vector < SymbolType > > key = std::make_pair ( transition.first.first, std::vector < SymbolType > { transition.first.second } ); transitions[key].insert ( transition.second ); diff --git a/alib2data/src/automaton/FSM/EpsilonNFA.h b/alib2data/src/automaton/FSM/EpsilonNFA.h index e700e941814c7f17acdb6797e4ec719e84bcfcbb..36ceb7b30c0ae960ea7d05f89af2f0b958ad28d6 100644 --- a/alib2data/src/automaton/FSM/EpsilonNFA.h +++ b/alib2data/src/automaton/FSM/EpsilonNFA.h @@ -45,9 +45,9 @@ protected: public: explicit EpsilonNFA ( StateType initialState ); explicit EpsilonNFA ( std::set < StateType > states, std::set < SymbolType > inputAlphabet, StateType initialState, std::set < StateType > finalStates ); - explicit EpsilonNFA ( const MultiInitialStateNFA < > & other ); - explicit EpsilonNFA ( const NFA<> & other ); - explicit EpsilonNFA ( const DFA<> & other ); + explicit EpsilonNFA ( const MultiInitialStateNFA < SymbolType, StateType > & other ); + explicit EpsilonNFA ( const NFA < SymbolType, StateType > & other ); + explicit EpsilonNFA ( const DFA < SymbolType, StateType > & other ); virtual AutomatonBase * clone ( ) const; @@ -267,7 +267,7 @@ EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( StateType initia template<class SymbolType, class EpsilonType, class StateType > -EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( const MultiInitialStateNFA < > & other ) : EpsilonNFA ( other.getStates ( ) + std::set < StateType > { common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ) }, other.getInputAlphabet ( ), common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ), other.getFinalStates ( ) ) { +EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( const MultiInitialStateNFA < SymbolType, StateType > & other ) : EpsilonNFA ( other.getStates ( ) + std::set < StateType > { common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ) }, other.getInputAlphabet ( ), common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { std::pair < StateType, std::variant < EpsilonType, SymbolType > > key = std::make_pair ( transition.first.first, std::variant < EpsilonType, SymbolType > ( transition.first.second ) ); transitions[key] = transition.second; @@ -279,7 +279,7 @@ EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( const MultiIniti template<class SymbolType, class EpsilonType, class StateType > -EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( const NFA <> & other ) : EpsilonNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { +EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( const NFA < SymbolType, StateType > & other ) : EpsilonNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { std::pair < StateType, std::variant < EpsilonType, SymbolType > > key = std::make_pair ( transition.first.first, std::variant < EpsilonType, SymbolType > ( transition.first.second ) ); transitions[key] = transition.second; @@ -287,7 +287,7 @@ EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( const NFA <> & o } template<class SymbolType, class EpsilonType, class StateType > -EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( const DFA<> & other ) : EpsilonNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { +EpsilonNFA < SymbolType, EpsilonType, StateType >::EpsilonNFA ( const DFA < SymbolType, StateType > & other ) : EpsilonNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { std::pair < StateType, std::variant < EpsilonType, SymbolType > > key = std::make_pair ( transition.first.first, std::variant < EpsilonType, SymbolType > ( transition.first.second ) ); transitions[key].insert ( transition.second ); diff --git a/alib2data/src/automaton/FSM/ExtendedNFA.h b/alib2data/src/automaton/FSM/ExtendedNFA.h index c9685960c1e7ce8bb801f1f3e662e0cc06de5c46..e902fd9ceda300769216c486ab3896338b5cfac1 100644 --- a/alib2data/src/automaton/FSM/ExtendedNFA.h +++ b/alib2data/src/automaton/FSM/ExtendedNFA.h @@ -48,11 +48,12 @@ protected: public: explicit ExtendedNFA ( StateType initialState ); explicit ExtendedNFA ( std::set < StateType > states, std::set < SymbolType > inputAlphabet, StateType initialState, std::set < StateType > finalStates ); - explicit ExtendedNFA ( const CompactNFA < > & other ); - explicit ExtendedNFA ( const EpsilonNFA < > & other ); - explicit ExtendedNFA ( const MultiInitialStateNFA < > & other ); - explicit ExtendedNFA ( const NFA<> & other ); - explicit ExtendedNFA ( const DFA<> & other ); + explicit ExtendedNFA ( const CompactNFA < SymbolType, StateType > & other ); + template < class EpsilonType > + explicit ExtendedNFA ( const EpsilonNFA < SymbolType, EpsilonType, StateType > & other ); + explicit ExtendedNFA ( const MultiInitialStateNFA < SymbolType, StateType > & other ); + explicit ExtendedNFA ( const NFA < SymbolType, StateType > & other ); + explicit ExtendedNFA ( const DFA < SymbolType, StateType > & other ); virtual AutomatonBase * clone ( ) const; @@ -195,7 +196,7 @@ ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( StateType initialState ) : } template<class SymbolType, class StateType > -ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const CompactNFA < > & other ) : ExtendedNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { +ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const CompactNFA < SymbolType, StateType > & other ) : ExtendedNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { regexp::UnboundedRegExpConcatenation < SymbolType > con; @@ -207,21 +208,22 @@ ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const CompactNFA < > & othe } } -template<class SymbolType, class StateType > -ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const EpsilonNFA < > & other ) : ExtendedNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { +template < class SymbolType, class StateType > +template < class EpsilonType > +ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const EpsilonNFA < SymbolType, EpsilonType, StateType > & other ) : ExtendedNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { - if ( transition.first.second.is < string::Epsilon < > > ( ) ) { + if ( transition.first.second.template is < EpsilonType > ( ) ) { std::pair < StateType, regexp::UnboundedRegExpStructure < SymbolType > > key = std::make_pair ( transition.first.first, regexp::UnboundedRegExpStructure < SymbolType > ( ) ); transitions[key] = transition.second; } else { - std::pair < StateType, regexp::UnboundedRegExpStructure < SymbolType > > key = std::make_pair ( transition.first.first, regexp::UnboundedRegExpStructure < SymbolType > ( regexp::UnboundedRegExpSymbol < SymbolType > ( transition.first.second.get < SymbolType > ( ) ) ) ); + std::pair < StateType, regexp::UnboundedRegExpStructure < SymbolType > > key = std::make_pair ( transition.first.first, regexp::UnboundedRegExpStructure < SymbolType > ( regexp::UnboundedRegExpSymbol < SymbolType > ( transition.first.second.template get < SymbolType > ( ) ) ) ); transitions[key] = transition.second; } } } template<class SymbolType, class StateType > -ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const MultiInitialStateNFA < > & other ) : ExtendedNFA ( other.getStates ( ) + std::set < StateType > { common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ) }, other.getInputAlphabet ( ), common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ), other.getFinalStates ( ) ) { +ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const MultiInitialStateNFA < SymbolType, StateType > & other ) : ExtendedNFA ( other.getStates ( ) + std::set < StateType > { common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ) }, other.getInputAlphabet ( ), common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { std::pair < StateType, regexp::UnboundedRegExpStructure < SymbolType > > key = std::make_pair ( transition.first.first, regexp::UnboundedRegExpStructure < SymbolType > ( regexp::UnboundedRegExpSymbol < SymbolType > ( transition.first.second ) ) ); transitions[key] = transition.second; @@ -232,7 +234,7 @@ ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const MultiInitialStateNFA } template<class SymbolType, class StateType > -ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const NFA <> & other ) : ExtendedNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { +ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const NFA < SymbolType, StateType > & other ) : ExtendedNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { std::pair < StateType, regexp::UnboundedRegExpStructure < SymbolType > > key = std::make_pair ( transition.first.first, regexp::UnboundedRegExpStructure < SymbolType > ( regexp::UnboundedRegExpSymbol < SymbolType > ( transition.first.second ) ) ); transitions[key] = transition.second; @@ -240,7 +242,7 @@ ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const NFA <> & other ) : Ex } template<class SymbolType, class StateType > -ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const DFA<> & other ) : ExtendedNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { +ExtendedNFA < SymbolType, StateType >::ExtendedNFA ( const DFA < SymbolType, StateType > & other ) : ExtendedNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) { std::pair < StateType, regexp::UnboundedRegExpStructure < SymbolType > > key = std::make_pair ( transition.first.first, regexp::UnboundedRegExpStructure < SymbolType > ( regexp::UnboundedRegExpSymbol < SymbolType > ( transition.first.second ) ) ); transitions[key].insert ( transition.second ); diff --git a/alib2data/src/automaton/FSM/MultiInitialStateNFA.h b/alib2data/src/automaton/FSM/MultiInitialStateNFA.h index 2fcdccfb890243171da5fe3799beb558b22dd8c6..8286c12864ddf7459cfcba90e5dce91712fe4958 100644 --- a/alib2data/src/automaton/FSM/MultiInitialStateNFA.h +++ b/alib2data/src/automaton/FSM/MultiInitialStateNFA.h @@ -41,8 +41,8 @@ protected: public: explicit MultiInitialStateNFA ( ); explicit MultiInitialStateNFA ( std::set < StateType > states, std::set < SymbolType > inputAlphabet, std::set < StateType > initialStates, std::set < StateType > finalStates ); - explicit MultiInitialStateNFA ( const NFA<> & other ); - explicit MultiInitialStateNFA ( const DFA<> & other ); + explicit MultiInitialStateNFA ( const NFA < SymbolType, StateType > & other ); + explicit MultiInitialStateNFA ( const DFA < SymbolType, StateType > & other ); virtual AutomatonBase * clone ( ) const; @@ -207,13 +207,13 @@ MultiInitialStateNFA < SymbolType, StateType >::MultiInitialStateNFA ( ) : Multi } template < class SymbolType, class StateType > -MultiInitialStateNFA < SymbolType, StateType >::MultiInitialStateNFA ( const DFA<> & other ) : MultiInitialStateNFA ( other.getStates ( ), other.getInputAlphabet ( ), { other.getInitialState ( ) }, other.getFinalStates ( ) ) { +MultiInitialStateNFA < SymbolType, StateType >::MultiInitialStateNFA ( const DFA < SymbolType, StateType > & other ) : MultiInitialStateNFA ( other.getStates ( ), other.getInputAlphabet ( ), { other.getInitialState ( ) }, other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) transitions[transition.first].insert ( transition.second ); } template < class SymbolType, class StateType > -MultiInitialStateNFA < SymbolType, StateType >::MultiInitialStateNFA ( const NFA <> & other ) : MultiInitialStateNFA ( other.getStates ( ), other.getInputAlphabet ( ), { other.getInitialState ( ) }, other.getFinalStates ( ) ) { +MultiInitialStateNFA < SymbolType, StateType >::MultiInitialStateNFA ( const NFA < SymbolType, StateType > & other ) : MultiInitialStateNFA ( other.getStates ( ), other.getInputAlphabet ( ), { other.getInitialState ( ) }, other.getFinalStates ( ) ) { for ( const auto & transition : other.getTransitions ( ) ) transitions[transition.first] = transition.second; } diff --git a/alib2data/src/automaton/TA/NFTA.h b/alib2data/src/automaton/TA/NFTA.h index c900c1f3a432a01d42a3fcf6dd4c76b2aebd0f93..85a1f23a4b8a15b0d5d54f93ba590637b6edbc8d 100644 --- a/alib2data/src/automaton/TA/NFTA.h +++ b/alib2data/src/automaton/TA/NFTA.h @@ -40,7 +40,7 @@ class NFTA : public AutomatonBase, public std::Components < NFTA < SymbolType, R public: explicit NFTA ( ); explicit NFTA ( std::set < StateType > states, std::set < std::ranked_symbol < SymbolType, RankType > > inputAlphabet, std::set < StateType > finalStates ); - explicit NFTA ( const DFTA < > & other ); + explicit NFTA ( const DFTA < SymbolType, RankType, StateType > & other ); virtual AutomatonBase * clone ( ) const; @@ -173,7 +173,7 @@ NFTA < SymbolType, RankType, StateType >::NFTA() : NFTA ( std::set < StateType > } template < class SymbolType, class RankType, class StateType > -NFTA < SymbolType, RankType, StateType >::NFTA(const DFTA < > & other) : NFTA ( other.getStates(), other.getInputAlphabet(), other.getFinalStates() ) { +NFTA < SymbolType, RankType, StateType >::NFTA(const DFTA < SymbolType, RankType, StateType > & other) : NFTA ( other.getStates(), other.getInputAlphabet(), other.getFinalStates() ) { for(const auto& transition : other.getTransitions()) { transitions[transition.first].insert(transition.second); }