From 229bb33ee47d175cded51d10726a0505aca8242e Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 12 Sep 2017 18:27:10 +0200 Subject: [PATCH] drop use of multiple dispatch from elgo --- .../properties/efficient/AllEpsilonClosure.cpp | 16 ++++++---------- .../properties/efficient/AllEpsilonClosure.h | 12 +----------- .../properties/efficient/ReachableStates.cpp | 16 ++++++---------- .../properties/efficient/ReachableStates.h | 8 +------- .../properties/efficient/UsefullStates.cpp | 16 ++++++---------- .../properties/efficient/UsefullStates.h | 8 +------- .../simplify/efficient/EpsilonRemoverOutgoing.h | 2 +- 7 files changed, 22 insertions(+), 56 deletions(-) diff --git a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp index b7538d680a..3ce2d4d16a 100644 --- a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp +++ b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp @@ -14,16 +14,12 @@ namespace properties { namespace efficient { -auto AllEpsilonClosureEpsilonNFA = registration::OverloadRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set < DefaultStateType > >, automaton::EpsilonNFA < > > ( AllEpsilonClosure::allEpsilonClosure ); -auto AllEpsilonClosureMultiInitialStateNFA = registration::OverloadRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set < DefaultStateType > >, automaton::MultiInitialStateNFA < >> ( AllEpsilonClosure::allEpsilonClosure ); -auto AllEpsilonClosureNFA = registration::OverloadRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set<DefaultStateType > >, automaton::NFA < > > ( AllEpsilonClosure::allEpsilonClosure ); -auto AllEpsilonClosureDFA = registration::OverloadRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set<DefaultStateType > >, automaton::DFA < > > ( AllEpsilonClosure::allEpsilonClosure ); -auto AllEpsilonClosureExtendedNFA = registration::OverloadRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set<DefaultStateType > >, automaton::ExtendedNFA < > > ( AllEpsilonClosure::allEpsilonClosure ); -auto AllEpsilonClosureCompactNFA = registration::OverloadRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set<DefaultStateType > >, automaton::CompactNFA < > > ( AllEpsilonClosure::allEpsilonClosure ); - -ext::map<DefaultStateType, ext::set<DefaultStateType>> AllEpsilonClosure::allEpsilonClosure(const Automaton& automaton) { - return dispatch(automaton.getData()); -} +auto AllEpsilonClosureEpsilonNFA = registration::AbstractRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set < DefaultStateType > >, const automaton::EpsilonNFA < > & > ( AllEpsilonClosure::allEpsilonClosure ); +auto AllEpsilonClosureMultiInitialStateNFA = registration::AbstractRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set < DefaultStateType > >, const automaton::MultiInitialStateNFA < > & > ( AllEpsilonClosure::allEpsilonClosure ); +auto AllEpsilonClosureNFA = registration::AbstractRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set<DefaultStateType > >, const automaton::NFA < > & > ( AllEpsilonClosure::allEpsilonClosure ); +auto AllEpsilonClosureDFA = registration::AbstractRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set<DefaultStateType > >, const automaton::DFA < > & > ( AllEpsilonClosure::allEpsilonClosure ); +auto AllEpsilonClosureExtendedNFA = registration::AbstractRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set<DefaultStateType > >, const automaton::ExtendedNFA < > & > ( AllEpsilonClosure::allEpsilonClosure ); +auto AllEpsilonClosureCompactNFA = registration::AbstractRegister < AllEpsilonClosure, ext::map < DefaultStateType, ext::set<DefaultStateType > >, const automaton::CompactNFA < > & > ( AllEpsilonClosure::allEpsilonClosure ); } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h index e247202e14..38a70bf568 100644 --- a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h +++ b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h @@ -8,13 +8,9 @@ #ifndef EFFICIENT_ALL_EPSILON_CLOSURE_H_ #define EFFICIENT_ALL_EPSILON_CLOSURE_H_ -#include <core/multipleDispatch.hpp> #include <set> #include <map> -#include "automaton/Automaton.h" -#include "automaton/AutomatonFeatures.h" - #include <automaton/FSM/ExtendedNFA.h> #include <automaton/FSM/CompactNFA.h> #include <automaton/FSM/EpsilonNFA.h> @@ -22,10 +18,6 @@ #include <automaton/FSM/NFA.h> #include <automaton/FSM/DFA.h> -#include <set> -#include <map> -#include <iostream> - #include <regexp/properties/RegExpEpsilon.h> namespace automaton { @@ -34,12 +26,10 @@ namespace properties { namespace efficient { -class AllEpsilonClosure : public alib::SingleDispatch<AllEpsilonClosure, ext::map<DefaultStateType, ext::set<DefaultStateType>>, const automaton::AutomatonBase &> { +class AllEpsilonClosure { template < class StateType > static void process(const ext::map<StateType, ext::set<StateType>>& epsilonTransitions, const StateType * state, ext::map<StateType, ext::set<StateType>>& closures, ext::set<StateType>& visited, ext::set<StateType>& nonvisited); public: - static ext::map<DefaultStateType, ext::set<DefaultStateType>> allEpsilonClosure( const automaton::Automaton & automaton); - /** * Computes allEpsilon closure of a state in allEpsilon nonfree automaton */ diff --git a/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp b/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp index 9a50330819..0dd8ab19c6 100644 --- a/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp +++ b/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp @@ -14,16 +14,12 @@ namespace properties { namespace efficient { -ext::set<DefaultStateType> ReachableStates::reachableStates(const Automaton& automaton) { - return dispatch(automaton.getData()); -} - -auto ReachableStatesEpsilonNFA = registration::OverloadRegister < ReachableStates, ext::set < DefaultStateType >, automaton::EpsilonNFA < > > ( ReachableStates::reachableStates ); -auto ReachableStatesNFA = registration::OverloadRegister < ReachableStates, ext::set < DefaultStateType >, automaton::NFA < > > ( ReachableStates::reachableStates ); -auto ReachableStatesCompactNFA = registration::OverloadRegister < ReachableStates, ext::set < DefaultStateType >, automaton::CompactNFA < > > ( ReachableStates::reachableStates ); -auto ReachableStatesExtendedNFA = registration::OverloadRegister < ReachableStates, ext::set < DefaultStateType >, automaton::ExtendedNFA < > > ( ReachableStates::reachableStates ); -auto ReachableStatesMultiInitialStateNFA = registration::OverloadRegister < ReachableStates, ext::set < DefaultStateType >, automaton::MultiInitialStateNFA < > > ( ReachableStates::reachableStates ); -auto ReachableStatesDFA = registration::OverloadRegister < ReachableStates, ext::set < DefaultStateType >, automaton::DFA < > > ( ReachableStates::reachableStates ); +auto ReachableStatesEpsilonNFA = registration::AbstractRegister < ReachableStates, ext::set < DefaultStateType >, const automaton::EpsilonNFA < > & > ( ReachableStates::reachableStates ); +auto ReachableStatesNFA = registration::AbstractRegister < ReachableStates, ext::set < DefaultStateType >, const automaton::NFA < > & > ( ReachableStates::reachableStates ); +auto ReachableStatesCompactNFA = registration::AbstractRegister < ReachableStates, ext::set < DefaultStateType >, const automaton::CompactNFA < > & > ( ReachableStates::reachableStates ); +auto ReachableStatesExtendedNFA = registration::AbstractRegister < ReachableStates, ext::set < DefaultStateType >, const automaton::ExtendedNFA < > & > ( ReachableStates::reachableStates ); +auto ReachableStatesMultiInitialStateNFA = registration::AbstractRegister < ReachableStates, ext::set < DefaultStateType >, const automaton::MultiInitialStateNFA < > & > ( ReachableStates::reachableStates ); +auto ReachableStatesDFA = registration::AbstractRegister < ReachableStates, ext::set < DefaultStateType >, const automaton::DFA < > & > ( ReachableStates::reachableStates ); } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/properties/efficient/ReachableStates.h b/alib2elgo/src/automaton/properties/efficient/ReachableStates.h index 91fc8e19a0..82b66de988 100644 --- a/alib2elgo/src/automaton/properties/efficient/ReachableStates.h +++ b/alib2elgo/src/automaton/properties/efficient/ReachableStates.h @@ -8,16 +8,12 @@ #ifndef EFFICIENT_REACHABLE_STATES_H_ #define EFFICIENT_REACHABLE_STATES_H_ -#include <core/multipleDispatch.hpp> #include <algorithm> #include <deque> #include <set> #include <map> -#include <queue> #include <automaton/Automaton.h> -#include <automaton/AutomatonFeatures.h> - #include <automaton/FSM/ExtendedNFA.h> #include <automaton/FSM/CompactNFA.h> #include <automaton/FSM/EpsilonNFA.h> @@ -30,10 +26,8 @@ namespace properties { namespace efficient { -class ReachableStates : public alib::SingleDispatch<ReachableStates, ext::set<DefaultStateType>, const automaton::AutomatonBase &> { +class ReachableStates { public: - static ext::set<DefaultStateType> reachableStates( const automaton::Automaton & automaton ); - /** * Removes dead states from FSM. Melichar 2.29 */ diff --git a/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp b/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp index f77e601518..dcfd2fc596 100644 --- a/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp +++ b/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp @@ -14,16 +14,12 @@ namespace properties { namespace efficient { -ext::set<DefaultStateType> UsefullStates::usefullStates(const Automaton& automaton) { - return dispatch(automaton.getData()); -} - -auto UsefullStatesEpsilonNFA = registration::OverloadRegister < UsefullStates, ext::set < DefaultStateType >, automaton::EpsilonNFA < > > ( UsefullStates::usefullStates ); -auto UsefullStatesNFA = registration::OverloadRegister < UsefullStates, ext::set < DefaultStateType >, automaton::NFA < > > ( UsefullStates::usefullStates ); -auto UsefullStatesCompactNFA = registration::OverloadRegister < UsefullStates, ext::set < DefaultStateType >, automaton::CompactNFA < > > ( UsefullStates::usefullStates ); -auto UsefullStatesExtendedNFA = registration::OverloadRegister < UsefullStates, ext::set < DefaultStateType >, automaton::ExtendedNFA < > > ( UsefullStates::usefullStates ); -auto UsefullStatesMultiInitialStateNFA = registration::OverloadRegister < UsefullStates, ext::set < DefaultStateType >, automaton::MultiInitialStateNFA < > > ( UsefullStates::usefullStates ); -auto UsefullStatesDFA = registration::OverloadRegister < UsefullStates, ext::set < DefaultStateType >, automaton::DFA < > > ( UsefullStates::usefullStates ); +auto UsefullStatesEpsilonNFA = registration::AbstractRegister < UsefullStates, ext::set < DefaultStateType >, const automaton::EpsilonNFA < > & > ( UsefullStates::usefullStates ); +auto UsefullStatesNFA = registration::AbstractRegister < UsefullStates, ext::set < DefaultStateType >, const automaton::NFA < > & > ( UsefullStates::usefullStates ); +auto UsefullStatesCompactNFA = registration::AbstractRegister < UsefullStates, ext::set < DefaultStateType >, const automaton::CompactNFA < > & > ( UsefullStates::usefullStates ); +auto UsefullStatesExtendedNFA = registration::AbstractRegister < UsefullStates, ext::set < DefaultStateType >, const automaton::ExtendedNFA < > & > ( UsefullStates::usefullStates ); +auto UsefullStatesMultiInitialStateNFA = registration::AbstractRegister < UsefullStates, ext::set < DefaultStateType >, const automaton::MultiInitialStateNFA < > & > ( UsefullStates::usefullStates ); +auto UsefullStatesDFA = registration::AbstractRegister < UsefullStates, ext::set < DefaultStateType >, const automaton::DFA < > & > ( UsefullStates::usefullStates ); } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/properties/efficient/UsefullStates.h b/alib2elgo/src/automaton/properties/efficient/UsefullStates.h index 51648a5771..c8be779645 100644 --- a/alib2elgo/src/automaton/properties/efficient/UsefullStates.h +++ b/alib2elgo/src/automaton/properties/efficient/UsefullStates.h @@ -8,16 +8,12 @@ #ifndef EFFICIENT_USEFULL_STATES_H_ #define EFFICIENT_USEFULL_STATES_H_ -#include <core/multipleDispatch.hpp> #include <algorithm> #include <deque> #include <set> #include <map> -#include <queue> #include <automaton/Automaton.h> -#include <automaton/AutomatonFeatures.h> - #include <automaton/FSM/ExtendedNFA.h> #include <automaton/FSM/CompactNFA.h> #include <automaton/FSM/EpsilonNFA.h> @@ -30,10 +26,8 @@ namespace properties { namespace efficient { -class UsefullStates : public alib::SingleDispatch<UsefullStates, ext::set<DefaultStateType>, const automaton::AutomatonBase &> { +class UsefullStates { public: - static ext::set<DefaultStateType> usefullStates( const automaton::Automaton & automaton ); - /** * Removes dead states from FSM. Melichar 2.32 */ diff --git a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.h b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.h index b53e585e20..28a48477b4 100644 --- a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.h +++ b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.h @@ -24,7 +24,7 @@ namespace simplify { namespace efficient { -class EpsilonRemoverOutgoing : public alib::SingleDispatch < EpsilonRemoverOutgoing, automaton::Automaton, const automaton::AutomatonBase & > { +class EpsilonRemoverOutgoing { public: /** * Computes epsilon closure of a state in epsilon nonfree automaton -- GitLab