diff --git a/aconvert2/src/DotConverter.cpp b/aconvert2/src/DotConverter.cpp index a524dc8ced3a2f05d218bca754e3bbfaa080c9cf..2faad1a1c8d9f08d3b91fa08db3b1df6d210fba3 100644 --- a/aconvert2/src/DotConverter.cpp +++ b/aconvert2/src/DotConverter.cpp @@ -48,7 +48,7 @@ auto replace = [](std::string& str, const std::string& what, const std::string& }; void DotConverter::convert(std::ostream& out, const automaton::Automaton& a) { - getInstance().dispatch(out, a.getData()); + dispatch(out, a.getData()); } void DotConverter::convert(std::ostream& out, const automaton::EpsilonNFA& a) { @@ -82,7 +82,7 @@ void DotConverter::convert(std::ostream& out, const automaton::EpsilonNFA& a) { out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::EpsilonNFA> DotConverterEpsilonNFA = DotConverter::RegistratorWrapper<void, automaton::EpsilonNFA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::EpsilonNFA> DotConverterEpsilonNFA = DotConverter::RegistratorWrapper<void, automaton::EpsilonNFA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::MultiInitialStateNFA& a) { out << "digraph automaton {\n"; @@ -117,7 +117,7 @@ void DotConverter::convert(std::ostream& out, const automaton::MultiInitialState out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::MultiInitialStateNFA> DotConverterMultiInitialStateNFA = DotConverter::RegistratorWrapper<void, automaton::MultiInitialStateNFA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::MultiInitialStateNFA> DotConverterMultiInitialStateNFA = DotConverter::RegistratorWrapper<void, automaton::MultiInitialStateNFA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::NFA& a) { out << "digraph automaton {\n"; @@ -150,7 +150,7 @@ void DotConverter::convert(std::ostream& out, const automaton::NFA& a) { out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::NFA> DotConverterNFA = DotConverter::RegistratorWrapper<void, automaton::NFA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::NFA> DotConverterNFA = DotConverter::RegistratorWrapper<void, automaton::NFA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::DFA& a) { out << "digraph automaton {\n"; @@ -183,7 +183,7 @@ void DotConverter::convert(std::ostream& out, const automaton::DFA& a) { out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::DFA> DotConverterDFA = DotConverter::RegistratorWrapper<void, automaton::DFA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::DFA> DotConverterDFA = DotConverter::RegistratorWrapper<void, automaton::DFA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::ExtendedNFA& a) { out << "digraph automaton {\n"; @@ -216,7 +216,7 @@ void DotConverter::convert(std::ostream& out, const automaton::ExtendedNFA& a) { out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::ExtendedNFA> DotConverterExtendedNFA = DotConverter::RegistratorWrapper<void, automaton::ExtendedNFA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::ExtendedNFA> DotConverterExtendedNFA = DotConverter::RegistratorWrapper<void, automaton::ExtendedNFA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::CompactNFA& a) { out << "digraph automaton {\n"; @@ -249,7 +249,7 @@ void DotConverter::convert(std::ostream& out, const automaton::CompactNFA& a) { out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::CompactNFA> DotConverterCompactNFA = DotConverter::RegistratorWrapper<void, automaton::CompactNFA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::CompactNFA> DotConverterCompactNFA = DotConverter::RegistratorWrapper<void, automaton::CompactNFA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::NFTA& a) { out << "digraph automaton {\n"; @@ -278,7 +278,7 @@ void DotConverter::convert(std::ostream& out, const automaton::NFTA& a) { out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::NFTA> DotConverterNFTA = DotConverter::RegistratorWrapper<void, automaton::NFTA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::NFTA> DotConverterNFTA = DotConverter::RegistratorWrapper<void, automaton::NFTA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::DFTA& a) { out << "digraph automaton {\n"; @@ -307,7 +307,7 @@ void DotConverter::convert(std::ostream& out, const automaton::DFTA& a) { out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::DFTA> DotConverterDFTA = DotConverter::RegistratorWrapper<void, automaton::DFTA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::DFTA> DotConverterDFTA = DotConverter::RegistratorWrapper<void, automaton::DFTA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::DPDA& a) { out << "digraph automaton {\n"; @@ -340,7 +340,7 @@ void DotConverter::convert(std::ostream& out, const automaton::DPDA& a) { out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::DPDA> DotConverterDPDA = DotConverter::RegistratorWrapper<void, automaton::DPDA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::DPDA> DotConverterDPDA = DotConverter::RegistratorWrapper<void, automaton::DPDA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::SinglePopDPDA& a) { out << "digraph automaton {\n"; @@ -373,7 +373,7 @@ void DotConverter::convert(std::ostream& out, const automaton::SinglePopDPDA& a) out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::SinglePopDPDA> DotConverterSinglePopDPDA = DotConverter::RegistratorWrapper<void, automaton::SinglePopDPDA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::SinglePopDPDA> DotConverterSinglePopDPDA = DotConverter::RegistratorWrapper<void, automaton::SinglePopDPDA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::InputDrivenDPDA& a) { out << "digraph automaton {\n"; @@ -406,7 +406,7 @@ void DotConverter::convert(std::ostream& out, const automaton::InputDrivenDPDA& out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::InputDrivenDPDA> DotConverterInputDrivenDPDA = DotConverter::RegistratorWrapper<void, automaton::InputDrivenDPDA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::InputDrivenDPDA> DotConverterInputDrivenDPDA = DotConverter::RegistratorWrapper<void, automaton::InputDrivenDPDA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::InputDrivenNPDA& a) { out << "digraph automaton {\n"; @@ -439,7 +439,7 @@ void DotConverter::convert(std::ostream& out, const automaton::InputDrivenNPDA& out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::InputDrivenNPDA> DotConverterInputDrivenNPDA = DotConverter::RegistratorWrapper<void, automaton::InputDrivenNPDA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::InputDrivenNPDA> DotConverterInputDrivenNPDA = DotConverter::RegistratorWrapper<void, automaton::InputDrivenNPDA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::VisiblyPushdownDPDA& a) { out << "digraph automaton {\n"; @@ -472,7 +472,7 @@ void DotConverter::convert(std::ostream& out, const automaton::VisiblyPushdownDP out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::VisiblyPushdownDPDA> DotConverterVisiblyPushdownDPDA = DotConverter::RegistratorWrapper<void, automaton::VisiblyPushdownDPDA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::VisiblyPushdownDPDA> DotConverterVisiblyPushdownDPDA = DotConverter::RegistratorWrapper<void, automaton::VisiblyPushdownDPDA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::VisiblyPushdownNPDA& a) { out << "digraph automaton {\n"; @@ -507,7 +507,7 @@ void DotConverter::convert(std::ostream& out, const automaton::VisiblyPushdownNP out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::VisiblyPushdownNPDA> DotConverterVisiblyPushdownNPDA = DotConverter::RegistratorWrapper<void, automaton::VisiblyPushdownNPDA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::VisiblyPushdownNPDA> DotConverterVisiblyPushdownNPDA = DotConverter::RegistratorWrapper<void, automaton::VisiblyPushdownNPDA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::RealTimeHeightDeterministicDPDA& a) { out << "digraph automaton {\n"; @@ -540,7 +540,7 @@ void DotConverter::convert(std::ostream& out, const automaton::RealTimeHeightDet out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicDPDA> DotConverterRealTimeHeightDeterministicDPDA = DotConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicDPDA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicDPDA> DotConverterRealTimeHeightDeterministicDPDA = DotConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicDPDA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::RealTimeHeightDeterministicNPDA& a) { out << "digraph automaton {\n"; @@ -575,7 +575,7 @@ void DotConverter::convert(std::ostream& out, const automaton::RealTimeHeightDet out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicNPDA> DotConverterRealTimeHeightDeterministicNPDA = DotConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicNPDA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicNPDA> DotConverterRealTimeHeightDeterministicNPDA = DotConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicNPDA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::NPDA& a) { out << "digraph automaton {\n"; @@ -608,7 +608,7 @@ void DotConverter::convert(std::ostream& out, const automaton::NPDA& a) { out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::NPDA> DotConverterNPDA = DotConverter::RegistratorWrapper<void, automaton::NPDA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::NPDA> DotConverterNPDA = DotConverter::RegistratorWrapper<void, automaton::NPDA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::SinglePopNPDA& a) { out << "digraph automaton {\n"; @@ -641,7 +641,7 @@ void DotConverter::convert(std::ostream& out, const automaton::SinglePopNPDA& a) out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::SinglePopNPDA> DotConverterSinglePopNPDA = DotConverter::RegistratorWrapper<void, automaton::SinglePopNPDA>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::SinglePopNPDA> DotConverterSinglePopNPDA = DotConverter::RegistratorWrapper<void, automaton::SinglePopNPDA>(DotConverter::convert); void DotConverter::convert(std::ostream& out, const automaton::OneTapeDTM& a) { out << "digraph automaton {\n"; @@ -674,7 +674,7 @@ void DotConverter::convert(std::ostream& out, const automaton::OneTapeDTM& a) { out << "}"; } -DotConverter::RegistratorWrapper<void, automaton::OneTapeDTM> DotConverterOneTapeDTM = DotConverter::RegistratorWrapper<void, automaton::OneTapeDTM>(DotConverter::getInstance(), DotConverter::convert); +DotConverter::RegistratorWrapper<void, automaton::OneTapeDTM> DotConverterOneTapeDTM = DotConverter::RegistratorWrapper<void, automaton::OneTapeDTM>(DotConverter::convert); void DotConverter::transitions(const automaton::EpsilonNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out) { std::map<std::pair<int, int>, std::string> transitions; diff --git a/aconvert2/src/DotConverter.h b/aconvert2/src/DotConverter.h index cfc152b46ff0a22083cbe3fd209c37e72a36c3e5..02e7ce5914a5fbe13779e9a55d9ceec00d212eae 100644 --- a/aconvert2/src/DotConverter.h +++ b/aconvert2/src/DotConverter.h @@ -17,7 +17,7 @@ #include <map> #include <utility> -class DotConverter : public std::SingleDispatchFirstStaticParam<void, std::ostream&, automaton::AutomatonBase> { +class DotConverter : public std::SingleDispatchFirstStaticParam<DotConverter, void, std::ostream&, automaton::AutomatonBase> { static void transitions(const automaton::EpsilonNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); static void transitions(const automaton::MultiInitialStateNFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); static void transitions(const automaton::NFA& fsm, const std::map<automaton::State, int>& states, std::ostream& out); @@ -59,11 +59,6 @@ public: static void convert(std::ostream& out, const automaton::NPDA& a); static void convert(std::ostream& out, const automaton::SinglePopNPDA& a); static void convert(std::ostream& out, const automaton::OneTapeDTM& a); - - static DotConverter& getInstance() { - static DotConverter res; - return res; - } }; #endif /* DOT_CONVERTER_H_ */ diff --git a/aconvert2/src/GasTexConverter.cpp b/aconvert2/src/GasTexConverter.cpp index 73eafdeb2e7f82e24cc354b209f630038de542e9..3b4ae3de9ab095e9b14a710d4092fd85e3a98fc2 100644 --- a/aconvert2/src/GasTexConverter.cpp +++ b/aconvert2/src/GasTexConverter.cpp @@ -35,7 +35,7 @@ #include "exception/CommonException.h" void GasTexConverter::convert(std::ostream& out, const automaton::Automaton& a) { - getInstance().dispatch(out, a.getData()); + dispatch(out, a.getData()); } void GasTexConverter::convert(std::ostream& out, const automaton::EpsilonNFA& a) { @@ -77,7 +77,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::EpsilonNFA& a) out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::EpsilonNFA> GasTexConverterEpsilonNFA = GasTexConverter::RegistratorWrapper<void, automaton::EpsilonNFA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::EpsilonNFA> GasTexConverterEpsilonNFA = GasTexConverter::RegistratorWrapper<void, automaton::EpsilonNFA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::MultiInitialStateNFA& a) { out << "\\begin{center}\n"; @@ -118,7 +118,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::MultiInitialSt out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::MultiInitialStateNFA> GasTexConverterMultiInitialStateNFA = GasTexConverter::RegistratorWrapper<void, automaton::MultiInitialStateNFA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::MultiInitialStateNFA> GasTexConverterMultiInitialStateNFA = GasTexConverter::RegistratorWrapper<void, automaton::MultiInitialStateNFA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::NFA& a) { out << "\\begin{center}\n"; @@ -159,7 +159,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::NFA& a) { out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::NFA> GasTexConverterNFA = GasTexConverter::RegistratorWrapper<void, automaton::NFA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::NFA> GasTexConverterNFA = GasTexConverter::RegistratorWrapper<void, automaton::NFA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::DFA& a) { out << "\\begin{center}\n"; @@ -200,7 +200,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::DFA& a) { out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::DFA> GasTexConverterDFA = GasTexConverter::RegistratorWrapper<void, automaton::DFA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::DFA> GasTexConverterDFA = GasTexConverter::RegistratorWrapper<void, automaton::DFA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::ExtendedNFA& a) { out << "\\begin{center}\n"; @@ -241,7 +241,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::ExtendedNFA& a out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::ExtendedNFA> GasTexConverterExtendedNFA = GasTexConverter::RegistratorWrapper<void, automaton::ExtendedNFA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::ExtendedNFA> GasTexConverterExtendedNFA = GasTexConverter::RegistratorWrapper<void, automaton::ExtendedNFA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::CompactNFA& a) { out << "\\begin{center}\n"; @@ -282,19 +282,19 @@ void GasTexConverter::convert(std::ostream& out, const automaton::CompactNFA& a) out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::CompactNFA> GasTexConverterCompactNFA = GasTexConverter::RegistratorWrapper<void, automaton::CompactNFA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::CompactNFA> GasTexConverterCompactNFA = GasTexConverter::RegistratorWrapper<void, automaton::CompactNFA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream&, const automaton::NFTA&) { //TODO } -GasTexConverter::RegistratorWrapper<void, automaton::NFTA> GasTexConverterNFTA = GasTexConverter::RegistratorWrapper<void, automaton::NFTA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::NFTA> GasTexConverterNFTA = GasTexConverter::RegistratorWrapper<void, automaton::NFTA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream&, const automaton::DFTA&) { //TODO } -GasTexConverter::RegistratorWrapper<void, automaton::DFTA> GasTexConverterDFTA = GasTexConverter::RegistratorWrapper<void, automaton::DFTA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::DFTA> GasTexConverterDFTA = GasTexConverter::RegistratorWrapper<void, automaton::DFTA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::DPDA& a) { out << "\\begin{center}\n"; @@ -335,7 +335,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::DPDA& a) { out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::DPDA> GasTexConverterDPDA = GasTexConverter::RegistratorWrapper<void, automaton::DPDA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::DPDA> GasTexConverterDPDA = GasTexConverter::RegistratorWrapper<void, automaton::DPDA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::SinglePopDPDA& a) { out << "\\begin{center}\n"; @@ -376,7 +376,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::SinglePopDPDA& out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::SinglePopDPDA> GasTexConverterSinglePopDPDA = GasTexConverter::RegistratorWrapper<void, automaton::SinglePopDPDA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::SinglePopDPDA> GasTexConverterSinglePopDPDA = GasTexConverter::RegistratorWrapper<void, automaton::SinglePopDPDA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::InputDrivenDPDA& a) { out << "\\begin{center}\n"; @@ -417,7 +417,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::InputDrivenDPD out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::InputDrivenDPDA> GasTexConverterInputDrivenDPDA = GasTexConverter::RegistratorWrapper<void, automaton::InputDrivenDPDA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::InputDrivenDPDA> GasTexConverterInputDrivenDPDA = GasTexConverter::RegistratorWrapper<void, automaton::InputDrivenDPDA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::InputDrivenNPDA& a) { out << "\\begin{center}\n"; @@ -458,7 +458,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::InputDrivenNPD out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::InputDrivenNPDA> GasTexConverterInputDrivenNPDA = GasTexConverter::RegistratorWrapper<void, automaton::InputDrivenNPDA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::InputDrivenNPDA> GasTexConverterInputDrivenNPDA = GasTexConverter::RegistratorWrapper<void, automaton::InputDrivenNPDA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::VisiblyPushdownDPDA& a) { out << "\\begin{center}\n"; @@ -499,7 +499,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::VisiblyPushdow out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::VisiblyPushdownDPDA> GasTexConverterVisiblyPushdownDPDA = GasTexConverter::RegistratorWrapper<void, automaton::VisiblyPushdownDPDA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::VisiblyPushdownDPDA> GasTexConverterVisiblyPushdownDPDA = GasTexConverter::RegistratorWrapper<void, automaton::VisiblyPushdownDPDA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::VisiblyPushdownNPDA& a) { out << "\\begin{center}\n"; @@ -540,7 +540,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::VisiblyPushdow out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::VisiblyPushdownNPDA> GasTexConverterVisiblyPushdownNPDA = GasTexConverter::RegistratorWrapper<void, automaton::VisiblyPushdownNPDA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::VisiblyPushdownNPDA> GasTexConverterVisiblyPushdownNPDA = GasTexConverter::RegistratorWrapper<void, automaton::VisiblyPushdownNPDA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::RealTimeHeightDeterministicDPDA& a) { out << "\\begin{center}\n"; @@ -581,7 +581,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::RealTimeHeight out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicDPDA> GasTexConverterRealTimeHeightDeterministicDPDA = GasTexConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicDPDA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicDPDA> GasTexConverterRealTimeHeightDeterministicDPDA = GasTexConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicDPDA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::RealTimeHeightDeterministicNPDA& a) { out << "\\begin{center}\n"; @@ -622,7 +622,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::RealTimeHeight out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicNPDA> GasTexConverterRealTimeHeightDeterministicNPDA = GasTexConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicNPDA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicNPDA> GasTexConverterRealTimeHeightDeterministicNPDA = GasTexConverter::RegistratorWrapper<void, automaton::RealTimeHeightDeterministicNPDA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::NPDA& a) { out << "\\begin{center}\n"; @@ -663,7 +663,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::NPDA& a) { out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::NPDA> GasTexConverterNPDA = GasTexConverter::RegistratorWrapper<void, automaton::NPDA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::NPDA> GasTexConverterNPDA = GasTexConverter::RegistratorWrapper<void, automaton::NPDA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::SinglePopNPDA& a) { out << "\\begin{center}\n"; @@ -704,7 +704,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::SinglePopNPDA& out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::SinglePopNPDA> GasTexConverterSinglePopNPDA = GasTexConverter::RegistratorWrapper<void, automaton::SinglePopNPDA>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::SinglePopNPDA> GasTexConverterSinglePopNPDA = GasTexConverter::RegistratorWrapper<void, automaton::SinglePopNPDA>(GasTexConverter::convert); void GasTexConverter::convert(std::ostream& out, const automaton::OneTapeDTM& a) { out << "\\begin{center}\n"; @@ -745,7 +745,7 @@ void GasTexConverter::convert(std::ostream& out, const automaton::OneTapeDTM& a) out << "\\end{picture}\n"; } -GasTexConverter::RegistratorWrapper<void, automaton::OneTapeDTM> GasTexConverterOneTapeDTM = GasTexConverter::RegistratorWrapper<void, automaton::OneTapeDTM>(GasTexConverter::getInstance(), GasTexConverter::convert); +GasTexConverter::RegistratorWrapper<void, automaton::OneTapeDTM> GasTexConverterOneTapeDTM = GasTexConverter::RegistratorWrapper<void, automaton::OneTapeDTM>(GasTexConverter::convert); std::string GasTexConverter::getStackSymbols(const std::vector<alphabet::Symbol>& stackSymbols) { if (stackSymbols.size() == 0) { diff --git a/aconvert2/src/GasTexConverter.h b/aconvert2/src/GasTexConverter.h index 70a98afb0f596fadb25c26fb284c3368685bcf44..11c63a09a6b288b6c4acd6523bcc9a7237bff8a7 100644 --- a/aconvert2/src/GasTexConverter.h +++ b/aconvert2/src/GasTexConverter.h @@ -16,7 +16,7 @@ #include "automaton/Automaton.h" #include "alphabet/Symbol.h" -class GasTexConverter : public std::SingleDispatchFirstStaticParam<void, std::ostream&, automaton::AutomatonBase> { +class GasTexConverter : public std::SingleDispatchFirstStaticParam<GasTexConverter, void, std::ostream&, automaton::AutomatonBase> { static void printTransitionMap( const std::map<std::pair<std::string, std::string>, std::string> transitionMap, std::ostream& out); static std::string getStackSymbols(const std::vector<alphabet::Symbol>& stackSymbols); @@ -61,11 +61,6 @@ public: static void convert(std::ostream& out, const automaton::NPDA& a); static void convert(std::ostream& out, const automaton::SinglePopNPDA& a); static void convert(std::ostream& out, const automaton::OneTapeDTM& a); - - static GasTexConverter& getInstance() { - static GasTexConverter res; - return res; - } }; #endif /* GAS_TEX_CONVERTER_H_ */ diff --git a/aconvert2/src/TikZConverter.cpp b/aconvert2/src/TikZConverter.cpp index 20f46c4678064faf7de81b55e49eb11c115d5d97..3719517579792dc13121c22f1414db858c5c1401 100644 --- a/aconvert2/src/TikZConverter.cpp +++ b/aconvert2/src/TikZConverter.cpp @@ -49,7 +49,7 @@ auto replace = [] ( std::string & str, const std::string & what, const std::stri }; void TikZConverter::convert ( std::ostream & out, const automaton::Automaton & a ) { - getInstance ( ).dispatch ( out, a.getData ( ) ); + dispatch ( out, a.getData ( ) ); } void TikZConverter::convert ( std::ostream & out, const automaton::EpsilonNFA & a ) { @@ -79,7 +79,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::EpsilonNFA & out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::EpsilonNFA > TikZConverterEpsilonNFA = TikZConverter::RegistratorWrapper < void, automaton::EpsilonNFA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::EpsilonNFA > TikZConverterEpsilonNFA = TikZConverter::RegistratorWrapper < void, automaton::EpsilonNFA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::MultiInitialStateNFA & a ) { out << "\\begin{tikzpicture}\n"; @@ -108,7 +108,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::MultiInitialS out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::MultiInitialStateNFA > TikZConverterMultiInitialStateNFA = TikZConverter::RegistratorWrapper < void, automaton::MultiInitialStateNFA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::MultiInitialStateNFA > TikZConverterMultiInitialStateNFA = TikZConverter::RegistratorWrapper < void, automaton::MultiInitialStateNFA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::NFA & a ) { out << "\\begin{tikzpicture}\n"; @@ -137,7 +137,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::NFA & a ) { out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::NFA > TikZConverterNFA = TikZConverter::RegistratorWrapper < void, automaton::NFA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::NFA > TikZConverterNFA = TikZConverter::RegistratorWrapper < void, automaton::NFA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::DFA & a ) { out << "\\begin{tikzpicture}\n"; @@ -166,7 +166,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::DFA & a ) { out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::DFA > TikZConverterDFA = TikZConverter::RegistratorWrapper < void, automaton::DFA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::DFA > TikZConverterDFA = TikZConverter::RegistratorWrapper < void, automaton::DFA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::ExtendedNFA & a ) { out << "\\begin{tikzpicture}\n"; @@ -195,7 +195,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::ExtendedNFA & out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::ExtendedNFA > TikZConverterExtendedNFA = TikZConverter::RegistratorWrapper < void, automaton::ExtendedNFA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::ExtendedNFA > TikZConverterExtendedNFA = TikZConverter::RegistratorWrapper < void, automaton::ExtendedNFA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::CompactNFA & a ) { out << "\\begin{tikzpicture}\n"; @@ -224,7 +224,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::CompactNFA & out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::CompactNFA > TikZConverterCompactNFA = TikZConverter::RegistratorWrapper < void, automaton::CompactNFA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::CompactNFA > TikZConverterCompactNFA = TikZConverter::RegistratorWrapper < void, automaton::CompactNFA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::NFTA & a ) { out << "\\begin{tikzpicture}\n"; @@ -250,7 +250,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::NFTA & a ) { out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::NFTA > TikZConverterNFTA = TikZConverter::RegistratorWrapper < void, automaton::NFTA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::NFTA > TikZConverterNFTA = TikZConverter::RegistratorWrapper < void, automaton::NFTA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::DFTA & a ) { out << "\\begin{tikzpicture}\n"; @@ -276,7 +276,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::DFTA & a ) { out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::DFTA > TikZConverterDFTA = TikZConverter::RegistratorWrapper < void, automaton::DFTA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::DFTA > TikZConverterDFTA = TikZConverter::RegistratorWrapper < void, automaton::DFTA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::DPDA & a ) { out << "\\begin{tikzpicture}\n"; @@ -305,7 +305,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::DPDA & a ) { out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::DPDA > TikZConverterDPDA = TikZConverter::RegistratorWrapper < void, automaton::DPDA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::DPDA > TikZConverterDPDA = TikZConverter::RegistratorWrapper < void, automaton::DPDA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::SinglePopDPDA & a ) { out << "\\begin{tikzpicture}\n"; @@ -334,7 +334,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::SinglePopDPDA out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::SinglePopDPDA > TikZConverterSinglePopDPDA = TikZConverter::RegistratorWrapper < void, automaton::SinglePopDPDA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::SinglePopDPDA > TikZConverterSinglePopDPDA = TikZConverter::RegistratorWrapper < void, automaton::SinglePopDPDA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::InputDrivenDPDA & a ) { out << "\\begin{tikzpicture}\n"; @@ -363,7 +363,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::InputDrivenDP out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::InputDrivenDPDA > TikZConverterInputDrivenDPDA = TikZConverter::RegistratorWrapper < void, automaton::InputDrivenDPDA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::InputDrivenDPDA > TikZConverterInputDrivenDPDA = TikZConverter::RegistratorWrapper < void, automaton::InputDrivenDPDA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::InputDrivenNPDA & a ) { out << "\\begin{tikzpicture}\n"; @@ -392,7 +392,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::InputDrivenNP out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::InputDrivenNPDA > TikZConverterInputDrivenNPDA = TikZConverter::RegistratorWrapper < void, automaton::InputDrivenNPDA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::InputDrivenNPDA > TikZConverterInputDrivenNPDA = TikZConverter::RegistratorWrapper < void, automaton::InputDrivenNPDA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::VisiblyPushdownDPDA & a ) { out << "\\begin{tikzpicture}\n"; @@ -421,7 +421,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::VisiblyPushdo out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::VisiblyPushdownDPDA > TikZConverterVisiblyPushdownDPDA = TikZConverter::RegistratorWrapper < void, automaton::VisiblyPushdownDPDA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::VisiblyPushdownDPDA > TikZConverterVisiblyPushdownDPDA = TikZConverter::RegistratorWrapper < void, automaton::VisiblyPushdownDPDA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::VisiblyPushdownNPDA & a ) { out << "\\begin{tikzpicture}\n"; @@ -450,7 +450,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::VisiblyPushdo out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::VisiblyPushdownNPDA > TikZConverterVisiblyPushdownNPDA = TikZConverter::RegistratorWrapper < void, automaton::VisiblyPushdownNPDA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::VisiblyPushdownNPDA > TikZConverterVisiblyPushdownNPDA = TikZConverter::RegistratorWrapper < void, automaton::VisiblyPushdownNPDA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::RealTimeHeightDeterministicDPDA & a ) { out << "\\begin{tikzpicture}\n"; @@ -479,7 +479,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::RealTimeHeigh out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::RealTimeHeightDeterministicDPDA > TikZConverterRealTimeHeightDeterministicDPDA = TikZConverter::RegistratorWrapper < void, automaton::RealTimeHeightDeterministicDPDA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::RealTimeHeightDeterministicDPDA > TikZConverterRealTimeHeightDeterministicDPDA = TikZConverter::RegistratorWrapper < void, automaton::RealTimeHeightDeterministicDPDA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::RealTimeHeightDeterministicNPDA & a ) { out << "\\begin{tikzpicture}\n"; @@ -508,7 +508,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::RealTimeHeigh out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::RealTimeHeightDeterministicNPDA > TikZConverterRealTimeHeightDeterministicNPDA = TikZConverter::RegistratorWrapper < void, automaton::RealTimeHeightDeterministicNPDA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::RealTimeHeightDeterministicNPDA > TikZConverterRealTimeHeightDeterministicNPDA = TikZConverter::RegistratorWrapper < void, automaton::RealTimeHeightDeterministicNPDA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::NPDA & a ) { out << "\\begin{tikzpicture}\n"; @@ -537,7 +537,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::NPDA & a ) { out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::NPDA > TikZConverterNPDA = TikZConverter::RegistratorWrapper < void, automaton::NPDA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::NPDA > TikZConverterNPDA = TikZConverter::RegistratorWrapper < void, automaton::NPDA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::SinglePopNPDA & a ) { out << "\\begin{tikzpicture}\n"; @@ -566,7 +566,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::SinglePopNPDA out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::SinglePopNPDA > TikZConverterSinglePopNPDA = TikZConverter::RegistratorWrapper < void, automaton::SinglePopNPDA > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::SinglePopNPDA > TikZConverterSinglePopNPDA = TikZConverter::RegistratorWrapper < void, automaton::SinglePopNPDA > ( TikZConverter::convert ); void TikZConverter::convert ( std::ostream & out, const automaton::OneTapeDTM & a ) { out << "\\begin{tikzpicture}\n"; @@ -595,7 +595,7 @@ void TikZConverter::convert ( std::ostream & out, const automaton::OneTapeDTM & out << "\\end{tikzpicture}"; } -TikZConverter::RegistratorWrapper < void, automaton::OneTapeDTM > TikZConverterOneTapeDTM = TikZConverter::RegistratorWrapper < void, automaton::OneTapeDTM > ( TikZConverter::getInstance ( ), TikZConverter::convert ); +TikZConverter::RegistratorWrapper < void, automaton::OneTapeDTM > TikZConverterOneTapeDTM = TikZConverter::RegistratorWrapper < void, automaton::OneTapeDTM > ( TikZConverter::convert ); void TikZConverter::transitions ( const automaton::EpsilonNFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ) { std::map < std::pair < int, int >, std::string > transitions; diff --git a/aconvert2/src/TikZConverter.h b/aconvert2/src/TikZConverter.h index e9c7508372377eaf9f36639be5ca1864322bf08c..7a6304b20c260befc793fd888cf1f7236b7ecd97 100644 --- a/aconvert2/src/TikZConverter.h +++ b/aconvert2/src/TikZConverter.h @@ -17,7 +17,7 @@ #include <map> #include <utility> -class TikZConverter : public std::SingleDispatchFirstStaticParam < void, std::ostream &, automaton::AutomatonBase > { +class TikZConverter : public std::SingleDispatchFirstStaticParam < TikZConverter, void, std::ostream &, automaton::AutomatonBase > { static void transitions ( const automaton::EpsilonNFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ); static void transitions ( const automaton::MultiInitialStateNFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ); static void transitions ( const automaton::NFA & fsm, const std::map < automaton::State, int > & states, std::ostream & out ); @@ -61,12 +61,6 @@ public: static void convert ( std::ostream & out, const automaton::SinglePopNPDA & a ); static void convert ( std::ostream & out, const automaton::OneTapeDTM & a ); - static TikZConverter & getInstance ( ) { - static TikZConverter res; - - return res; - } - }; #endif /* TIKZ_CONVERTER_H_ */ diff --git a/alib2algo/src/arbology/exact/BadCharacterShiftTable.cpp b/alib2algo/src/arbology/exact/BadCharacterShiftTable.cpp index 94cf204adeaf50fc2ec78ec4d3d0afa09707c6fe..9fa0b5aa779d4c4de6ab4528a4b1b11a9634a22f 100644 --- a/alib2algo/src/arbology/exact/BadCharacterShiftTable.cpp +++ b/alib2algo/src/arbology/exact/BadCharacterShiftTable.cpp @@ -14,7 +14,7 @@ namespace arbology { namespace exact { std::map < alphabet::RankedSymbol, size_t > BadCharacterShiftTable::bcs ( const tree::RankedTreeWrapper & pattern ) { - return getInstance ( ).dispatch ( pattern.getData ( ) ); + return dispatch ( pattern.getData ( ) ); } std::map < alphabet::RankedSymbol, size_t > BadCharacterShiftTable::bcs ( const tree::PrefixRankedBarPattern & pattern ) { @@ -70,7 +70,7 @@ std::map < alphabet::RankedSymbol, size_t > BadCharacterShiftTable::bcs ( const return bcs; } -auto BadCharacterShiftTablePrefixRankedBarPattern = BadCharacterShiftTable::RegistratorWrapper < std::map < alphabet::RankedSymbol, size_t >, tree::PrefixRankedBarPattern > ( BadCharacterShiftTable::getInstance ( ), BadCharacterShiftTable::bcs ); +auto BadCharacterShiftTablePrefixRankedBarPattern = BadCharacterShiftTable::RegistratorWrapper < std::map < alphabet::RankedSymbol, size_t >, tree::PrefixRankedBarPattern > ( BadCharacterShiftTable::bcs ); } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/BadCharacterShiftTable.h b/alib2algo/src/arbology/exact/BadCharacterShiftTable.h index 4772ce30c33261fe03c61c1ffa004f2f7f3eb64e..fd09c8cdfc511332e28c686a80bb71474ff5a065 100644 --- a/alib2algo/src/arbology/exact/BadCharacterShiftTable.h +++ b/alib2algo/src/arbology/exact/BadCharacterShiftTable.h @@ -24,7 +24,7 @@ namespace exact { * Computation of BCS table for BMH from MI(E+\eps)-EVY course 2014 * To get rid of zeros in BCS table we ignore last haystack character */ -class BadCharacterShiftTable : public std::SingleDispatch < std::map < alphabet::RankedSymbol, size_t >, tree::RankedTreeBase > { +class BadCharacterShiftTable : public std::SingleDispatch < BadCharacterShiftTable, std::map < alphabet::RankedSymbol, size_t >, tree::RankedTreeBase > { public: /** * Search for pattern in linear string. @@ -34,12 +34,6 @@ public: static std::map < alphabet::RankedSymbol, size_t > bcs ( const tree::PrefixRankedBarPattern & pattern ); - static BadCharacterShiftTable & getInstance ( ) { - static BadCharacterShiftTable res; - - return res; - } - }; } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/BorderArrayNaive.cpp b/alib2algo/src/arbology/exact/BorderArrayNaive.cpp index ccc4a0e4f7380520b2053dfc6bd07e7aebdbf35b..ad466a71915132215714a3667840306ecfd15971 100644 --- a/alib2algo/src/arbology/exact/BorderArrayNaive.cpp +++ b/alib2algo/src/arbology/exact/BorderArrayNaive.cpp @@ -18,7 +18,7 @@ namespace arbology { namespace exact { std::vector < size_t > BorderArrayNaive::ba ( const tree::Tree & pattern ) { - return getInstance ( ).dispatch ( pattern.getData ( ) ); + return dispatch ( pattern.getData ( ) ); } bool BorderArrayNaive::matches ( const tree::PrefixRankedBarPattern & pattern, const std::vector < int > & subtreeJumpTable, int stop, int offset ) { @@ -65,7 +65,7 @@ std::vector < size_t > BorderArrayNaive::ba ( const tree::PrefixRankedBarPattern return res; } -auto BorderArrayPrefixRankedBarPattern = BorderArrayNaive::RegistratorWrapper < std::vector < size_t >, tree::PrefixRankedBarPattern > ( BorderArrayNaive::getInstance ( ), BorderArrayNaive::ba ); +auto BorderArrayPrefixRankedBarPattern = BorderArrayNaive::RegistratorWrapper < std::vector < size_t >, tree::PrefixRankedBarPattern > ( BorderArrayNaive::ba ); bool BorderArrayNaive::matches ( const tree::PrefixRankedPattern & pattern, const std::vector < int > & subtreeJumpTable, int stop, int offset ) { unsigned i = 0; @@ -111,7 +111,7 @@ std::vector < size_t > BorderArrayNaive::ba ( const tree::PrefixRankedPattern & return res; } -auto BorderArrayPrefixRankedPattern = BorderArrayNaive::RegistratorWrapper < std::vector < size_t >, tree::PrefixRankedPattern > ( BorderArrayNaive::getInstance ( ), BorderArrayNaive::ba ); +auto BorderArrayPrefixRankedPattern = BorderArrayNaive::RegistratorWrapper < std::vector < size_t >, tree::PrefixRankedPattern > ( BorderArrayNaive::ba ); } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/BorderArrayNaive.h b/alib2algo/src/arbology/exact/BorderArrayNaive.h index ad5f318dde04c088e2073ffa0d00fbca99cc73e7..2a576a6ea89c4facdf0bd373cd35f272e1b45c4c 100644 --- a/alib2algo/src/arbology/exact/BorderArrayNaive.h +++ b/alib2algo/src/arbology/exact/BorderArrayNaive.h @@ -21,7 +21,7 @@ namespace exact { * Computation of BCS table for BMH from MI(E+\eps)-EVY course 2014 * To get rid of zeros in BCS table we ignore last haystack character */ -class BorderArrayNaive : public std::SingleDispatch < std::vector < size_t >, tree::TreeBase > { +class BorderArrayNaive : public std::SingleDispatch < BorderArrayNaive, std::vector < size_t >, tree::TreeBase > { static bool matches ( const tree::PrefixRankedBarPattern & pattern, const std::vector < int > & subtreeJumpTable, int stop, int offset ); static bool matches ( const tree::PrefixRankedPattern & pattern, const std::vector < int > & subtreeJumpTable, int stop, int offset ); @@ -45,12 +45,6 @@ public: */ static std::vector < size_t > ba ( const tree::PrefixRankedPattern & pattern ); - static BorderArrayNaive & getInstance ( ) { - static BorderArrayNaive res; - - return res; - } - }; } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ExactPatternMatchingAutomaton.cpp b/alib2algo/src/arbology/exact/ExactPatternMatchingAutomaton.cpp index 5ef25719bb6581825b13b80590ada4dbe7acf810..2ec5ce847ffca6e873873c53f4d9331b7e6e6922 100644 --- a/alib2algo/src/arbology/exact/ExactPatternMatchingAutomaton.cpp +++ b/alib2algo/src/arbology/exact/ExactPatternMatchingAutomaton.cpp @@ -30,14 +30,14 @@ namespace arbology { namespace exact { automaton::Automaton ExactPatternMatchingAutomaton::construct ( const tree::Tree & pattern ) { - return getInstance ( ).dispatch ( pattern.getData ( ) ); + return dispatch ( pattern.getData ( ) ); } automaton::InputDrivenNPDA ExactPatternMatchingAutomaton::construct ( const tree::PrefixRankedTree & pattern ) { return ExactSubtreeMatchingAutomaton::construct ( pattern ); } -auto ExactPatternMatchingAutomatonPrefixRankedTree = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedTree > ( ExactPatternMatchingAutomaton::getInstance ( ), ExactPatternMatchingAutomaton::construct ); +auto ExactPatternMatchingAutomatonPrefixRankedTree = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedTree > ( ExactPatternMatchingAutomaton::construct ); std::vector < alphabet::Symbol > computeRHS ( const tree::PrefixRankedPattern & pattern, const std::vector < int > & patternSubtreeJumpTable, int i ) { const std::vector < alphabet::RankedSymbol > & content = pattern.getContent ( ); @@ -115,13 +115,13 @@ automaton::NPDA ExactPatternMatchingAutomaton::construct ( const tree::PrefixRan return res; } -auto ExactPatternMatchingAutomatonPrefixRankedPattern = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::NPDA, tree::PrefixRankedPattern > ( ExactPatternMatchingAutomaton::getInstance ( ), ExactPatternMatchingAutomaton::construct ); +auto ExactPatternMatchingAutomatonPrefixRankedPattern = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::NPDA, tree::PrefixRankedPattern > ( ExactPatternMatchingAutomaton::construct ); automaton::InputDrivenNPDA ExactPatternMatchingAutomaton::construct ( const tree::PrefixRankedBarTree & pattern ) { return ExactSubtreeMatchingAutomaton::construct ( pattern ); } -auto ExactPatternMatchingAutomatonPrefixRankedBarTree = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedBarTree > ( ExactPatternMatchingAutomaton::getInstance ( ), ExactPatternMatchingAutomaton::construct ); +auto ExactPatternMatchingAutomatonPrefixRankedBarTree = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedBarTree > ( ExactPatternMatchingAutomaton::construct ); automaton::VisiblyPushdownNPDA ExactPatternMatchingAutomaton::construct ( const tree::PrefixRankedBarPattern & pattern ) { automaton::VisiblyPushdownNPDA res ( alphabet::Symbol { alphabet::BottomOfTheStackSymbol::BOTTOM_OF_THE_STACK } ); @@ -188,13 +188,13 @@ automaton::VisiblyPushdownNPDA ExactPatternMatchingAutomaton::construct ( const return res; } -auto ExactPatternMatchingAutomatonPrefixRankedBarPattern = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::VisiblyPushdownNPDA, tree::PrefixRankedBarPattern > ( ExactPatternMatchingAutomaton::getInstance ( ), ExactPatternMatchingAutomaton::construct ); +auto ExactPatternMatchingAutomatonPrefixRankedBarPattern = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::VisiblyPushdownNPDA, tree::PrefixRankedBarPattern > ( ExactPatternMatchingAutomaton::construct ); automaton::NFTA ExactPatternMatchingAutomaton::construct ( const tree::RankedTree & pattern ) { return ExactSubtreeMatchingAutomaton::construct ( pattern ); } -auto ExactPatternMatchingAutomatonRankedTree = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::NFTA, tree::RankedTree > ( ExactPatternMatchingAutomaton::getInstance ( ), ExactPatternMatchingAutomaton::construct ); +auto ExactPatternMatchingAutomatonRankedTree = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::NFTA, tree::RankedTree > ( ExactPatternMatchingAutomaton::construct ); automaton::State constructRecursivePattern ( const tree::RankedNode & node, automaton::NFTA & res, const alphabet::RankedSymbol & subtreeWildcard, const automaton::State & loopState, int & nextState ) { if ( node.getSymbol ( ) == subtreeWildcard ) { @@ -253,7 +253,7 @@ automaton::NFTA ExactPatternMatchingAutomaton::construct ( const tree::RankedPat return res; } -auto ExactPatternMatchingAutomatonRankedPattern = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::NFTA, tree::RankedPattern > ( ExactPatternMatchingAutomaton::getInstance ( ), ExactPatternMatchingAutomaton::construct ); +auto ExactPatternMatchingAutomatonRankedPattern = ExactPatternMatchingAutomaton::RegistratorWrapper < automaton::NFTA, tree::RankedPattern > ( ExactPatternMatchingAutomaton::construct ); } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ExactPatternMatchingAutomaton.h b/alib2algo/src/arbology/exact/ExactPatternMatchingAutomaton.h index e8dd38a5b23c5c9ad5f9e57ac27080ac1b28526d..6973d1b22e63938fe71bb4f5eadc229689f88e9e 100644 --- a/alib2algo/src/arbology/exact/ExactPatternMatchingAutomaton.h +++ b/alib2algo/src/arbology/exact/ExactPatternMatchingAutomaton.h @@ -17,10 +17,8 @@ namespace arbology { namespace exact { -class ExactPatternMatchingAutomaton : public std::SingleDispatch < automaton::Automaton, tree::TreeBase > { +class ExactPatternMatchingAutomaton : public std::SingleDispatch < ExactPatternMatchingAutomaton, automaton::Automaton, tree::TreeBase > { public: - ExactPatternMatchingAutomaton ( ) { } - /** * Performs conversion. * @return left regular grammar equivalent to source automaton. @@ -34,12 +32,6 @@ public: static automaton::NFTA construct ( const tree::RankedTree & pattern ); static automaton::NFTA construct ( const tree::RankedPattern & pattern ); - static ExactPatternMatchingAutomaton & getInstance ( ) { - static ExactPatternMatchingAutomaton res; - - return res; - } - }; } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ExactSubtreeAutomaton.cpp b/alib2algo/src/arbology/exact/ExactSubtreeAutomaton.cpp index b8b3d7a59949b68a16f88d58612ee20560a96472..ca99559fb3e6589fcc60566aead0b2d5bb7ec290 100644 --- a/alib2algo/src/arbology/exact/ExactSubtreeAutomaton.cpp +++ b/alib2algo/src/arbology/exact/ExactSubtreeAutomaton.cpp @@ -18,7 +18,7 @@ namespace arbology { namespace exact { automaton::Automaton ExactSubtreeAutomaton::construct ( const tree::Tree & text ) { - return getInstance ( ).dispatch ( text.getData ( ) ); + return dispatch ( text.getData ( ) ); } automaton::InputDrivenNPDA ExactSubtreeAutomaton::construct ( const tree::PrefixRankedTree & tree ) { @@ -45,7 +45,7 @@ automaton::InputDrivenNPDA ExactSubtreeAutomaton::construct ( const tree::Prefix return res; } -auto ExactSubtreeAutomatonPrefixRankedTree = ExactSubtreeAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedTree > ( ExactSubtreeAutomaton::getInstance ( ), ExactSubtreeAutomaton::construct ); +auto ExactSubtreeAutomatonPrefixRankedTree = ExactSubtreeAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedTree > ( ExactSubtreeAutomaton::construct ); } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ExactSubtreeAutomaton.h b/alib2algo/src/arbology/exact/ExactSubtreeAutomaton.h index e7d7abbb0ba0cf6b6dd513990ce8991a2c3203dd..517949209069676f87a8a008ceb7e42c4084eb02 100644 --- a/alib2algo/src/arbology/exact/ExactSubtreeAutomaton.h +++ b/alib2algo/src/arbology/exact/ExactSubtreeAutomaton.h @@ -16,7 +16,7 @@ namespace arbology { namespace exact { -class ExactSubtreeAutomaton : public std::SingleDispatch < automaton::Automaton, tree::TreeBase > { +class ExactSubtreeAutomaton : public std::SingleDispatch < ExactSubtreeAutomaton, automaton::Automaton, tree::TreeBase > { public: /** * Performs conversion. @@ -26,12 +26,6 @@ public: static automaton::InputDrivenNPDA construct ( const tree::PrefixRankedTree & tree ); - static ExactSubtreeAutomaton & getInstance ( ) { - static ExactSubtreeAutomaton res; - - return res; - } - }; } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ExactSubtreeMatchingAutomaton.cpp b/alib2algo/src/arbology/exact/ExactSubtreeMatchingAutomaton.cpp index c1e8915e5630cea094300b6142078a7467f80901..af9fc4a11db66e82603c63e72d83399e804cffa9 100644 --- a/alib2algo/src/arbology/exact/ExactSubtreeMatchingAutomaton.cpp +++ b/alib2algo/src/arbology/exact/ExactSubtreeMatchingAutomaton.cpp @@ -22,7 +22,7 @@ namespace arbology { namespace exact { automaton::Automaton ExactSubtreeMatchingAutomaton::construct ( const tree::Tree & pattern ) { - return getInstance ( ).dispatch ( pattern.getData ( ) ); + return dispatch ( pattern.getData ( ) ); } automaton::InputDrivenNPDA ExactSubtreeMatchingAutomaton::construct ( const tree::PrefixRankedTree & pattern ) { @@ -49,7 +49,7 @@ automaton::InputDrivenNPDA ExactSubtreeMatchingAutomaton::construct ( const tree return res; } -auto ExactSubtreeMatchingAutomatonPrefixRankedTree = ExactSubtreeMatchingAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedTree > ( ExactSubtreeMatchingAutomaton::getInstance ( ), ExactSubtreeMatchingAutomaton::construct ); +auto ExactSubtreeMatchingAutomatonPrefixRankedTree = ExactSubtreeMatchingAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedTree > ( ExactSubtreeMatchingAutomaton::construct ); automaton::InputDrivenNPDA ExactSubtreeMatchingAutomaton::construct ( const tree::PrefixRankedBarTree & pattern ) { automaton::InputDrivenNPDA res ( automaton::State ( 0 ), alphabet::Symbol { alphabet::BottomOfTheStackSymbol::BOTTOM_OF_THE_STACK } ); @@ -81,7 +81,7 @@ automaton::InputDrivenNPDA ExactSubtreeMatchingAutomaton::construct ( const tree return res; } -auto ExactSubtreeMatchingAutomatonPrefixRankedBarTree = ExactSubtreeMatchingAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedBarTree > ( ExactSubtreeMatchingAutomaton::getInstance ( ), ExactSubtreeMatchingAutomaton::construct ); +auto ExactSubtreeMatchingAutomatonPrefixRankedBarTree = ExactSubtreeMatchingAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedBarTree > ( ExactSubtreeMatchingAutomaton::construct ); automaton::State constructRecursive ( const tree::RankedNode & node, automaton::NFTA & res, int & nextState ) { std::vector < automaton::State > states; @@ -106,7 +106,7 @@ automaton::NFTA ExactSubtreeMatchingAutomaton::construct ( const tree::RankedTre return res; } -auto ExactSubtreeMatchingAutomatonRankedTree = ExactSubtreeMatchingAutomaton::RegistratorWrapper < automaton::NFTA, tree::RankedTree > ( ExactSubtreeMatchingAutomaton::getInstance ( ), ExactSubtreeMatchingAutomaton::construct ); +auto ExactSubtreeMatchingAutomatonRankedTree = ExactSubtreeMatchingAutomaton::RegistratorWrapper < automaton::NFTA, tree::RankedTree > ( ExactSubtreeMatchingAutomaton::construct ); } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ExactSubtreeMatchingAutomaton.h b/alib2algo/src/arbology/exact/ExactSubtreeMatchingAutomaton.h index 2dc4a30cfce413e5779be7ad28923a7995b6738e..d7a77c020a92ac2d448a0f02b5fd2f0b5172e365 100644 --- a/alib2algo/src/arbology/exact/ExactSubtreeMatchingAutomaton.h +++ b/alib2algo/src/arbology/exact/ExactSubtreeMatchingAutomaton.h @@ -18,7 +18,7 @@ namespace arbology { namespace exact { -class ExactSubtreeMatchingAutomaton : public std::SingleDispatch < automaton::Automaton, tree::TreeBase > { +class ExactSubtreeMatchingAutomaton : public std::SingleDispatch < ExactSubtreeMatchingAutomaton, automaton::Automaton, tree::TreeBase > { public: ExactSubtreeMatchingAutomaton ( ) { } @@ -32,12 +32,6 @@ public: static automaton::InputDrivenNPDA construct ( const tree::PrefixRankedBarTree & pattern ); static automaton::NFTA construct ( const tree::RankedTree & pattern ); - static ExactSubtreeMatchingAutomaton & getInstance ( ) { - static ExactSubtreeMatchingAutomaton res; - - return res; - } - }; } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ExactSubtreeRepeatsNaive.cpp b/alib2algo/src/arbology/exact/ExactSubtreeRepeatsNaive.cpp index 288e197c4a672bf62aeefce1ee1172f25d21abb0..c9ecef4b8b2f95b2ddc8adb321a819378728e804 100644 --- a/alib2algo/src/arbology/exact/ExactSubtreeRepeatsNaive.cpp +++ b/alib2algo/src/arbology/exact/ExactSubtreeRepeatsNaive.cpp @@ -19,7 +19,7 @@ namespace arbology { namespace exact { tree::Tree ExactSubtreeRepeatsNaive::repeats ( const tree::Tree & tree ) { - return getInstance ( ).dispatch ( tree.getData ( ) ); + return dispatch ( tree.getData ( ) ); } tree::RankedNode * ExactSubtreeRepeatsNaive::repeats ( const tree::RankedNode & node, std::map < std::pair < alphabet::RankedSymbol, std::vector < alphabet::RankedSymbol > >, int > & data, int & minId ) { @@ -49,7 +49,7 @@ tree::RankedTree ExactSubtreeRepeatsNaive::repeats ( const tree::RankedTree & tr return res; } -auto ExactRepeatsNaiveRankedTree = ExactSubtreeRepeatsNaive::RegistratorWrapper < tree::RankedTree, tree::RankedTree > ( ExactSubtreeRepeatsNaive::getInstance ( ), ExactSubtreeRepeatsNaive::repeats ); +auto ExactRepeatsNaiveRankedTree = ExactSubtreeRepeatsNaive::RegistratorWrapper < tree::RankedTree, tree::RankedTree > ( ExactSubtreeRepeatsNaive::repeats ); alphabet::RankedSymbol ExactSubtreeRepeatsNaive::repeatsPrefixRanked ( const std::vector < alphabet::RankedSymbol > & symbols, std::vector < alphabet::RankedSymbol > & res, std::map < std::pair < alphabet::RankedSymbol, std::vector < alphabet::RankedSymbol > >, int > & data, int & minId, int & index ) { int begin = index; @@ -80,7 +80,7 @@ tree::PrefixRankedTree ExactSubtreeRepeatsNaive::repeats ( const tree::PrefixRan return tree::PrefixRankedTree ( res ); } -auto ExactRepeatsNaivePrefixRankedTree = ExactSubtreeRepeatsNaive::RegistratorWrapper < tree::PrefixRankedTree, tree::PrefixRankedTree > ( ExactSubtreeRepeatsNaive::getInstance ( ), ExactSubtreeRepeatsNaive::repeats ); +auto ExactRepeatsNaivePrefixRankedTree = ExactSubtreeRepeatsNaive::RegistratorWrapper < tree::PrefixRankedTree, tree::PrefixRankedTree > ( ExactSubtreeRepeatsNaive::repeats ); alphabet::RankedSymbol ExactSubtreeRepeatsNaive::repeatsPrefixRankedBar ( const std::vector < alphabet::RankedSymbol > & symbols, std::vector < alphabet::RankedSymbol > & res, std::map < std::pair < alphabet::RankedSymbol, std::vector < alphabet::RankedSymbol > >, int > & data, int & minId, int & index ) { int begin = index; @@ -114,7 +114,7 @@ tree::PrefixRankedBarTree ExactSubtreeRepeatsNaive::repeats ( const tree::Prefix return tree::PrefixRankedBarTree ( tree.getBarSymbol ( ), res ); } -auto ExactRepeatsNaivePrefixRankedBarTree = ExactSubtreeRepeatsNaive::RegistratorWrapper < tree::PrefixRankedBarTree, tree::PrefixRankedBarTree > ( ExactSubtreeRepeatsNaive::getInstance ( ), ExactSubtreeRepeatsNaive::repeats ); +auto ExactRepeatsNaivePrefixRankedBarTree = ExactSubtreeRepeatsNaive::RegistratorWrapper < tree::PrefixRankedBarTree, tree::PrefixRankedBarTree > ( ExactSubtreeRepeatsNaive::repeats ); } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ExactSubtreeRepeatsNaive.h b/alib2algo/src/arbology/exact/ExactSubtreeRepeatsNaive.h index f2d3f837cde9cbec022e3e30f631a05640b78089..7664fa21aa5502fb5b85ffd1f6529899ae2baad3 100644 --- a/alib2algo/src/arbology/exact/ExactSubtreeRepeatsNaive.h +++ b/alib2algo/src/arbology/exact/ExactSubtreeRepeatsNaive.h @@ -22,7 +22,7 @@ namespace exact { /** * Simple computation of subtree repeats */ -class ExactSubtreeRepeatsNaive : public std::SingleDispatch < tree::Tree, tree::TreeBase > { +class ExactSubtreeRepeatsNaive : public std::SingleDispatch < ExactSubtreeRepeatsNaive, tree::Tree, tree::TreeBase > { static tree::RankedNode * repeats ( const tree::RankedNode & node, std::map < std::pair < alphabet::RankedSymbol, std::vector < alphabet::RankedSymbol > >, int > & data, int & minId ); static alphabet::RankedSymbol repeatsPrefixRanked ( const std::vector < alphabet::RankedSymbol > & symbols, std::vector < alphabet::RankedSymbol > & res, std::map < std::pair < alphabet::RankedSymbol, std::vector < alphabet::RankedSymbol > >, int > & data, int & minId, int & index ); static alphabet::RankedSymbol repeatsPrefixRankedBar ( const std::vector < alphabet::RankedSymbol > & symbols, std::vector < alphabet::RankedSymbol > & res, std::map < std::pair < alphabet::RankedSymbol, std::vector < alphabet::RankedSymbol > >, int > & data, int & minId, int & index ); @@ -42,12 +42,6 @@ public: static tree::PrefixRankedTree repeats ( const tree::PrefixRankedTree & tree ); static tree::PrefixRankedBarTree repeats ( const tree::PrefixRankedBarTree & tree ); - static ExactSubtreeRepeatsNaive & getInstance ( ) { - static ExactSubtreeRepeatsNaive res; - - return res; - } - }; } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ExactTreePatternAutomaton.cpp b/alib2algo/src/arbology/exact/ExactTreePatternAutomaton.cpp index 7e13e2ab6fdad933e26d16dc67424f1da9e127ab..5843fe692bbfacae293020fe75ecfddbff8f4d6c 100644 --- a/alib2algo/src/arbology/exact/ExactTreePatternAutomaton.cpp +++ b/alib2algo/src/arbology/exact/ExactTreePatternAutomaton.cpp @@ -23,7 +23,7 @@ automaton::Automaton ExactTreePatternAutomaton::construct ( const tree::Tree & t } automaton::Automaton ExactTreePatternAutomaton::construct ( const tree::Tree & text, const alphabet::Symbol & subtreeWildcard ) { - return getInstance ( ).dispatch ( text.getData ( ), subtreeWildcard ); + return dispatch ( text.getData ( ), subtreeWildcard ); } automaton::InputDrivenNPDA ExactTreePatternAutomaton::construct ( const tree::PrefixRankedTree & tree ) { @@ -67,7 +67,7 @@ automaton::InputDrivenNPDA ExactTreePatternAutomaton::construct ( const tree::Pr return res; } -auto ExactTreePatternAutomatonPrefixRankedTree = ExactTreePatternAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedTree > ( ExactTreePatternAutomaton::getInstance ( ), ExactTreePatternAutomaton::construct ); +auto ExactTreePatternAutomatonPrefixRankedTree = ExactTreePatternAutomaton::RegistratorWrapper < automaton::InputDrivenNPDA, tree::PrefixRankedTree > ( ExactTreePatternAutomaton::construct ); } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ExactTreePatternAutomaton.h b/alib2algo/src/arbology/exact/ExactTreePatternAutomaton.h index 80e48de05c680610b9d424ebc395e877c984b211..ee75320844b34d4e1b4cc51a2f5ba76dbed83446 100644 --- a/alib2algo/src/arbology/exact/ExactTreePatternAutomaton.h +++ b/alib2algo/src/arbology/exact/ExactTreePatternAutomaton.h @@ -17,7 +17,7 @@ namespace arbology { namespace exact { -class ExactTreePatternAutomaton : public std::SingleDispatchLastStaticParam < automaton::Automaton, tree::TreeBase, const alphabet::Symbol & > { +class ExactTreePatternAutomaton : public std::SingleDispatchLastStaticParam < ExactTreePatternAutomaton, automaton::Automaton, tree::TreeBase, const alphabet::Symbol & > { public: /** * Performs conversion. @@ -29,12 +29,6 @@ public: static automaton::InputDrivenNPDA construct ( const tree::PrefixRankedTree & tree ); static automaton::InputDrivenNPDA construct ( const tree::PrefixRankedTree & tree, const alphabet::Symbol & subtreeWildcard ); - static ExactTreePatternAutomaton & getInstance ( ) { - static ExactTreePatternAutomaton res; - - return res; - } - }; } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ReversedBadCharacterShiftTable.cpp b/alib2algo/src/arbology/exact/ReversedBadCharacterShiftTable.cpp index f31ce91689dce2cf44e6fe02147617e9f7198fc7..810ed8417a5d60644c00eebced0137c57b5b99d8 100644 --- a/alib2algo/src/arbology/exact/ReversedBadCharacterShiftTable.cpp +++ b/alib2algo/src/arbology/exact/ReversedBadCharacterShiftTable.cpp @@ -15,7 +15,7 @@ namespace arbology { namespace exact { std::map < alphabet::RankedSymbol, size_t > ReversedBadCharacterShiftTable::bcs ( const tree::RankedTreeWrapper & pattern ) { - return getInstance ( ).dispatch ( pattern.getData ( ) ); + return dispatch ( pattern.getData ( ) ); } std::map < alphabet::RankedSymbol, size_t > ReversedBadCharacterShiftTable::bcs ( const tree::PrefixRankedBarPattern & pattern ) { @@ -71,7 +71,7 @@ std::map < alphabet::RankedSymbol, size_t > ReversedBadCharacterShiftTable::bcs return bcs; } -auto ReversedBadCharacterShiftTablePrefixRankedBarPattern = ReversedBadCharacterShiftTable::RegistratorWrapper < std::map < alphabet::RankedSymbol, size_t >, tree::PrefixRankedBarPattern > ( ReversedBadCharacterShiftTable::getInstance ( ), ReversedBadCharacterShiftTable::bcs ); +auto ReversedBadCharacterShiftTablePrefixRankedBarPattern = ReversedBadCharacterShiftTable::RegistratorWrapper < std::map < alphabet::RankedSymbol, size_t >, tree::PrefixRankedBarPattern > ( ReversedBadCharacterShiftTable::bcs ); std::map < alphabet::RankedSymbol, size_t > ReversedBadCharacterShiftTable::bcs ( const tree::PrefixRankedPattern & pattern ) { const std::set < alphabet::RankedSymbol > & alphabet = pattern.getAlphabet ( ); @@ -115,7 +115,7 @@ std::map < alphabet::RankedSymbol, size_t > ReversedBadCharacterShiftTable::bcs return bcs; } -auto ReversedBadCharacterShiftTablePrefixRankedPattern = ReversedBadCharacterShiftTable::RegistratorWrapper < std::map < alphabet::RankedSymbol, size_t >, tree::PrefixRankedPattern > ( ReversedBadCharacterShiftTable::getInstance ( ), ReversedBadCharacterShiftTable::bcs ); +auto ReversedBadCharacterShiftTablePrefixRankedPattern = ReversedBadCharacterShiftTable::RegistratorWrapper < std::map < alphabet::RankedSymbol, size_t >, tree::PrefixRankedPattern > ( ReversedBadCharacterShiftTable::bcs ); } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/ReversedBadCharacterShiftTable.h b/alib2algo/src/arbology/exact/ReversedBadCharacterShiftTable.h index 7b648b3444a66bd0f319223b16ce3717476b5162..909c4301ca29d93b2f1cac61e5cc4fb781bb73a2 100644 --- a/alib2algo/src/arbology/exact/ReversedBadCharacterShiftTable.h +++ b/alib2algo/src/arbology/exact/ReversedBadCharacterShiftTable.h @@ -24,7 +24,7 @@ namespace exact { * Computation of BCS table for BMH from MI(E+\eps)-EVY course 2014 * To get rid of zeros in BCS table we ignore last haystack character */ -class ReversedBadCharacterShiftTable : public std::SingleDispatch < std::map < alphabet::RankedSymbol, size_t >, tree::RankedTreeBase > { +class ReversedBadCharacterShiftTable : public std::SingleDispatch < ReversedBadCharacterShiftTable, std::map < alphabet::RankedSymbol, size_t >, tree::RankedTreeBase > { public: /** * Search for pattern in linear string. @@ -35,12 +35,6 @@ public: static std::map < alphabet::RankedSymbol, size_t > bcs ( const tree::PrefixRankedBarPattern & pattern ); static std::map < alphabet::RankedSymbol, size_t > bcs ( const tree::PrefixRankedPattern & pattern ); - static ReversedBadCharacterShiftTable & getInstance ( ) { - static ReversedBadCharacterShiftTable res; - - return res; - } - }; } /* namespace exact */ diff --git a/alib2algo/src/arbology/exact/SubtreeJumpTable.cpp b/alib2algo/src/arbology/exact/SubtreeJumpTable.cpp index 584c3385bfbe71fa617289fc74e18df002ad6eb8..96eb18c220489dc2bf982a2dc9c7bee726de5686 100644 --- a/alib2algo/src/arbology/exact/SubtreeJumpTable.cpp +++ b/alib2algo/src/arbology/exact/SubtreeJumpTable.cpp @@ -20,7 +20,7 @@ namespace arbology { namespace exact { std::vector < int > SubtreeJumpTable::compute ( const tree::RankedTreeWrapper & subject ) { - return getInstance ( ).dispatch ( subject.getData ( ) ); + return dispatch ( subject.getData ( ) ); } std::vector < int > SubtreeJumpTable::compute ( const tree::PrefixRankedBarTree & subject ) { @@ -31,7 +31,7 @@ std::vector < int > SubtreeJumpTable::compute ( const tree::PrefixRankedBarTree return res; } -auto SubtreeSizesPrefixRankedBarTree = SubtreeJumpTable::RegistratorWrapper < std::vector < int >, tree::PrefixRankedBarTree > ( SubtreeJumpTable::getInstance ( ), SubtreeJumpTable::compute ); +auto SubtreeSizesPrefixRankedBarTree = SubtreeJumpTable::RegistratorWrapper < std::vector < int >, tree::PrefixRankedBarTree > ( SubtreeJumpTable::compute ); std::vector < int > SubtreeJumpTable::compute ( const tree::PrefixRankedBarPattern & pattern ) { std::vector < int > res; @@ -41,7 +41,7 @@ std::vector < int > SubtreeJumpTable::compute ( const tree::PrefixRankedBarPatte return res; } -auto SubtreeSizesPrefixRankedBarPattern = SubtreeJumpTable::RegistratorWrapper < std::vector < int >, tree::PrefixRankedBarPattern > ( SubtreeJumpTable::getInstance ( ), SubtreeJumpTable::compute ); +auto SubtreeSizesPrefixRankedBarPattern = SubtreeJumpTable::RegistratorWrapper < std::vector < int >, tree::PrefixRankedBarPattern > ( SubtreeJumpTable::compute ); std::vector < int > SubtreeJumpTable::compute ( const tree::PrefixRankedTree & subject ) { std::vector < int > res; @@ -51,7 +51,7 @@ std::vector < int > SubtreeJumpTable::compute ( const tree::PrefixRankedTree & s return res; } -auto SubtreeSizesPrefixRankedTree = SubtreeJumpTable::RegistratorWrapper < std::vector < int >, tree::PrefixRankedTree > ( SubtreeJumpTable::getInstance ( ), SubtreeJumpTable::compute ); +auto SubtreeSizesPrefixRankedTree = SubtreeJumpTable::RegistratorWrapper < std::vector < int >, tree::PrefixRankedTree > ( SubtreeJumpTable::compute ); std::vector < int > SubtreeJumpTable::compute ( const tree::PrefixRankedPattern & pattern ) { std::vector < int > res; @@ -61,7 +61,7 @@ std::vector < int > SubtreeJumpTable::compute ( const tree::PrefixRankedPattern return res; } -auto SubtreeSizesPrefixRankedPattern = SubtreeJumpTable::RegistratorWrapper < std::vector < int >, tree::PrefixRankedPattern > ( SubtreeJumpTable::getInstance ( ), SubtreeJumpTable::compute ); +auto SubtreeSizesPrefixRankedPattern = SubtreeJumpTable::RegistratorWrapper < std::vector < int >, tree::PrefixRankedPattern > ( SubtreeJumpTable::compute ); /** * used to compute subtree jump table. diff --git a/alib2algo/src/arbology/exact/SubtreeJumpTable.h b/alib2algo/src/arbology/exact/SubtreeJumpTable.h index 4dceef61f5c0ee1eaf8d6e56614344dcdea93356..6778bf3c8b42b6e105abd6e4c59a426b05f1902d 100644 --- a/alib2algo/src/arbology/exact/SubtreeJumpTable.h +++ b/alib2algo/src/arbology/exact/SubtreeJumpTable.h @@ -19,7 +19,7 @@ namespace arbology { namespace exact { -class SubtreeJumpTable : public std::SingleDispatch < std::vector < int >, tree::RankedTreeBase > { +class SubtreeJumpTable : public std::SingleDispatch < SubtreeJumpTable, std::vector < int >, tree::RankedTreeBase > { template < class T > static int buildDataPointersBar ( std::vector < int > & res, const T & subject, int begin ); template < class T > @@ -35,12 +35,6 @@ public: static std::vector < int > compute ( const tree::PrefixRankedTree & subject ); static std::vector < int > compute ( const tree::PrefixRankedPattern & pattern ); - static SubtreeJumpTable & getInstance ( ) { - static SubtreeJumpTable res; - - return res; - } - }; } /* namespace exact */ diff --git a/alib2algo/src/arbology/transform/BeginToEndIndex.cpp b/alib2algo/src/arbology/transform/BeginToEndIndex.cpp index f5dfd25b8a68e7c2cf6e84710718b9ad73b6abbc..eff7026579536536a504f0d638ec4021287ceee5 100644 --- a/alib2algo/src/arbology/transform/BeginToEndIndex.cpp +++ b/alib2algo/src/arbology/transform/BeginToEndIndex.cpp @@ -19,7 +19,7 @@ namespace arbology { namespace transform { std::set < unsigned > BeginToEndIndex::transform ( const tree::Tree & subject, const std::set < unsigned > & indexes ) { - return getInstance ( ).dispatch ( subject.getData ( ), indexes ); + return dispatch ( subject.getData ( ), indexes ); } std::set < unsigned > BeginToEndIndex::transform ( const tree::PrefixRankedBarTree & subject, const std::set < unsigned > & indexes ) { @@ -32,7 +32,7 @@ std::set < unsigned > BeginToEndIndex::transform ( const tree::PrefixRankedBarTr return res; } -auto BeginToEndIndexPrefixRankedBarTreePrefixRankedBarTree = BeginToEndIndex::RegistratorWrapper < std::set < unsigned >, tree::PrefixRankedBarTree > ( BeginToEndIndex::getInstance ( ), BeginToEndIndex::transform ); +auto BeginToEndIndexPrefixRankedBarTreePrefixRankedBarTree = BeginToEndIndex::RegistratorWrapper < std::set < unsigned >, tree::PrefixRankedBarTree > ( BeginToEndIndex::transform ); std::set < unsigned > BeginToEndIndex::transform ( const tree::PrefixRankedTree & subject, const std::set < unsigned > & indexes ) { std::vector < int > subjectSubtreeJumpTable = exact::SubtreeJumpTable::compute ( subject ); @@ -44,7 +44,7 @@ std::set < unsigned > BeginToEndIndex::transform ( const tree::PrefixRankedTree return res; } -auto BeginToEndIndexPrefixRankedBarTreePrefixRankedBarPattern = BeginToEndIndex::RegistratorWrapper < std::set < unsigned >, tree::PrefixRankedTree > ( BeginToEndIndex::getInstance ( ), BeginToEndIndex::transform ); +auto BeginToEndIndexPrefixRankedBarTreePrefixRankedBarPattern = BeginToEndIndex::RegistratorWrapper < std::set < unsigned >, tree::PrefixRankedTree > ( BeginToEndIndex::transform ); } /* namespace transform */ diff --git a/alib2algo/src/arbology/transform/BeginToEndIndex.h b/alib2algo/src/arbology/transform/BeginToEndIndex.h index 7b980f55ea17a9635abb8abf887eb7405bf6f17b..cd0c61e32cb77a3b9559d74b4c5410e7a1d59995 100644 --- a/alib2algo/src/arbology/transform/BeginToEndIndex.h +++ b/alib2algo/src/arbology/transform/BeginToEndIndex.h @@ -18,7 +18,7 @@ namespace transform { /** */ -class BeginToEndIndex : public std::SingleDispatchLastStaticParam < std::set < unsigned >, tree::TreeBase, const std::set < unsigned > & > { +class BeginToEndIndex : public std::SingleDispatchLastStaticParam < BeginToEndIndex, std::set < unsigned >, tree::TreeBase, const std::set < unsigned > & > { public: /** * Search for pattern in linear string. @@ -29,12 +29,6 @@ public: static std::set < unsigned > transform ( const tree::PrefixRankedBarTree & subject, const std::set < unsigned > & indexes ); static std::set < unsigned > transform ( const tree::PrefixRankedTree & subject, const std::set < unsigned > & indexes ); - static BeginToEndIndex & getInstance ( ) { - static BeginToEndIndex res; - - return res; - } - }; } /* namespace transform */ diff --git a/alib2algo/src/automaton/convert/ToGrammar.cpp b/alib2algo/src/automaton/convert/ToGrammar.cpp index fc79bc6c8a03aaa37ff87ba521a6056b89404507..f681ce399da55e9236c6fd763ecbc61e38644a79 100644 --- a/alib2algo/src/automaton/convert/ToGrammar.cpp +++ b/alib2algo/src/automaton/convert/ToGrammar.cpp @@ -13,20 +13,20 @@ namespace automaton { namespace convert { grammar::Grammar ToGrammar::convert(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } grammar::Grammar ToGrammar::convert(const automaton::NFA& automaton) { return grammar::Grammar(ToGrammarRightRG::convert(automaton)); } -auto ToGrammarNFA = ToGrammar::RegistratorWrapper<grammar::Grammar, automaton::NFA>(ToGrammar::getInstance(), ToGrammar::convert); +auto ToGrammarNFA = ToGrammar::RegistratorWrapper<grammar::Grammar, automaton::NFA>(ToGrammar::convert); grammar::Grammar ToGrammar::convert(const automaton::DFA& automaton) { return grammar::Grammar(ToGrammarRightRG::convert(automaton)); } -auto ToGrammarDFA = ToGrammar::RegistratorWrapper<grammar::Grammar, automaton::DFA>(ToGrammar::getInstance(), ToGrammar::convert); +auto ToGrammarDFA = ToGrammar::RegistratorWrapper<grammar::Grammar, automaton::DFA>(ToGrammar::convert); } /* namespace convert */ diff --git a/alib2algo/src/automaton/convert/ToGrammar.h b/alib2algo/src/automaton/convert/ToGrammar.h index 456af55821a5159df2a30fbd59855a1c80ea3b3f..3edef0b4c17eec166a33861ccdfeedab9ad7269c 100644 --- a/alib2algo/src/automaton/convert/ToGrammar.h +++ b/alib2algo/src/automaton/convert/ToGrammar.h @@ -21,7 +21,7 @@ namespace automaton { namespace convert { -class ToGrammar : public std::SingleDispatch<grammar::Grammar, automaton::AutomatonBase> { +class ToGrammar : public std::SingleDispatch<ToGrammar, grammar::Grammar, automaton::AutomatonBase> { public: /** * Performs conversion. @@ -31,11 +31,6 @@ public: static grammar::Grammar convert(const NFA& automaton); static grammar::Grammar convert(const DFA& automaton); - - static ToGrammar& getInstance() { - static ToGrammar res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/automaton/convert/ToGrammarLeftRG.cpp b/alib2algo/src/automaton/convert/ToGrammarLeftRG.cpp index 3e46688f86a49907cbde870533a9c85d7a609d8b..dd2b1b518ff630e1b8d4be7fd191a38088263073 100644 --- a/alib2algo/src/automaton/convert/ToGrammarLeftRG.cpp +++ b/alib2algo/src/automaton/convert/ToGrammarLeftRG.cpp @@ -15,7 +15,7 @@ namespace automaton { namespace convert { grammar::LeftRG ToGrammarLeftRG::convert(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } grammar::LeftRG ToGrammarLeftRG::convert(const automaton::NFA& automaton) { @@ -63,7 +63,7 @@ grammar::LeftRG ToGrammarLeftRG::convert(const automaton::NFA& automaton) { return grammar; } -auto ToGrammarLeftRGNFA = ToGrammarLeftRG::RegistratorWrapper<grammar::LeftRG, automaton::NFA>(ToGrammarLeftRG::getInstance(), ToGrammarLeftRG::convert); +auto ToGrammarLeftRGNFA = ToGrammarLeftRG::RegistratorWrapper<grammar::LeftRG, automaton::NFA>(ToGrammarLeftRG::convert); grammar::LeftRG ToGrammarLeftRG::convert(const automaton::DFA& automaton) { std::map<automaton::State, alphabet::Symbol> nonterminalMap; @@ -108,7 +108,7 @@ grammar::LeftRG ToGrammarLeftRG::convert(const automaton::DFA& automaton) { return grammar; } -auto ToGrammarLeftRGDFA = ToGrammarLeftRG::RegistratorWrapper<grammar::LeftRG, automaton::DFA>(ToGrammarLeftRG::getInstance(), ToGrammarLeftRG::convert); +auto ToGrammarLeftRGDFA = ToGrammarLeftRG::RegistratorWrapper<grammar::LeftRG, automaton::DFA>(ToGrammarLeftRG::convert); } /* namespace convert */ diff --git a/alib2algo/src/automaton/convert/ToGrammarLeftRG.h b/alib2algo/src/automaton/convert/ToGrammarLeftRG.h index 7d8496ce1335bde0232dc8e0b76d0a537041bc45..4976d12c61e0de79ce600e3241e0d0584d824c8f 100644 --- a/alib2algo/src/automaton/convert/ToGrammarLeftRG.h +++ b/alib2algo/src/automaton/convert/ToGrammarLeftRG.h @@ -24,7 +24,7 @@ namespace convert { * Finite automaton to right regular grammar converter. * Source: My own :) */ -class ToGrammarLeftRG : public std::SingleDispatch<grammar::LeftRG, automaton::AutomatonBase> { +class ToGrammarLeftRG : public std::SingleDispatch<ToGrammarLeftRG, grammar::LeftRG, automaton::AutomatonBase> { public: /** * Performs conversion. @@ -34,11 +34,6 @@ public: static grammar::LeftRG convert(const automaton::NFA& automaton); static grammar::LeftRG convert(const automaton::DFA& automaton); - - static ToGrammarLeftRG& getInstance() { - static ToGrammarLeftRG res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/automaton/convert/ToGrammarRightRG.cpp b/alib2algo/src/automaton/convert/ToGrammarRightRG.cpp index 07a62a49acabcd0cb5997661cbf37cbb1a007f4a..645bf266b399f40e9bbfcf179a8dc11ea6239fa8 100644 --- a/alib2algo/src/automaton/convert/ToGrammarRightRG.cpp +++ b/alib2algo/src/automaton/convert/ToGrammarRightRG.cpp @@ -13,7 +13,7 @@ namespace automaton { namespace convert { grammar::RightRG ToGrammarRightRG::convert(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } grammar::RightRG ToGrammarRightRG::convert(const automaton::NFA& automaton) { @@ -57,7 +57,7 @@ grammar::RightRG ToGrammarRightRG::convert(const automaton::NFA& automaton) { return grammar; } -auto ToGrammarRightRGNFA = ToGrammarRightRG::RegistratorWrapper<grammar::RightRG, automaton::NFA>(ToGrammarRightRG::getInstance(), ToGrammarRightRG::convert); +auto ToGrammarRightRGNFA = ToGrammarRightRG::RegistratorWrapper<grammar::RightRG, automaton::NFA>(ToGrammarRightRG::convert); grammar::RightRG ToGrammarRightRG::convert(const automaton::DFA& automaton) { std::map<automaton::State, alphabet::Symbol> nonterminalMap; @@ -100,7 +100,7 @@ grammar::RightRG ToGrammarRightRG::convert(const automaton::DFA& automaton) { return grammar; } -auto ToGrammarRightRGDFA = ToGrammarRightRG::RegistratorWrapper<grammar::RightRG, automaton::DFA>(ToGrammarRightRG::getInstance(), ToGrammarRightRG::convert); +auto ToGrammarRightRGDFA = ToGrammarRightRG::RegistratorWrapper<grammar::RightRG, automaton::DFA>(ToGrammarRightRG::convert); } /* namespace convert */ diff --git a/alib2algo/src/automaton/convert/ToGrammarRightRG.h b/alib2algo/src/automaton/convert/ToGrammarRightRG.h index e23c32e6b8a998836ef0de79ec458340bd69b43b..ab57e4b43f119dccb8c7e75ed98ac58080e1fde8 100644 --- a/alib2algo/src/automaton/convert/ToGrammarRightRG.h +++ b/alib2algo/src/automaton/convert/ToGrammarRightRG.h @@ -24,7 +24,7 @@ namespace convert { * Finite automaton to right regular grammar converter. * Source: Melichar 2.104 */ -class ToGrammarRightRG : public std::SingleDispatch<grammar::RightRG, automaton::AutomatonBase> { +class ToGrammarRightRG : public std::SingleDispatch<ToGrammarRightRG, grammar::RightRG, automaton::AutomatonBase> { public: /** * Performs conversion. @@ -34,11 +34,6 @@ public: static grammar::RightRG convert(const automaton::NFA& automaton); static grammar::RightRG convert(const automaton::DFA& automaton); - - static ToGrammarRightRG& getInstance() { - static ToGrammarRightRG res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/automaton/convert/ToRegExp.cpp b/alib2algo/src/automaton/convert/ToRegExp.cpp index a9029e563148406a690a7d20f66d49650a291fa1..37e615ce92b5d20e4a334b2f16b40169bc83a84b 100644 --- a/alib2algo/src/automaton/convert/ToRegExp.cpp +++ b/alib2algo/src/automaton/convert/ToRegExp.cpp @@ -13,44 +13,44 @@ namespace automaton { namespace convert { regexp::RegExp ToRegExp::convert(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } regexp::RegExp ToRegExp::convert(const automaton::EpsilonNFA& automaton) { return regexp::RegExp(ToRegExpStateElimination::convert(automaton)); } -auto ToRegExpEpsilonNFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::EpsilonNFA>(ToRegExp::getInstance(), ToRegExp::convert); +auto ToRegExpEpsilonNFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::EpsilonNFA>(ToRegExp::convert); regexp::RegExp ToRegExp::convert(const automaton::MultiInitialStateNFA& automaton) { return regexp::RegExp(ToRegExpStateElimination::convert(automaton)); } -auto ToRegExpMultiInitialStateNFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::MultiInitialStateNFA>(ToRegExp::getInstance(), ToRegExp::convert); +auto ToRegExpMultiInitialStateNFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::MultiInitialStateNFA>(ToRegExp::convert); regexp::RegExp ToRegExp::convert(const automaton::NFA& automaton) { return regexp::RegExp(ToRegExpStateElimination::convert(automaton)); } -auto ToRegExpNFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::NFA>(ToRegExp::getInstance(), ToRegExp::convert); +auto ToRegExpNFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::NFA>(ToRegExp::convert); regexp::RegExp ToRegExp::convert(const automaton::DFA& automaton) { return regexp::RegExp(ToRegExpStateElimination::convert(automaton)); } -auto ToRegExpDFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::DFA>(ToRegExp::getInstance(), ToRegExp::convert); +auto ToRegExpDFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::DFA>(ToRegExp::convert); regexp::RegExp ToRegExp::convert(const automaton::ExtendedNFA& automaton) { return regexp::RegExp(ToRegExpStateElimination::convert(automaton)); } -auto ToRegExpExtendedNFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::ExtendedNFA>(ToRegExp::getInstance(), ToRegExp::convert); +auto ToRegExpExtendedNFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::ExtendedNFA>(ToRegExp::convert); regexp::RegExp ToRegExp::convert(const automaton::CompactNFA& automaton) { return regexp::RegExp(ToRegExpStateElimination::convert(automaton)); } -auto ToRegExpCompactNFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::CompactNFA>(ToRegExp::getInstance(), ToRegExp::convert); +auto ToRegExpCompactNFA = ToRegExp::RegistratorWrapper<regexp::RegExp, automaton::CompactNFA>(ToRegExp::convert); } /* namespace convert */ diff --git a/alib2algo/src/automaton/convert/ToRegExp.h b/alib2algo/src/automaton/convert/ToRegExp.h index 0470e419f380eeed9c8d6172e1e4ea50a91c9ef9..2c74aebf93003729f2b73d89d560a025edf730df 100644 --- a/alib2algo/src/automaton/convert/ToRegExp.h +++ b/alib2algo/src/automaton/convert/ToRegExp.h @@ -22,7 +22,7 @@ namespace automaton { namespace convert { -class ToRegExp : public std::SingleDispatch<regexp::RegExp, automaton::AutomatonBase> { +class ToRegExp : public std::SingleDispatch<ToRegExp, regexp::RegExp, automaton::AutomatonBase> { public: /** * Performs conversion. @@ -36,11 +36,6 @@ public: static regexp::RegExp convert(const DFA& automaton); static regexp::RegExp convert(const ExtendedNFA& automaton); static regexp::RegExp convert(const CompactNFA& automaton); - - static ToRegExp& getInstance() { - static ToRegExp res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/automaton/convert/ToRegExpAlgebraic.cpp b/alib2algo/src/automaton/convert/ToRegExpAlgebraic.cpp index 11cc98a3f2d6639625cbe547ac86b2b5017de29e..d79c251331a3b0540c83815ffe4ec0ad019aa8fd 100644 --- a/alib2algo/src/automaton/convert/ToRegExpAlgebraic.cpp +++ b/alib2algo/src/automaton/convert/ToRegExpAlgebraic.cpp @@ -23,7 +23,7 @@ namespace automaton { namespace convert { regexp::RegExp ToRegExpAlgebraic::convert(const automaton::Automaton& automaton) { - return regexp::RegExp(getInstance().dispatch(automaton.getData())); + return dispatch(automaton.getData()); } regexp::UnboundedRegExp ToRegExpAlgebraic::convert( const automaton::EpsilonNFA & automaton ) { @@ -53,7 +53,7 @@ regexp::UnboundedRegExp ToRegExpAlgebraic::convert( const automaton::EpsilonNFA return solver.solve( alphabet::Symbol( alphabet::LabeledSymbol (automaton.getInitialState().getName() ) ) ); } -auto ToRegExpAlgebraicEpsilonNFA = ToRegExpAlgebraic::RegistratorWrapper<regexp::UnboundedRegExp, automaton::EpsilonNFA>(ToRegExpAlgebraic::getInstance(), ToRegExpAlgebraic::convert); +auto ToRegExpAlgebraicEpsilonNFA = ToRegExpAlgebraic::RegistratorWrapper<regexp::UnboundedRegExp, automaton::EpsilonNFA>(ToRegExpAlgebraic::convert); regexp::UnboundedRegExp ToRegExpAlgebraic::convert( const automaton::MultiInitialStateNFA & automaton ) { equations::RightRegularEquationSolver solver; @@ -84,7 +84,7 @@ regexp::UnboundedRegExp ToRegExpAlgebraic::convert( const automaton::MultiInitia return regexp::UnboundedRegExp { alternation }; } -auto ToRegExpAlgebraicMultiInitialStateNFA = ToRegExpAlgebraic::RegistratorWrapper<regexp::UnboundedRegExp, automaton::MultiInitialStateNFA>(ToRegExpAlgebraic::getInstance(), ToRegExpAlgebraic::convert); +auto ToRegExpAlgebraicMultiInitialStateNFA = ToRegExpAlgebraic::RegistratorWrapper<regexp::UnboundedRegExp, automaton::MultiInitialStateNFA>(ToRegExpAlgebraic::convert); regexp::UnboundedRegExp ToRegExpAlgebraic::convert( const automaton::NFA & automaton ) { equations::RightRegularEquationSolver solver; @@ -107,7 +107,7 @@ regexp::UnboundedRegExp ToRegExpAlgebraic::convert( const automaton::NFA & autom return solver.solve( alphabet::Symbol( alphabet::LabeledSymbol (automaton.getInitialState().getName() ) ) ); } -auto ToRegExpAlgebraicNFA = ToRegExpAlgebraic::RegistratorWrapper<regexp::UnboundedRegExp, automaton::NFA>(ToRegExpAlgebraic::getInstance(), ToRegExpAlgebraic::convert); +auto ToRegExpAlgebraicNFA = ToRegExpAlgebraic::RegistratorWrapper<regexp::UnboundedRegExp, automaton::NFA>(ToRegExpAlgebraic::convert); regexp::UnboundedRegExp ToRegExpAlgebraic::convert( const automaton::DFA & automaton ) { equations::RightRegularEquationSolver solver; @@ -128,7 +128,7 @@ regexp::UnboundedRegExp ToRegExpAlgebraic::convert( const automaton::DFA & autom return solver.solve( alphabet::Symbol( alphabet::LabeledSymbol (automaton.getInitialState().getName() ) ) ); } -auto ToRegExpAlgebraicDFA = ToRegExpAlgebraic::RegistratorWrapper<regexp::UnboundedRegExp, automaton::DFA>(ToRegExpAlgebraic::getInstance(), ToRegExpAlgebraic::convert); +auto ToRegExpAlgebraicDFA = ToRegExpAlgebraic::RegistratorWrapper<regexp::UnboundedRegExp, automaton::DFA>(ToRegExpAlgebraic::convert); } /* namespace convert */ diff --git a/alib2algo/src/automaton/convert/ToRegExpAlgebraic.h b/alib2algo/src/automaton/convert/ToRegExpAlgebraic.h index f4f8f72c2f78d5d829e15c343d9c6d6c9c9b50b8..6df41d2ca57453786d6174a78fba49f7c0d8c516 100644 --- a/alib2algo/src/automaton/convert/ToRegExpAlgebraic.h +++ b/alib2algo/src/automaton/convert/ToRegExpAlgebraic.h @@ -29,7 +29,7 @@ namespace convert { * Converts FA to RE using Brzozowski's algebraic method using right regular equations. * Source : Melichar 2.122 */ -class ToRegExpAlgebraic : public std::SingleDispatch<regexp::UnboundedRegExp, automaton::AutomatonBase> { +class ToRegExpAlgebraic : public std::SingleDispatch<ToRegExpAlgebraic, regexp::RegExp, automaton::AutomatonBase> { public: /** * Performs conversion. @@ -41,11 +41,6 @@ public: static regexp::UnboundedRegExp convert(const automaton::MultiInitialStateNFA& automaton); static regexp::UnboundedRegExp convert(const automaton::NFA& automaton); static regexp::UnboundedRegExp convert(const automaton::DFA& automaton); - - static ToRegExpAlgebraic& getInstance() { - static ToRegExpAlgebraic res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp b/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp index fea2fc44089402851225f7ea43daaffad8f5bbe3..a56757aeadd19601ca3f3637448ba72950454e0e 100644 --- a/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp +++ b/alib2algo/src/automaton/convert/ToRegExpStateElimination.cpp @@ -19,7 +19,7 @@ namespace automaton { namespace convert { regexp::RegExp ToRegExpStateElimination::convert(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } template<class T> @@ -46,12 +46,12 @@ regexp::RegExp ToRegExpStateElimination::convert(const T& automaton) { regexp::RegExpIterate::iterate(transition(extendedAutomaton, *extendedAutomaton.getFinalStates().begin(), *extendedAutomaton.getFinalStates().begin())))); } -auto ToRegExpStateEliminationEpsilonNFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::EpsilonNFA>(ToRegExpStateElimination::getInstance(), ToRegExpStateElimination::convert); -auto ToRegExpStateEliminationMultiInitialStateNFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::MultiInitialStateNFA>(ToRegExpStateElimination::getInstance(), ToRegExpStateElimination::convert); -auto ToRegExpStateEliminationNFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::NFA>(ToRegExpStateElimination::getInstance(), ToRegExpStateElimination::convert); -auto ToRegExpStateEliminationDFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::DFA>(ToRegExpStateElimination::getInstance(), ToRegExpStateElimination::convert); -auto ToRegExpStateEliminationExtendedNFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::ExtendedNFA>(ToRegExpStateElimination::getInstance(), ToRegExpStateElimination::convert); -auto ToRegExpStateEliminationCompactNFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::CompactNFA>(ToRegExpStateElimination::getInstance(), ToRegExpStateElimination::convert); +auto ToRegExpStateEliminationEpsilonNFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::EpsilonNFA>(ToRegExpStateElimination::convert); +auto ToRegExpStateEliminationMultiInitialStateNFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::MultiInitialStateNFA>(ToRegExpStateElimination::convert); +auto ToRegExpStateEliminationNFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::NFA>(ToRegExpStateElimination::convert); +auto ToRegExpStateEliminationDFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::DFA>(ToRegExpStateElimination::convert); +auto ToRegExpStateEliminationExtendedNFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::ExtendedNFA>(ToRegExpStateElimination::convert); +auto ToRegExpStateEliminationCompactNFA = ToRegExpStateElimination::RegistratorWrapper<regexp::RegExp, automaton::CompactNFA>(ToRegExpStateElimination::convert); automaton::ExtendedNFA ToRegExpStateElimination::eliminateState(const automaton::ExtendedNFA& extendedAutomaton, const automaton::State& q) { diff --git a/alib2algo/src/automaton/convert/ToRegExpStateElimination.h b/alib2algo/src/automaton/convert/ToRegExpStateElimination.h index 32f485f84c96abfadfcbb9adb3f6ba83605fe929..0e79e6edf131390176cb065de0fa7d2937e500f4 100644 --- a/alib2algo/src/automaton/convert/ToRegExpStateElimination.h +++ b/alib2algo/src/automaton/convert/ToRegExpStateElimination.h @@ -27,7 +27,7 @@ namespace convert { * Converts FSM to RE using State Elimination algorithm. * Source: Melichar 2.118 */ -class ToRegExpStateElimination : public std::SingleDispatch<regexp::RegExp, automaton::AutomatonBase> { +class ToRegExpStateElimination : public std::SingleDispatch<ToRegExpStateElimination, regexp::RegExp, automaton::AutomatonBase> { public: /** * Performs conversion. @@ -45,12 +45,6 @@ private: static const regexp::RegExp transition(const automaton::ExtendedNFA& automaton, const automaton::State& from, const automaton::State& to); static automaton::ExtendedNFA eliminateState(const automaton::ExtendedNFA& extendedAutomaton, const automaton::State& state); - -public: - static ToRegExpStateElimination& getInstance() { - static ToRegExpStateElimination res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/automaton/determinize/Determinize.cpp b/alib2algo/src/automaton/determinize/Determinize.cpp index 723a3deac39135404bbbc917f91c8c130c792721..6447e4bc3702037f24b8c5cd885dc933a1b96e70 100644 --- a/alib2algo/src/automaton/determinize/Determinize.cpp +++ b/alib2algo/src/automaton/determinize/Determinize.cpp @@ -16,44 +16,44 @@ namespace automaton { namespace determinize { automaton::Automaton Determinize::determinize(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } DFA Determinize::determinize(const automaton::DFA& automaton) { return automaton; } -auto DeterminizeDFA = Determinize::RegistratorWrapper<automaton::DFA, automaton::DFA>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeDFA = Determinize::RegistratorWrapper<automaton::DFA, automaton::DFA>(Determinize::determinize); DPDA Determinize::determinize(const automaton::DPDA& automaton) { return automaton; } -auto DeterminizeDPDA = Determinize::RegistratorWrapper<automaton::DPDA, automaton::DPDA>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeDPDA = Determinize::RegistratorWrapper<automaton::DPDA, automaton::DPDA>(Determinize::determinize); SinglePopDPDA Determinize::determinize(const automaton::SinglePopDPDA& automaton) { return automaton; } -auto DeterminizeSinglePopDPDA = Determinize::RegistratorWrapper<automaton::SinglePopDPDA, automaton::SinglePopDPDA>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeSinglePopDPDA = Determinize::RegistratorWrapper<automaton::SinglePopDPDA, automaton::SinglePopDPDA>(Determinize::determinize); InputDrivenDPDA Determinize::determinize(const automaton::InputDrivenDPDA& automaton) { return automaton; } -auto DeterminizeInputDrivenDPDA = Determinize::RegistratorWrapper<automaton::InputDrivenDPDA, automaton::InputDrivenDPDA>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeInputDrivenDPDA = Determinize::RegistratorWrapper<automaton::InputDrivenDPDA, automaton::InputDrivenDPDA>(Determinize::determinize); VisiblyPushdownDPDA Determinize::determinize(const automaton::VisiblyPushdownDPDA& automaton) { return automaton; } -auto DeterminizeVisiblyPushdownDPDA = Determinize::RegistratorWrapper<automaton::VisiblyPushdownDPDA, automaton::VisiblyPushdownDPDA>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeVisiblyPushdownDPDA = Determinize::RegistratorWrapper<automaton::VisiblyPushdownDPDA, automaton::VisiblyPushdownDPDA>(Determinize::determinize); RealTimeHeightDeterministicDPDA Determinize::determinize(const automaton::RealTimeHeightDeterministicDPDA& automaton) { return automaton; } -auto DeterminizeRealTimeHeightDeterministicDPDA = Determinize::RegistratorWrapper<automaton::RealTimeHeightDeterministicDPDA, automaton::RealTimeHeightDeterministicDPDA>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeRealTimeHeightDeterministicDPDA = Determinize::RegistratorWrapper<automaton::RealTimeHeightDeterministicDPDA, automaton::RealTimeHeightDeterministicDPDA>(Determinize::determinize); DPDA Determinize::determinize(const automaton::NPDA& automaton) { automaton::RealTimeHeightDeterministicNPDA rhpda = automaton::PDAToRHPDA::convert(automaton); @@ -61,19 +61,19 @@ DPDA Determinize::determinize(const automaton::NPDA& automaton) { return automaton::RHPDAToPDA::convert(dpda); } -auto DeterminizeNPDA = Determinize::RegistratorWrapper<automaton::DPDA, automaton::NPDA>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeNPDA = Determinize::RegistratorWrapper<automaton::DPDA, automaton::NPDA>(Determinize::determinize); OneTapeDTM Determinize::determinize(const automaton::OneTapeDTM& automaton) { return automaton; } -auto DeterminizeOneTapeDTM = Determinize::RegistratorWrapper<automaton::OneTapeDTM, automaton::OneTapeDTM>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeOneTapeDTM = Determinize::RegistratorWrapper<automaton::OneTapeDTM, automaton::OneTapeDTM>(Determinize::determinize); DFTA Determinize::determinize(const automaton::DFTA& automaton) { return automaton; } -auto DeterminizeDFTA = Determinize::RegistratorWrapper<automaton::DFTA, automaton::DFTA>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeDFTA = Determinize::RegistratorWrapper<automaton::DFTA, automaton::DFTA>(Determinize::determinize); } /* namespace determinize */ diff --git a/alib2algo/src/automaton/determinize/Determinize.h b/alib2algo/src/automaton/determinize/Determinize.h index c21a55c36a0570beab8d89eecac1743ac3ae05af..0701af5eff40bb4e79c783af96eea368d87a5592 100644 --- a/alib2algo/src/automaton/determinize/Determinize.h +++ b/alib2algo/src/automaton/determinize/Determinize.h @@ -29,7 +29,7 @@ namespace determinize { /** * Class for running determinization algorithm on fsm. */ -class Determinize : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class Determinize : public std::SingleDispatch<Determinize, automaton::Automaton, automaton::AutomatonBase> { public: /** @@ -54,11 +54,6 @@ public: static automaton::DFTA determinize(const automaton::DFTA& nfta); static automaton::DFTA determinize(const automaton::NFTA& nfta); static automaton::OneTapeDTM determinize(const automaton::OneTapeDTM& nfta); - - static Determinize& getInstance() { - static Determinize res; - return res; - } }; } /* namespace determinize */ diff --git a/alib2algo/src/automaton/determinize/DeterminizeIDPDAPart.cxx b/alib2algo/src/automaton/determinize/DeterminizeIDPDAPart.cxx index 6bd860bf017e821ed701a2b0d6b128a4a07773da..df4fc1aad6d8d4f5ed81d7dbb44125750eef883e 100644 --- a/alib2algo/src/automaton/determinize/DeterminizeIDPDAPart.cxx +++ b/alib2algo/src/automaton/determinize/DeterminizeIDPDAPart.cxx @@ -70,7 +70,7 @@ automaton::InputDrivenDPDA Determinize::determinize ( const automaton::InputDriv return res; } -auto DeterminizeInputDrivenNPDA = Determinize::RegistratorWrapper < automaton::InputDrivenDPDA, automaton::InputDrivenNPDA > ( Determinize::getInstance ( ), Determinize::determinize ); +auto DeterminizeInputDrivenNPDA = Determinize::RegistratorWrapper < automaton::InputDrivenDPDA, automaton::InputDrivenNPDA > ( Determinize::determinize ); } /* namespace determinize */ diff --git a/alib2algo/src/automaton/determinize/DeterminizeNFAPart.cxx b/alib2algo/src/automaton/determinize/DeterminizeNFAPart.cxx index 3cd91e9658ba327056edd109a1e503d0582d5e3b..bc2fdb8e34794438bbfe9548ee7b3a960468280f 100644 --- a/alib2algo/src/automaton/determinize/DeterminizeNFAPart.cxx +++ b/alib2algo/src/automaton/determinize/DeterminizeNFAPart.cxx @@ -67,7 +67,7 @@ automaton::DFA Determinize::determinize ( const automaton::MultiInitialStateNFA return res; } -auto DeterminizeMultiInitialStateNFA = Determinize::RegistratorWrapper < automaton::DFA, automaton::MultiInitialStateNFA > ( Determinize::getInstance ( ), Determinize::determinize ); +auto DeterminizeMultiInitialStateNFA = Determinize::RegistratorWrapper < automaton::DFA, automaton::MultiInitialStateNFA > ( Determinize::determinize ); automaton::DFA Determinize::determinize ( const automaton::NFA & nfa ) { // 1, 4 @@ -120,7 +120,7 @@ automaton::DFA Determinize::determinize ( const automaton::NFA & nfa ) { return res; } -auto DeterminizeNFA = Determinize::RegistratorWrapper < automaton::DFA, automaton::NFA > ( Determinize::getInstance ( ), Determinize::determinize ); +auto DeterminizeNFA = Determinize::RegistratorWrapper < automaton::DFA, automaton::NFA > ( Determinize::determinize ); } /* namespace determinize */ diff --git a/alib2algo/src/automaton/determinize/DeterminizeNFTAPart.cxx b/alib2algo/src/automaton/determinize/DeterminizeNFTAPart.cxx index 0f467bddf20b0676afee7a61e2d4aca51bb5e8bb..a76a5e00c4096a2d66eac87fdcd10b99e22237e5 100644 --- a/alib2algo/src/automaton/determinize/DeterminizeNFTAPart.cxx +++ b/alib2algo/src/automaton/determinize/DeterminizeNFTAPart.cxx @@ -94,7 +94,7 @@ DFTA Determinize::determinize(const NFTA & nfta) { return res; } -auto DeterminizeNFTA = Determinize::RegistratorWrapper<automaton::DFTA, automaton::NFTA>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeNFTA = Determinize::RegistratorWrapper<automaton::DFTA, automaton::NFTA>( Determinize::determinize ); } /* namespace determinize */ diff --git a/alib2algo/src/automaton/determinize/DeterminizeRHDPDAPart.cxx b/alib2algo/src/automaton/determinize/DeterminizeRHDPDAPart.cxx index a3a27620d491b99b20f0e2f5ab2c0f12f466d5ab..4cc74f14aa202898ace95b7e2354657f483313f7 100644 --- a/alib2algo/src/automaton/determinize/DeterminizeRHDPDAPart.cxx +++ b/alib2algo/src/automaton/determinize/DeterminizeRHDPDAPart.cxx @@ -277,7 +277,7 @@ automaton::RealTimeHeightDeterministicDPDA Determinize::determinize(const automa return d; } -auto DeterminizeRealTimeHeightDeterministicNPDA = Determinize::RegistratorWrapper<automaton::RealTimeHeightDeterministicDPDA, automaton::RealTimeHeightDeterministicNPDA>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeRealTimeHeightDeterministicNPDA = Determinize::RegistratorWrapper<automaton::RealTimeHeightDeterministicDPDA, automaton::RealTimeHeightDeterministicNPDA>( Determinize::determinize ); } /* namespace determinize */ diff --git a/alib2algo/src/automaton/determinize/DeterminizeVPAPart.cxx b/alib2algo/src/automaton/determinize/DeterminizeVPAPart.cxx index 8bb8b005915e1f2b21be53ad9330f22b877ececc..5f7f1522be3ae53fdfbaae4c28e796ebaf68eb01 100644 --- a/alib2algo/src/automaton/determinize/DeterminizeVPAPart.cxx +++ b/alib2algo/src/automaton/determinize/DeterminizeVPAPart.cxx @@ -209,7 +209,7 @@ automaton::VisiblyPushdownDPDA Determinize::determinize(const automaton::Visibly return d; } -auto DeterminizeVisiblyPushdownNPDA = Determinize::RegistratorWrapper<automaton::VisiblyPushdownDPDA, automaton::VisiblyPushdownNPDA>(Determinize::getInstance(), Determinize::determinize); +auto DeterminizeVisiblyPushdownNPDA = Determinize::RegistratorWrapper<automaton::VisiblyPushdownDPDA, automaton::VisiblyPushdownNPDA>( Determinize::determinize ); } /* namespace determinize */ diff --git a/alib2algo/src/automaton/properties/AllEpsilonClosure.cpp b/alib2algo/src/automaton/properties/AllEpsilonClosure.cpp index f699a63c8f2f72b7f7e729da8bc69ca7204de90b..7969aaecfa8703a16ab7f77df2468f6f0ead23f5 100644 --- a/alib2algo/src/automaton/properties/AllEpsilonClosure.cpp +++ b/alib2algo/src/automaton/properties/AllEpsilonClosure.cpp @@ -52,7 +52,7 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return Qi.at(i); } -auto AllEpsilonClosureEpsilonNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::EpsilonNFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureEpsilonNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::EpsilonNFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::MultiInitialStateNFA & fsm) { std::map<automaton::State, std::set<automaton::State>> closure; @@ -61,7 +61,7 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return closure; } -auto AllEpsilonClosureMultiInitialStateNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::MultiInitialStateNFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureMultiInitialStateNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::MultiInitialStateNFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::NFA & fsm) { std::map<automaton::State, std::set<automaton::State>> closure; @@ -70,7 +70,7 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return closure; } -auto AllEpsilonClosureNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::NFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::NFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::DFA & fsm) { std::map<automaton::State, std::set<automaton::State>> closure; @@ -79,7 +79,7 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return closure; } -auto AllEpsilonClosureDFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::DFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureDFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::DFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::ExtendedNFA & fsm) { std::map<automaton::State, std::set<automaton::State>> res; @@ -103,7 +103,7 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return res; } -auto AllEpsilonClosureExtendedNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::ExtendedNFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureExtendedNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::ExtendedNFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::CompactNFA & fsm) { std::map<automaton::State, std::set<automaton::State>> res; @@ -127,10 +127,10 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return res; } -auto AllEpsilonClosureCompactNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::CompactNFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureCompactNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::CompactNFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure(const Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /* namespace properties */ diff --git a/alib2algo/src/automaton/properties/AllEpsilonClosure.h b/alib2algo/src/automaton/properties/AllEpsilonClosure.h index 119c7efccd19cff9a37538bb1bd7669bbe23fbcf..d5b8164e6e642e0418f489c82fe545c948d7064b 100644 --- a/alib2algo/src/automaton/properties/AllEpsilonClosure.h +++ b/alib2algo/src/automaton/properties/AllEpsilonClosure.h @@ -19,7 +19,7 @@ namespace automaton { namespace properties { -class AllEpsilonClosure : public std::SingleDispatch<std::map<automaton::State, std::set<automaton::State>>, automaton::AutomatonBase> { +class AllEpsilonClosure : public std::SingleDispatch<AllEpsilonClosure, std::map<automaton::State, std::set<automaton::State>>, automaton::AutomatonBase> { public: static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::Automaton & automaton); @@ -32,11 +32,6 @@ public: static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::DFA & fsm); static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::ExtendedNFA & fsm); static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::CompactNFA & fsm); - - static AllEpsilonClosure& getInstance() { - static AllEpsilonClosure res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/automaton/properties/EpsilonClosure.cpp b/alib2algo/src/automaton/properties/EpsilonClosure.cpp index 26f0a4a2a730cba722cded9536ffb4d9df42e81e..9910bca8a7d161d94385f9aaf3a83d55a0048085 100644 --- a/alib2algo/src/automaton/properties/EpsilonClosure.cpp +++ b/alib2algo/src/automaton/properties/EpsilonClosure.cpp @@ -53,7 +53,7 @@ std::set<automaton::State> EpsilonClosure::epsilonClosure( const automaton::Epsi return closure; } -auto EpsilonClosureEpsilonNFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(EpsilonClosure::getInstance(), EpsilonClosure::epsilonClosure); +auto EpsilonClosureEpsilonNFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(EpsilonClosure::epsilonClosure); std::set<automaton::State> EpsilonClosure::epsilonClosure( const automaton::MultiInitialStateNFA & fsm, const automaton::State & q ) { if(! fsm.getStates().count(q) ) throw exception::CommonException("State is not in the automaton"); @@ -63,7 +63,7 @@ std::set<automaton::State> EpsilonClosure::epsilonClosure( const automaton::Mult return closure; } -auto EpsilonClosureMultiInitialStateNFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(EpsilonClosure::getInstance(), EpsilonClosure::epsilonClosure); +auto EpsilonClosureMultiInitialStateNFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(EpsilonClosure::epsilonClosure); std::set<automaton::State> EpsilonClosure::epsilonClosure( const automaton::NFA & fsm, const automaton::State & q ) { if(! fsm.getStates().count(q) ) throw exception::CommonException("State is not in the automaton"); @@ -73,7 +73,7 @@ std::set<automaton::State> EpsilonClosure::epsilonClosure( const automaton::NFA return closure; } -auto EpsilonClosureNFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(EpsilonClosure::getInstance(), EpsilonClosure::epsilonClosure); +auto EpsilonClosureNFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(EpsilonClosure::epsilonClosure); std::set<automaton::State> EpsilonClosure::epsilonClosure( const automaton::DFA & fsm, const automaton::State & q ) { if(! fsm.getStates().count(q) ) throw exception::CommonException("State is not in the automaton"); @@ -83,7 +83,7 @@ std::set<automaton::State> EpsilonClosure::epsilonClosure( const automaton::DFA return closure; } -auto EpsilonClosureDFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::DFA>(EpsilonClosure::getInstance(), EpsilonClosure::epsilonClosure); +auto EpsilonClosureDFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::DFA>(EpsilonClosure::epsilonClosure); std::set<automaton::State> EpsilonClosure::epsilonClosure( const automaton::ExtendedNFA & fsm, const automaton::State & q ) { if(! fsm.getStates().count(q) ) throw exception::CommonException("State is not in the automaton"); @@ -113,7 +113,7 @@ std::set<automaton::State> EpsilonClosure::epsilonClosure( const automaton::Exte return closure; } -auto EpsilonClosureExtendedNFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(EpsilonClosure::getInstance(), EpsilonClosure::epsilonClosure); +auto EpsilonClosureExtendedNFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(EpsilonClosure::epsilonClosure); std::set<automaton::State> EpsilonClosure::epsilonClosure( const automaton::CompactNFA & fsm, const automaton::State & q ) { if(! fsm.getStates().count(q) ) throw exception::CommonException("State is not in the automaton"); @@ -143,10 +143,10 @@ std::set<automaton::State> EpsilonClosure::epsilonClosure( const automaton::Comp return closure; } -auto EpsilonClosureCompactNFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(EpsilonClosure::getInstance(), EpsilonClosure::epsilonClosure); +auto EpsilonClosureCompactNFA = EpsilonClosure::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(EpsilonClosure::epsilonClosure); std::set<automaton::State> EpsilonClosure::epsilonClosure(const Automaton& automaton, const automaton::State& q) { - return getInstance().dispatch(automaton.getData(), q); + return dispatch(automaton.getData(), q); } } /* namespace properties */ diff --git a/alib2algo/src/automaton/properties/EpsilonClosure.h b/alib2algo/src/automaton/properties/EpsilonClosure.h index 93464931140cf612c69695ec5282ca6588d6c214..e2b3f834afb9ef757640b4969bfff3b96425357a 100644 --- a/alib2algo/src/automaton/properties/EpsilonClosure.h +++ b/alib2algo/src/automaton/properties/EpsilonClosure.h @@ -20,7 +20,7 @@ namespace automaton { namespace properties { -class EpsilonClosure : public std::SingleDispatchLastStaticParam<std::set<automaton::State>, automaton::AutomatonBase, const automaton::State&> { +class EpsilonClosure : public std::SingleDispatchLastStaticParam< EpsilonClosure, std::set<automaton::State>, automaton::AutomatonBase, const automaton::State&> { public: static std::set<automaton::State> epsilonClosure( const automaton::Automaton & automaton, const automaton::State & state ); @@ -33,11 +33,6 @@ public: static std::set<automaton::State> epsilonClosure( const automaton::DFA & fsm, const automaton::State & state ); static std::set<automaton::State> epsilonClosure( const automaton::ExtendedNFA & fsm, const automaton::State & state ); static std::set<automaton::State> epsilonClosure( const automaton::CompactNFA & fsm, const automaton::State & state ); - - static EpsilonClosure& getInstance() { - static EpsilonClosure res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/automaton/properties/ReachableStates.cpp b/alib2algo/src/automaton/properties/ReachableStates.cpp index 7cd6ac9e8bcc56313beefe4c3dd7214a5e469fe3..4613270de326be6c9e7012af3d1e12bf97c25b30 100644 --- a/alib2algo/src/automaton/properties/ReachableStates.cpp +++ b/alib2algo/src/automaton/properties/ReachableStates.cpp @@ -22,7 +22,7 @@ namespace automaton { namespace properties { std::set<automaton::State> ReachableStates::reachableStates(const Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } template<class T> @@ -51,10 +51,10 @@ std::set<automaton::State> ReachableStates::reachableStates( const T & fsm ) { return Qi.at( i ); } -auto ReachableStatesEpsilonNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); -auto ReachableStatesNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); -auto ReachableStatesCompactNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); -auto ReachableStatesExtendedNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); +auto ReachableStatesEpsilonNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(ReachableStates::reachableStates); +auto ReachableStatesNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(ReachableStates::reachableStates); +auto ReachableStatesCompactNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(ReachableStates::reachableStates); +auto ReachableStatesExtendedNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(ReachableStates::reachableStates); template<> std::set<automaton::State> ReachableStates::reachableStates( const automaton::MultiInitialStateNFA & fsm ) { @@ -82,7 +82,7 @@ std::set<automaton::State> ReachableStates::reachableStates( const automaton::Mu return Qi.at( i ); } -auto ReachableStatesMultiInitialStateNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); +auto ReachableStatesMultiInitialStateNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(ReachableStates::reachableStates); template<> std::set<automaton::State> ReachableStates::reachableStates( const automaton::DFA & fsm ) { @@ -110,7 +110,7 @@ std::set<automaton::State> ReachableStates::reachableStates( const automaton::DF return Qi.at( i ); } -auto ReachableStatesDFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::DFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); +auto ReachableStatesDFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::DFA>(ReachableStates::reachableStates); } /* namespace properties */ diff --git a/alib2algo/src/automaton/properties/ReachableStates.h b/alib2algo/src/automaton/properties/ReachableStates.h index 8a809b3f14f8ceb593e34f07890c598f56cf42b1..f16ece52aed4253dcd09cf9e1145b49931992fe5 100644 --- a/alib2algo/src/automaton/properties/ReachableStates.h +++ b/alib2algo/src/automaton/properties/ReachableStates.h @@ -20,7 +20,7 @@ namespace automaton { namespace properties { -class ReachableStates : public std::SingleDispatch<std::set<automaton::State>, automaton::AutomatonBase> { +class ReachableStates : public std::SingleDispatch<ReachableStates, std::set<automaton::State>, automaton::AutomatonBase> { public: static std::set<automaton::State> reachableStates( const automaton::Automaton & automaton ); @@ -29,11 +29,6 @@ public: */ template<class T> static std::set<automaton::State> reachableStates( const T & fsm ); - - static ReachableStates& getInstance() { - static ReachableStates res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/automaton/properties/UsefullStates.cpp b/alib2algo/src/automaton/properties/UsefullStates.cpp index f0949a0da265002776e73cca40b25339d2916f65..6c6a1732fa9a0a627ffd29c4392c090a9557a981 100644 --- a/alib2algo/src/automaton/properties/UsefullStates.cpp +++ b/alib2algo/src/automaton/properties/UsefullStates.cpp @@ -22,7 +22,7 @@ namespace automaton { namespace properties { std::set<automaton::State> UsefullStates::usefullStates(const Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } template<class T> @@ -49,11 +49,11 @@ std::set<automaton::State> UsefullStates::usefullStates( const T & fsm ) { return Qi.at( i ); } -auto UsefullStatesEpsilonNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); -auto UsefullStatesNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); -auto UsefullStatesCompactNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); -auto UsefullStatesExtendedNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); -auto UsefullStatesMultiInitialStateNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); +auto UsefullStatesEpsilonNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(UsefullStates::usefullStates); +auto UsefullStatesNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(UsefullStates::usefullStates); +auto UsefullStatesCompactNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(UsefullStates::usefullStates); +auto UsefullStatesExtendedNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(UsefullStates::usefullStates); +auto UsefullStatesMultiInitialStateNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(UsefullStates::usefullStates); template<> std::set<automaton::State> UsefullStates::usefullStates( const automaton::DFA & fsm ) { @@ -79,7 +79,7 @@ std::set<automaton::State> UsefullStates::usefullStates( const automaton::DFA & return Qi.at( i ); } -auto UsefullStatesDFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::DFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); +auto UsefullStatesDFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::DFA>(UsefullStates::usefullStates); } /* namespace properties */ diff --git a/alib2algo/src/automaton/properties/UsefullStates.h b/alib2algo/src/automaton/properties/UsefullStates.h index 3b962e19fecbced9cf758c5c4915bd5fe467cbd0..f6cdc6b2fd631efbcaad0867eeeba2858704b101 100644 --- a/alib2algo/src/automaton/properties/UsefullStates.h +++ b/alib2algo/src/automaton/properties/UsefullStates.h @@ -20,7 +20,7 @@ namespace automaton { namespace properties { -class UsefullStates : public std::SingleDispatch<std::set<automaton::State>, automaton::AutomatonBase> { +class UsefullStates : public std::SingleDispatch<UsefullStates, std::set<automaton::State>, automaton::AutomatonBase> { public: static std::set<automaton::State> usefullStates( const automaton::Automaton & automaton ); @@ -29,11 +29,6 @@ public: */ template<class T> static std::set<automaton::State> usefullStates( const T & fsm ); - - static UsefullStates& getInstance() { - static UsefullStates res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.cpp b/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.cpp index 2e78ceeec4bee5651c6c79a7121c1b8a274580be..9bd3811f8614060ca2c9b622603752d3e1c6e5df 100644 --- a/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.cpp +++ b/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.cpp @@ -17,19 +17,19 @@ automaton::DFA EpsilonRemoverIncoming::remove(const automaton::DFA& origFSM) { return origFSM; } -auto EpsilonRemoverIncomingDFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::DFA, automaton::DFA>(EpsilonRemoverIncoming::getInstance(), EpsilonRemoverIncoming::remove); +auto EpsilonRemoverIncomingDFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::DFA, automaton::DFA>(EpsilonRemoverIncoming::remove); automaton::MultiInitialStateNFA EpsilonRemoverIncoming::remove(const automaton::MultiInitialStateNFA& origFSM) { return origFSM; } -auto EpsilonRemoverIncomingMultiInitialStateNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(EpsilonRemoverIncoming::getInstance(), EpsilonRemoverIncoming::remove); +auto EpsilonRemoverIncomingMultiInitialStateNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(EpsilonRemoverIncoming::remove); automaton::NFA EpsilonRemoverIncoming::remove(const automaton::NFA& origFSM) { return origFSM; } -auto EpsilonRemoverIncomingNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::NFA, automaton::NFA>(EpsilonRemoverIncoming::getInstance(), EpsilonRemoverIncoming::remove); +auto EpsilonRemoverIncomingNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::NFA, automaton::NFA>(EpsilonRemoverIncoming::remove); automaton::NFA EpsilonRemoverIncoming::remove( const automaton::EpsilonNFA & origFSM ) { automaton::NFA fsm(origFSM.getInitialState()); @@ -69,10 +69,10 @@ automaton::NFA EpsilonRemoverIncoming::remove( const automaton::EpsilonNFA & ori return fsm; } -auto EpsilonRemoverIncomingEpsilonNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::NFA, automaton::EpsilonNFA>(EpsilonRemoverIncoming::getInstance(), EpsilonRemoverIncoming::remove); +auto EpsilonRemoverIncomingEpsilonNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::NFA, automaton::EpsilonNFA>(EpsilonRemoverIncoming::remove); automaton::Automaton EpsilonRemoverIncoming::remove(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h b/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h index 7bcfbf059bbc6555b7001a9bf1a0a20425468aa7..4204bf939668be2a3efaa2a421bca0df443972ce 100644 --- a/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h +++ b/alib2algo/src/automaton/simplify/EpsilonRemoverIncoming.h @@ -20,7 +20,7 @@ namespace automaton { namespace simplify { -class EpsilonRemoverIncoming : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class EpsilonRemoverIncoming : public std::SingleDispatch<EpsilonRemoverIncoming, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton remove( const automaton::Automaton & automaton ); @@ -32,10 +32,6 @@ public: static automaton::NFA remove( const automaton::NFA & fsm ); static automaton::DFA remove( const automaton::DFA & fsm ); - static EpsilonRemoverIncoming& getInstance() { - static EpsilonRemoverIncoming res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.cpp b/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.cpp index 3804e576ee47822171f66612c85b61fa8000cddc..7f090a806861134082f473ebec83a68ce9c259f5 100644 --- a/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.cpp +++ b/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.cpp @@ -17,19 +17,19 @@ automaton::DFA EpsilonRemoverOutgoing::remove(const automaton::DFA& origFSM) { return origFSM; } -auto EpsilonRemoverOutgoingDFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::DFA, automaton::DFA>(EpsilonRemoverOutgoing::getInstance(), EpsilonRemoverOutgoing::remove); +auto EpsilonRemoverOutgoingDFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::DFA, automaton::DFA>(EpsilonRemoverOutgoing::remove); automaton::MultiInitialStateNFA EpsilonRemoverOutgoing::remove(const automaton::MultiInitialStateNFA& origFSM) { return origFSM; } -auto EpsilonRemoverOutgoingMultiInitialStateNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(EpsilonRemoverOutgoing::getInstance(), EpsilonRemoverOutgoing::remove); +auto EpsilonRemoverOutgoingMultiInitialStateNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(EpsilonRemoverOutgoing::remove); automaton::NFA EpsilonRemoverOutgoing::remove(const automaton::NFA& origFSM) { return origFSM; } -auto EpsilonRemoverOutgoingNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::NFA, automaton::NFA>(EpsilonRemoverOutgoing::getInstance(), EpsilonRemoverOutgoing::remove); +auto EpsilonRemoverOutgoingNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::NFA, automaton::NFA>(EpsilonRemoverOutgoing::remove); automaton::MultiInitialStateNFA EpsilonRemoverOutgoing::remove( const automaton::EpsilonNFA & origFSM ) { automaton::MultiInitialStateNFA fsm; @@ -62,10 +62,10 @@ automaton::MultiInitialStateNFA EpsilonRemoverOutgoing::remove( const automaton: return fsm; } -auto EpsilonRemoverOutgoingEpsilonNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::EpsilonNFA>(EpsilonRemoverOutgoing::getInstance(), EpsilonRemoverOutgoing::remove); +auto EpsilonRemoverOutgoingEpsilonNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::EpsilonNFA>(EpsilonRemoverOutgoing::remove); automaton::Automaton EpsilonRemoverOutgoing::remove(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h b/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h index 67ec9b93e11f05dcfeaa4f222de14c3b7e9c4722..46aab269d641977f6059e90d11a0d3bd335ef235 100644 --- a/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h +++ b/alib2algo/src/automaton/simplify/EpsilonRemoverOutgoing.h @@ -20,7 +20,7 @@ namespace automaton { namespace simplify { -class EpsilonRemoverOutgoing : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class EpsilonRemoverOutgoing : public std::SingleDispatch<EpsilonRemoverOutgoing, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton remove( const automaton::Automaton & automaton ); @@ -31,11 +31,6 @@ public: static automaton::MultiInitialStateNFA remove( const automaton::MultiInitialStateNFA & fsm ); static automaton::NFA remove( const automaton::NFA & fsm ); static automaton::DFA remove( const automaton::DFA & fsm ); - - static EpsilonRemoverOutgoing& getInstance() { - static EpsilonRemoverOutgoing res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/Minimize.cpp b/alib2algo/src/automaton/simplify/Minimize.cpp index 3351a59c34cf966f0cddf4922f045a6900feb2d8..c41fa3d38f599f46c69c383993cde1d729979914 100644 --- a/alib2algo/src/automaton/simplify/Minimize.cpp +++ b/alib2algo/src/automaton/simplify/Minimize.cpp @@ -21,7 +21,7 @@ namespace automaton { namespace simplify { automaton::Automaton Minimize::minimize(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } automaton::DFA Minimize::minimize(const automaton::DFA& dfa) { @@ -219,7 +219,7 @@ void Minimize::print_progress(const automaton::DFA& dfa, const std::map<std::pai std::clog << std::endl; } -auto MinimizeNFA = Minimize::RegistratorWrapper<automaton::DFA, automaton::DFA>(Minimize::getInstance(), Minimize::minimize); +auto MinimizeNFA = Minimize::RegistratorWrapper<automaton::DFA, automaton::DFA>( Minimize::minimize ); } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/Minimize.h b/alib2algo/src/automaton/simplify/Minimize.h index ca95d44343bcf6dabf6f96cc0c3e1752982f2a13..9b03c33c4610c901a55b2ba25d5aacdc53042cee 100644 --- a/alib2algo/src/automaton/simplify/Minimize.h +++ b/alib2algo/src/automaton/simplify/Minimize.h @@ -16,7 +16,7 @@ namespace automaton { namespace simplify { -class Minimize : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class Minimize : public std::SingleDispatch<Minimize, automaton::Automaton, automaton::AutomatonBase> { public: /** * @param dfa automaton to minimize @@ -25,11 +25,6 @@ public: static automaton::DFA minimize(const automaton::DFA& dfa); - static Minimize& getInstance() { - static Minimize res; - return res; - } - private: static void print_progress(const automaton::DFA& dfa, const std::map<std::pair<automaton::State, std::set<std::pair<alphabet::Symbol, automaton::State> > >, std::set<automaton::State> >& minimizedTransitionFunction, size_t iter); }; diff --git a/alib2algo/src/automaton/simplify/MinimizeBrzozowski.cpp b/alib2algo/src/automaton/simplify/MinimizeBrzozowski.cpp index 99f9c32dccad8a4e36b5ffc9929b447a127d8f6f..6f985c73fbf897dba360cdcbf62aaa4c6be01ef8 100644 --- a/alib2algo/src/automaton/simplify/MinimizeBrzozowski.cpp +++ b/alib2algo/src/automaton/simplify/MinimizeBrzozowski.cpp @@ -18,20 +18,20 @@ namespace automaton { namespace simplify { automaton::Automaton MinimizeBrzozowski::minimize(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } automaton::DFA MinimizeBrzozowski::minimize(const automaton::DFA& dfa) { return automaton::determinize::Determinize::determinize(automaton::transform::Reverse::convert(automaton::determinize::Determinize::determinize(automaton::transform::Reverse::convert(dfa)))); } -auto MinimizeBrzozowskiDFA = MinimizeBrzozowski::RegistratorWrapper<automaton::DFA, automaton::DFA>(MinimizeBrzozowski::getInstance(), MinimizeBrzozowski::minimize); +auto MinimizeBrzozowskiDFA = MinimizeBrzozowski::RegistratorWrapper<automaton::DFA, automaton::DFA>(MinimizeBrzozowski::minimize); automaton::DFA MinimizeBrzozowski::minimize(const automaton::NFA& nfa) { return automaton::determinize::Determinize::determinize(automaton::transform::Reverse::convert(automaton::determinize::Determinize::determinize(automaton::transform::Reverse::convert(nfa)))); } -auto MinimizeBrzozowskiNFA = MinimizeBrzozowski::RegistratorWrapper<automaton::DFA, automaton::NFA>(MinimizeBrzozowski::getInstance(), MinimizeBrzozowski::minimize); +auto MinimizeBrzozowskiNFA = MinimizeBrzozowski::RegistratorWrapper<automaton::DFA, automaton::NFA>(MinimizeBrzozowski::minimize); } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/MinimizeBrzozowski.h b/alib2algo/src/automaton/simplify/MinimizeBrzozowski.h index f1bb7cd66b075169ad65de675451ec624e7ba44b..b0f25204f0e8497634b691d28b07a93c77b6804e 100644 --- a/alib2algo/src/automaton/simplify/MinimizeBrzozowski.h +++ b/alib2algo/src/automaton/simplify/MinimizeBrzozowski.h @@ -16,7 +16,7 @@ namespace automaton { namespace simplify { -class MinimizeBrzozowski : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class MinimizeBrzozowski : public std::SingleDispatch<MinimizeBrzozowski, automaton::Automaton, automaton::AutomatonBase> { public: /** * @param dfa automaton to minimize @@ -25,11 +25,6 @@ public: static automaton::DFA minimize(const automaton::DFA& dfa); static automaton::DFA minimize(const automaton::NFA& nfa); - - static MinimizeBrzozowski& getInstance() { - static MinimizeBrzozowski res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/Normalize.cpp b/alib2algo/src/automaton/simplify/Normalize.cpp index 9ad5a99804b066702af7777b54b8a63af22c75b1..4dec16d9e557d99198908edbf8d4d16648077db3 100644 --- a/alib2algo/src/automaton/simplify/Normalize.cpp +++ b/alib2algo/src/automaton/simplify/Normalize.cpp @@ -22,7 +22,7 @@ namespace automaton { namespace simplify { automaton::Automaton Normalize::normalize(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } automaton::DFA Normalize::normalize(const automaton::DFA& fsm) { @@ -71,7 +71,7 @@ automaton::DFA Normalize::normalize(const automaton::DFA& fsm) { return result; } -auto NormalizeDFA = Normalize::RegistratorWrapper<automaton::DFA, automaton::DFA>(Normalize::getInstance(), Normalize::normalize); +auto NormalizeDFA = Normalize::RegistratorWrapper<automaton::DFA, automaton::DFA>(Normalize::normalize); automaton::DPDA Normalize::normalize(const automaton::DPDA& pda) { int counterState = 0; @@ -163,7 +163,7 @@ automaton::DPDA Normalize::normalize(const automaton::DPDA& pda) { return result; } -auto NormalizeDPDA = Normalize::RegistratorWrapper<automaton::DPDA, automaton::DPDA>(Normalize::getInstance(), Normalize::normalize); +auto NormalizeDPDA = Normalize::RegistratorWrapper<automaton::DPDA, automaton::DPDA>(Normalize::normalize); } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/Normalize.h b/alib2algo/src/automaton/simplify/Normalize.h index 7bcc2f266c08c2913c055c7401050225df12ef57..f50df2e1eb72000a9c9ef700976f37d38e0845f4 100644 --- a/alib2algo/src/automaton/simplify/Normalize.h +++ b/alib2algo/src/automaton/simplify/Normalize.h @@ -17,7 +17,7 @@ namespace automaton { namespace simplify { -class Normalize : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class Normalize : public std::SingleDispatch<Normalize, automaton::Automaton, automaton::AutomatonBase> { public: /** * @param dfa automaton to normalize @@ -26,11 +26,6 @@ public: static automaton::DFA normalize(const automaton::DFA& dfa); static automaton::DPDA normalize(const automaton::DPDA& dfa); - - static Normalize& getInstance() { - static Normalize res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/Rename.cpp b/alib2algo/src/automaton/simplify/Rename.cpp index c6e394649efe271b6936d010937181a06264a197..a58df12807a2353df0db2be51c7546f3facbace3 100644 --- a/alib2algo/src/automaton/simplify/Rename.cpp +++ b/alib2algo/src/automaton/simplify/Rename.cpp @@ -24,7 +24,7 @@ namespace automaton { namespace simplify { automaton::Automaton Rename::rename(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } automaton::DFA Rename::rename(const automaton::DFA& fsm) { @@ -54,7 +54,7 @@ automaton::DFA Rename::rename(const automaton::DFA& fsm) { return result; } -auto RenameDFA = Rename::RegistratorWrapper<automaton::DFA, automaton::DFA>(Rename::getInstance(), Rename::rename); +auto RenameDFA = Rename::RegistratorWrapper<automaton::DFA, automaton::DFA>(Rename::rename); automaton::DPDA Rename::rename(const automaton::DPDA& pda) { int counterState = 0; @@ -101,7 +101,7 @@ automaton::DPDA Rename::rename(const automaton::DPDA& pda) { return result; } -auto RenameDPDA = Rename::RegistratorWrapper<automaton::DPDA, automaton::DPDA>(Rename::getInstance(), Rename::rename); +auto RenameDPDA = Rename::RegistratorWrapper<automaton::DPDA, automaton::DPDA>(Rename::rename); automaton::SinglePopDPDA Rename::rename(const automaton::SinglePopDPDA& pda) { int counterState = 0; @@ -144,7 +144,7 @@ automaton::SinglePopDPDA Rename::rename(const automaton::SinglePopDPDA& pda) { return result; } -auto RenameSinglePopDPDA = Rename::RegistratorWrapper<automaton::SinglePopDPDA, automaton::SinglePopDPDA>(Rename::getInstance(), Rename::rename); +auto RenameSinglePopDPDA = Rename::RegistratorWrapper<automaton::SinglePopDPDA, automaton::SinglePopDPDA>(Rename::rename); automaton::InputDrivenDPDA Rename::rename(const automaton::InputDrivenDPDA& pda) { int counter = 0; @@ -192,7 +192,7 @@ automaton::InputDrivenDPDA Rename::rename(const automaton::InputDrivenDPDA& pda) return result; } -auto RenameInputDrivenDPDA = Rename::RegistratorWrapper<automaton::InputDrivenDPDA, automaton::InputDrivenDPDA>(Rename::getInstance(), Rename::rename); +auto RenameInputDrivenDPDA = Rename::RegistratorWrapper<automaton::InputDrivenDPDA, automaton::InputDrivenDPDA>(Rename::rename); automaton::VisiblyPushdownDPDA Rename::rename(const automaton::VisiblyPushdownDPDA& pda) { int counterState = 0; @@ -241,7 +241,7 @@ automaton::VisiblyPushdownDPDA Rename::rename(const automaton::VisiblyPushdownDP return result; } -auto RenameVisiblyPushdownDPDA = Rename::RegistratorWrapper<automaton::VisiblyPushdownDPDA, automaton::VisiblyPushdownDPDA>(Rename::getInstance(), Rename::rename); +auto RenameVisiblyPushdownDPDA = Rename::RegistratorWrapper<automaton::VisiblyPushdownDPDA, automaton::VisiblyPushdownDPDA>(Rename::rename); automaton::RealTimeHeightDeterministicDPDA Rename::rename(const automaton::RealTimeHeightDeterministicDPDA& pda) { int counterState = 0; @@ -288,7 +288,7 @@ automaton::RealTimeHeightDeterministicDPDA Rename::rename(const automaton::RealT return result; } -auto RenameRealTimeHeightDeterministicDPDA = Rename::RegistratorWrapper<automaton::RealTimeHeightDeterministicDPDA, automaton::RealTimeHeightDeterministicDPDA>(Rename::getInstance(), Rename::rename); +auto RenameRealTimeHeightDeterministicDPDA = Rename::RegistratorWrapper<automaton::RealTimeHeightDeterministicDPDA, automaton::RealTimeHeightDeterministicDPDA>(Rename::rename); } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/Rename.h b/alib2algo/src/automaton/simplify/Rename.h index 747e9c6b3997ee1be67ef5fceb8381393668d7f1..6e9ae94d4f6dc999740ac01df8033fc8fb645971 100644 --- a/alib2algo/src/automaton/simplify/Rename.h +++ b/alib2algo/src/automaton/simplify/Rename.h @@ -21,7 +21,7 @@ namespace automaton { namespace simplify { -class Rename : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class Rename : public std::SingleDispatch<Rename, automaton::Automaton, automaton::AutomatonBase> { public: /** * @param dfa automaton to rename @@ -34,11 +34,6 @@ public: static automaton::InputDrivenDPDA rename(const automaton::InputDrivenDPDA& pda); static automaton::VisiblyPushdownDPDA rename(const automaton::VisiblyPushdownDPDA& pda); static automaton::RealTimeHeightDeterministicDPDA rename(const automaton::RealTimeHeightDeterministicDPDA& pda); - - static Rename& getInstance() { - static Rename res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/SingleInitialState.cpp b/alib2algo/src/automaton/simplify/SingleInitialState.cpp index 26e4ff56ad53a1cd08c5e148aa4a046cc5c28896..66071b292b6373ee1d7ad1d92c7081b02dac8f50 100644 --- a/alib2algo/src/automaton/simplify/SingleInitialState.cpp +++ b/alib2algo/src/automaton/simplify/SingleInitialState.cpp @@ -24,7 +24,7 @@ namespace automaton { namespace simplify { automaton::Automaton SingleInitialState::convert(const Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } automaton::NFA SingleInitialState::convert(const automaton::MultiInitialStateNFA& automaton) { @@ -67,37 +67,37 @@ automaton::NFA SingleInitialState::convert(const automaton::MultiInitialStateNFA return res; } -auto SingleInitialStateMultiInitialStateNFA = SingleInitialState::RegistratorWrapper<automaton::NFA, automaton::MultiInitialStateNFA>(SingleInitialState::getInstance(), SingleInitialState::convert); +auto SingleInitialStateMultiInitialStateNFA = SingleInitialState::RegistratorWrapper<automaton::NFA, automaton::MultiInitialStateNFA>(SingleInitialState::convert); automaton::DFA SingleInitialState::convert(const automaton::DFA& automaton) { return automaton; } -auto SingleInitialStateDFA = SingleInitialState::RegistratorWrapper<automaton::DFA, automaton::DFA>(SingleInitialState::getInstance(), SingleInitialState::convert); +auto SingleInitialStateDFA = SingleInitialState::RegistratorWrapper<automaton::DFA, automaton::DFA>(SingleInitialState::convert); automaton::EpsilonNFA SingleInitialState::convert(const automaton::EpsilonNFA& automaton) { return automaton; } -auto SingleInitialStateEpsilonNFA = SingleInitialState::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(SingleInitialState::getInstance(), SingleInitialState::convert); +auto SingleInitialStateEpsilonNFA = SingleInitialState::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(SingleInitialState::convert); automaton::NFA SingleInitialState::convert(const automaton::NFA& automaton) { return automaton; } -auto SingleInitialStateNFA = SingleInitialState::RegistratorWrapper<automaton::NFA, automaton::NFA>(SingleInitialState::getInstance(), SingleInitialState::convert); +auto SingleInitialStateNFA = SingleInitialState::RegistratorWrapper<automaton::NFA, automaton::NFA>(SingleInitialState::convert); automaton::CompactNFA SingleInitialState::convert(const automaton::CompactNFA& automaton) { return automaton; } -auto SingleInitialStateCompactNFA = SingleInitialState::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(SingleInitialState::getInstance(), SingleInitialState::convert); +auto SingleInitialStateCompactNFA = SingleInitialState::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(SingleInitialState::convert); automaton::ExtendedNFA SingleInitialState::convert(const automaton::ExtendedNFA& automaton) { return automaton; } -auto SingleInitialStateExtendedNFA = SingleInitialState::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(SingleInitialState::getInstance(), SingleInitialState::convert); +auto SingleInitialStateExtendedNFA = SingleInitialState::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(SingleInitialState::convert); } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/SingleInitialState.h b/alib2algo/src/automaton/simplify/SingleInitialState.h index c913e6fcd20ed2bfe3abbdc97281e715b1352e30..bdbcf487d50bf3adecb2bdc2ff6430b162f7dac3 100644 --- a/alib2algo/src/automaton/simplify/SingleInitialState.h +++ b/alib2algo/src/automaton/simplify/SingleInitialState.h @@ -19,7 +19,7 @@ namespace simplify { * Makes finite automaton's transition function convert. * Source: Melichar: Algorithm 2.22 */ -class SingleInitialState : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class SingleInitialState : public std::SingleDispatch<SingleInitialState, automaton::Automaton, automaton::AutomatonBase> { public: /** * Computes epsilon closure of a state in epsilon nonfree automaton @@ -33,11 +33,6 @@ public: static automaton::EpsilonNFA convert(const automaton::EpsilonNFA& automaton); static automaton::ExtendedNFA convert(const automaton::ExtendedNFA& automaton); static automaton::CompactNFA convert(const automaton::CompactNFA& automaton); - - static SingleInitialState& getInstance() { - static SingleInitialState res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/Total.cpp b/alib2algo/src/automaton/simplify/Total.cpp index f7b5c78b1c648ad49703556933708bd078c50877..aabf8779322630fe74ae7274816b362a87f2ceaa 100644 --- a/alib2algo/src/automaton/simplify/Total.cpp +++ b/alib2algo/src/automaton/simplify/Total.cpp @@ -17,7 +17,7 @@ namespace automaton { namespace simplify { automaton::Automaton Total::total(const Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } automaton::NFA Total::total(const automaton::NFA& automaton) { @@ -40,7 +40,7 @@ automaton::NFA Total::total(const automaton::NFA& automaton) { return res; } -auto TotalNFA = Total::RegistratorWrapper<automaton::NFA, automaton::NFA>(Total::getInstance(), Total::total); +auto TotalNFA = Total::RegistratorWrapper<automaton::NFA, automaton::NFA>(Total::total); automaton::DFA Total::total(const automaton::DFA& automaton) { automaton::DFA res(automaton); @@ -58,7 +58,7 @@ automaton::DFA Total::total(const automaton::DFA& automaton) { return res; } -auto TotalDFA = Total::RegistratorWrapper<automaton::DFA, automaton::DFA>(Total::getInstance(), Total::total); +auto TotalDFA = Total::RegistratorWrapper<automaton::DFA, automaton::DFA>(Total::total); } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/Total.h b/alib2algo/src/automaton/simplify/Total.h index 511429953b8f7bee2f58141eec5045b5d60b3758..09c10638beb3fe6181b49334b1acb2eafebe3981 100644 --- a/alib2algo/src/automaton/simplify/Total.h +++ b/alib2algo/src/automaton/simplify/Total.h @@ -19,7 +19,7 @@ namespace simplify { * Makes finite automaton's transition function total. * Source: Melichar: Algorithm 2.22 */ -class Total : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class Total : public std::SingleDispatch<Total, automaton::Automaton, automaton::AutomatonBase> { public: /** * Computes epsilon closure of a state in epsilon nonfree automaton @@ -28,11 +28,6 @@ public: static automaton::NFA total(const automaton::NFA& automaton); static automaton::DFA total(const automaton::DFA& automaton); - - static Total& getInstance() { - static Total res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/Trim.cpp b/alib2algo/src/automaton/simplify/Trim.cpp index ba36414d375b48c50ef6e4f86aa7db5507e81c87..b85413a56a3361d2ded78212746dfe0f4c144209 100644 --- a/alib2algo/src/automaton/simplify/Trim.cpp +++ b/alib2algo/src/automaton/simplify/Trim.cpp @@ -27,15 +27,15 @@ T Trim::trim( const T & fsm ) { return UnreachableStatesRemover::remove(UselessStatesRemover::remove(fsm)); } -auto TrimDFA = Trim::RegistratorWrapper<automaton::DFA, automaton::DFA>(Trim::getInstance(), Trim::trim); -auto TrimNFA = Trim::RegistratorWrapper<automaton::NFA, automaton::NFA>(Trim::getInstance(), Trim::trim); -auto TrimMultiInitialStateNFA = Trim::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(Trim::getInstance(), Trim::trim); -auto TrimEpsilonNFA = Trim::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(Trim::getInstance(), Trim::trim); -auto TrimCompactNFA = Trim::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(Trim::getInstance(), Trim::trim); -auto TrimExtendedNFA = Trim::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(Trim::getInstance(), Trim::trim); +auto TrimDFA = Trim::RegistratorWrapper<automaton::DFA, automaton::DFA>(Trim::trim); +auto TrimNFA = Trim::RegistratorWrapper<automaton::NFA, automaton::NFA>(Trim::trim); +auto TrimMultiInitialStateNFA = Trim::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(Trim::trim); +auto TrimEpsilonNFA = Trim::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(Trim::trim); +auto TrimCompactNFA = Trim::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(Trim::trim); +auto TrimExtendedNFA = Trim::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(Trim::trim); automaton::Automaton Trim::trim(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/Trim.h b/alib2algo/src/automaton/simplify/Trim.h index 2b1eb1c6ffe3682a3aff981e6332841c5c6f1588..2eaeea8c1e9c75eb3c0dfc232b2525e4f0e2904a 100644 --- a/alib2algo/src/automaton/simplify/Trim.h +++ b/alib2algo/src/automaton/simplify/Trim.h @@ -15,7 +15,7 @@ namespace automaton { namespace simplify { -class Trim : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class Trim : public std::SingleDispatch<Trim, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton trim( const automaton::Automaton & automaton ); @@ -24,11 +24,6 @@ public: */ template<class T> static T trim( const T & fsm ); - - static Trim& getInstance() { - static Trim res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.cpp b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.cpp index 4fca5e52eb5d7679690677e36dc33387292e5a3b..49a035dd4ce29dd6aeac5fd7ac555981c0296a54 100644 --- a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.cpp +++ b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.cpp @@ -50,10 +50,10 @@ T UnreachableStatesRemover::remove( const T & fsm ) { return M; } -auto UnreachableStatesRemoverEpsilonNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); -auto UnreachableStatesRemoverNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::NFA, automaton::NFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); -auto UnreachableStatesRemoverCompactNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); -auto UnreachableStatesRemoverExtendedNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverEpsilonNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::NFA, automaton::NFA>(UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverCompactNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverExtendedNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(UnreachableStatesRemover::remove); template<> automaton::DFA UnreachableStatesRemover::remove( const automaton::DFA & fsm ) { @@ -81,7 +81,7 @@ automaton::DFA UnreachableStatesRemover::remove( const automaton::DFA & fsm ) { return M; } -auto UnreachableStatesRemoverDFA = UnreachableStatesRemover::RegistratorWrapper<automaton::DFA, automaton::DFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverDFA = UnreachableStatesRemover::RegistratorWrapper<automaton::DFA, automaton::DFA>(UnreachableStatesRemover::remove); template<> automaton::MultiInitialStateNFA UnreachableStatesRemover::remove( const automaton::MultiInitialStateNFA & fsm ) { @@ -112,10 +112,10 @@ automaton::MultiInitialStateNFA UnreachableStatesRemover::remove( const automato return M; } -auto UnreachableStatesRemoverMultiInitialStateNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverMultiInitialStateNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(UnreachableStatesRemover::remove); automaton::Automaton UnreachableStatesRemover::remove(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h index c52051e1a194af2fc55809ee7e4934a58322b535..dc78ba8de0dd454f842904993704779cea1c8c8f 100644 --- a/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h +++ b/alib2algo/src/automaton/simplify/UnreachableStatesRemover.h @@ -15,7 +15,7 @@ namespace automaton { namespace simplify { -class UnreachableStatesRemover : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class UnreachableStatesRemover : public std::SingleDispatch<UnreachableStatesRemover, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton remove( const automaton::Automaton & automaton ); @@ -24,11 +24,6 @@ public: */ template<class T> static T remove( const T & automaton ); - - static UnreachableStatesRemover& getInstance() { - static UnreachableStatesRemover res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/UselessStatesRemover.cpp b/alib2algo/src/automaton/simplify/UselessStatesRemover.cpp index 5d84c921617bf48dd6b8b318351280b1c40221be..e99db1e03786e8e7295f9e4e2dd7ad33485eed88 100644 --- a/alib2algo/src/automaton/simplify/UselessStatesRemover.cpp +++ b/alib2algo/src/automaton/simplify/UselessStatesRemover.cpp @@ -50,10 +50,10 @@ T UselessStatesRemover::remove( const T & fsm ) { return M; } -auto UselessStatesRemoverEpsilonNFA = UselessStatesRemover::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); -auto UselessStatesRemoverNFA = UselessStatesRemover::RegistratorWrapper<automaton::NFA, automaton::NFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); -auto UselessStatesRemoverCompactNFA = UselessStatesRemover::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); -auto UselessStatesRemoverExtendedNFA = UselessStatesRemover::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); +auto UselessStatesRemoverEpsilonNFA = UselessStatesRemover::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(UselessStatesRemover::remove); +auto UselessStatesRemoverNFA = UselessStatesRemover::RegistratorWrapper<automaton::NFA, automaton::NFA>(UselessStatesRemover::remove); +auto UselessStatesRemoverCompactNFA = UselessStatesRemover::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(UselessStatesRemover::remove); +auto UselessStatesRemoverExtendedNFA = UselessStatesRemover::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(UselessStatesRemover::remove); template<> automaton::DFA UselessStatesRemover::remove( const automaton::DFA & fsm ) { @@ -83,7 +83,7 @@ automaton::DFA UselessStatesRemover::remove( const automaton::DFA & fsm ) { return M; } -auto UselessStatesRemoverDFA = UselessStatesRemover::RegistratorWrapper<automaton::DFA, automaton::DFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); +auto UselessStatesRemoverDFA = UselessStatesRemover::RegistratorWrapper<automaton::DFA, automaton::DFA>(UselessStatesRemover::remove); template<> automaton::MultiInitialStateNFA UselessStatesRemover::remove( const automaton::MultiInitialStateNFA & fsm ) { @@ -119,10 +119,10 @@ automaton::MultiInitialStateNFA UselessStatesRemover::remove( const automaton::M return M; } -auto UselessStatesRemoverMultiInitialStateNFA = UselessStatesRemover::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); +auto UselessStatesRemoverMultiInitialStateNFA = UselessStatesRemover::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(UselessStatesRemover::remove); automaton::Automaton UselessStatesRemover::remove(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/automaton/simplify/UselessStatesRemover.h b/alib2algo/src/automaton/simplify/UselessStatesRemover.h index 01a4ed1e1a8294705f91b0bfbfeb0dcdc7d475c1..0cc2febd78c01310a58162e1f3090d994f90a382 100644 --- a/alib2algo/src/automaton/simplify/UselessStatesRemover.h +++ b/alib2algo/src/automaton/simplify/UselessStatesRemover.h @@ -15,7 +15,7 @@ namespace automaton { namespace simplify { -class UselessStatesRemover : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class UselessStatesRemover : public std::SingleDispatch<UselessStatesRemover, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton remove( const automaton::Automaton & automaton ); @@ -24,11 +24,6 @@ public: */ template<class T> static T remove( const T & automaton ); - - static UselessStatesRemover& getInstance() { - static UselessStatesRemover res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/automaton/transform/AutomatonIteration.cpp b/alib2algo/src/automaton/transform/AutomatonIteration.cpp index 2bf1781156cc0416e22752dc6874b81b89bd629c..1db8c9ce1059f5696c7ab5926085315ca649f852 100644 --- a/alib2algo/src/automaton/transform/AutomatonIteration.cpp +++ b/alib2algo/src/automaton/transform/AutomatonIteration.cpp @@ -12,7 +12,7 @@ namespace automaton { namespace transform { automaton::Automaton AutomatonIteration::iteration(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } template<class T> @@ -27,8 +27,8 @@ automaton::NFA AutomatonIteration::iteration(const T& automaton) { return res; } -auto AutomatonIterationDFA = AutomatonIteration::RegistratorWrapper<automaton::NFA, automaton::DFA>(AutomatonIteration::getInstance(), AutomatonIteration::iteration); -auto AutomatonIterationNFA = AutomatonIteration::RegistratorWrapper<automaton::NFA, automaton::NFA>(AutomatonIteration::getInstance(), AutomatonIteration::iteration); +auto AutomatonIterationDFA = AutomatonIteration::RegistratorWrapper<automaton::NFA, automaton::DFA>(AutomatonIteration::iteration); +auto AutomatonIterationNFA = AutomatonIteration::RegistratorWrapper<automaton::NFA, automaton::NFA>(AutomatonIteration::iteration); } /* namespace transform */ diff --git a/alib2algo/src/automaton/transform/AutomatonIteration.h b/alib2algo/src/automaton/transform/AutomatonIteration.h index 47a09b9696541910aee39903d0a3054e7155470d..f5d2319e4f6452bea286f459169e766111714210 100644 --- a/alib2algo/src/automaton/transform/AutomatonIteration.h +++ b/alib2algo/src/automaton/transform/AutomatonIteration.h @@ -20,17 +20,12 @@ namespace transform { * Iterates language given by automaton * - For finite automaton A1, we create automaton L accepting L(A1)* */ -class AutomatonIteration : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class AutomatonIteration : public std::SingleDispatch<AutomatonIteration, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton iteration(const automaton::Automaton& automaton); template<class T> static automaton::NFA iteration(const T& automaton); - - static AutomatonIteration& getInstance() { - static AutomatonIteration res; - return res; - } }; } /* namespace transform */ diff --git a/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.cpp b/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.cpp index d4f47f3a31ef198b8e44d33d7be253175a0db07f..5688efff856024e5dbb4ee0ccec31e87f914e17f 100644 --- a/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.cpp +++ b/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.cpp @@ -12,7 +12,7 @@ namespace automaton { namespace transform { automaton::Automaton AutomatonIterationEpsilonTransition::iteration(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } template<class T> @@ -26,9 +26,9 @@ automaton::EpsilonNFA AutomatonIterationEpsilonTransition::iteration(const T& au return res; } -auto AutomatonIterationEpsilonTransitionDFA = AutomatonIterationEpsilonTransition::RegistratorWrapper<automaton::EpsilonNFA, automaton::DFA>(AutomatonIterationEpsilonTransition::getInstance(), AutomatonIterationEpsilonTransition::iteration); -auto AutomatonIterationEpsilonTransitionNFA = AutomatonIterationEpsilonTransition::RegistratorWrapper<automaton::EpsilonNFA, automaton::NFA>(AutomatonIterationEpsilonTransition::getInstance(), AutomatonIterationEpsilonTransition::iteration); -auto AutomatonIterationEpsilonTransitionEpsilonNFA = AutomatonIterationEpsilonTransition::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(AutomatonIterationEpsilonTransition::getInstance(), AutomatonIterationEpsilonTransition::iteration); +auto AutomatonIterationEpsilonTransitionDFA = AutomatonIterationEpsilonTransition::RegistratorWrapper<automaton::EpsilonNFA, automaton::DFA>(AutomatonIterationEpsilonTransition::iteration); +auto AutomatonIterationEpsilonTransitionNFA = AutomatonIterationEpsilonTransition::RegistratorWrapper<automaton::EpsilonNFA, automaton::NFA>(AutomatonIterationEpsilonTransition::iteration); +auto AutomatonIterationEpsilonTransitionEpsilonNFA = AutomatonIterationEpsilonTransition::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(AutomatonIterationEpsilonTransition::iteration); } /* namespace transform */ diff --git a/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h b/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h index 090c26de2745467b5cf7fa7a7d8b9d44ed9ecd8a..17d3b5c53ee662f958ac679e8b12a2b42169f81f 100644 --- a/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h +++ b/alib2algo/src/automaton/transform/AutomatonIterationEpsilonTransition.h @@ -20,17 +20,12 @@ namespace transform { * Iterates language given by automaton * - For finite automaton A1, we create automaton L accepting L(A1)* */ -class AutomatonIterationEpsilonTransition : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class AutomatonIterationEpsilonTransition : public std::SingleDispatch<AutomatonIterationEpsilonTransition, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton iteration(const automaton::Automaton& automaton); template<class T> static automaton::EpsilonNFA iteration(const T& automaton); - - static AutomatonIterationEpsilonTransition& getInstance() { - static AutomatonIterationEpsilonTransition res; - return res; - } }; } /* namespace transform */ diff --git a/alib2algo/src/automaton/transform/Compaction.cpp b/alib2algo/src/automaton/transform/Compaction.cpp index e0bbcda96ed17fee461dee11c66f22793f8e7954..bf3aefd374a247f7d63086db257329b86a59d25b 100644 --- a/alib2algo/src/automaton/transform/Compaction.cpp +++ b/alib2algo/src/automaton/transform/Compaction.cpp @@ -19,14 +19,14 @@ namespace automaton { namespace transform { automaton::Automaton Compaction::convert(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } automaton::CompactNFA Compaction::convert(const automaton::CompactNFA& automaton) { return automaton; } -auto CompactionCompactNFA = Compaction::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(Compaction::getInstance(), Compaction::convert); +auto CompactionCompactNFA = Compaction::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(Compaction::convert); automaton::CompactNFA Compaction::convert(const automaton::DFA& automaton) { automaton::CompactNFA res(automaton.getInitialState()); @@ -74,7 +74,7 @@ automaton::CompactNFA Compaction::convert(const automaton::DFA& automaton) { return res; } -auto CompactionDFA = Compaction::RegistratorWrapper<automaton::CompactNFA, automaton::DFA>(Compaction::getInstance(), Compaction::convert); +auto CompactionDFA = Compaction::RegistratorWrapper<automaton::CompactNFA, automaton::DFA>(Compaction::convert); automaton::CompactNFA Compaction::convert(const automaton::NFA& automaton) { automaton::CompactNFA res(automaton.getInitialState()); @@ -82,7 +82,7 @@ automaton::CompactNFA Compaction::convert(const automaton::NFA& automaton) { return res; } -auto CompactionNFA = Compaction::RegistratorWrapper<automaton::CompactNFA, automaton::NFA>(Compaction::getInstance(), Compaction::convert); +auto CompactionNFA = Compaction::RegistratorWrapper<automaton::CompactNFA, automaton::NFA>(Compaction::convert); } /* namespace transform */ diff --git a/alib2algo/src/automaton/transform/Compaction.h b/alib2algo/src/automaton/transform/Compaction.h index 51223fc2efecb2c5e1338eeb344ec2d3e5fadb9c..efdec5d97bdd1b76f86c5f323ae4d956a5f8c0bf 100644 --- a/alib2algo/src/automaton/transform/Compaction.h +++ b/alib2algo/src/automaton/transform/Compaction.h @@ -18,7 +18,7 @@ namespace transform { /** * Transforms FSM to CompactNFA */ -class Compaction : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class Compaction : public std::SingleDispatch<Compaction, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::CompactNFA convert( const automaton::DFA& automaton); static automaton::CompactNFA convert( const automaton::NFA& automaton); @@ -30,11 +30,6 @@ public: * @return CompactNFA equivalent to given automaton */ static automaton::Automaton convert( const automaton::Automaton & automaton ); - - static Compaction& getInstance() { - static Compaction res; - return res; - } }; } /* namespace transform */ diff --git a/alib2algo/src/automaton/transform/PDAToRHPDA.cpp b/alib2algo/src/automaton/transform/PDAToRHPDA.cpp index 1bfb64423821791d8b9088aeea3ae376c7ccce11..37ee089dba26ec4d9b6306110a500f2d1fea43bb 100644 --- a/alib2algo/src/automaton/transform/PDAToRHPDA.cpp +++ b/alib2algo/src/automaton/transform/PDAToRHPDA.cpp @@ -24,13 +24,13 @@ automaton::RealTimeHeightDeterministicDPDA PDAToRHPDA::convert ( const automaton return pda; } -auto PDAToRHPDARealTimeHeightDeterministicDPDA = PDAToRHPDA::RegistratorWrapper < automaton::RealTimeHeightDeterministicDPDA, automaton::RealTimeHeightDeterministicDPDA > ( PDAToRHPDA::getInstance ( ), PDAToRHPDA::convert ); +auto PDAToRHPDARealTimeHeightDeterministicDPDA = PDAToRHPDA::RegistratorWrapper < automaton::RealTimeHeightDeterministicDPDA, automaton::RealTimeHeightDeterministicDPDA > ( PDAToRHPDA::convert ); automaton::RealTimeHeightDeterministicNPDA PDAToRHPDA::convert ( const automaton::RealTimeHeightDeterministicNPDA & pda ) { return pda; } -auto PDAToRHPDARealTimeHeightDeterministicNPDA = PDAToRHPDA::RegistratorWrapper < automaton::RealTimeHeightDeterministicNPDA, automaton::RealTimeHeightDeterministicNPDA > ( PDAToRHPDA::getInstance ( ), PDAToRHPDA::convert ); +auto PDAToRHPDARealTimeHeightDeterministicNPDA = PDAToRHPDA::RegistratorWrapper < automaton::RealTimeHeightDeterministicNPDA, automaton::RealTimeHeightDeterministicNPDA > ( PDAToRHPDA::convert ); automaton::RealTimeHeightDeterministicDPDA PDAToRHPDA::convert ( const automaton::DPDA & pda ) { automaton::State q0 = automaton::createUniqueState ( automaton::State ( "q0" ), pda.getStates ( ) ); @@ -106,7 +106,7 @@ automaton::RealTimeHeightDeterministicDPDA PDAToRHPDA::convert ( const automaton return res; } -auto PDAToRHPDADPDA = PDAToRHPDA::RegistratorWrapper < automaton::RealTimeHeightDeterministicDPDA, automaton::DPDA > ( PDAToRHPDA::getInstance ( ), PDAToRHPDA::convert ); +auto PDAToRHPDADPDA = PDAToRHPDA::RegistratorWrapper < automaton::RealTimeHeightDeterministicDPDA, automaton::DPDA > ( PDAToRHPDA::convert ); automaton::RealTimeHeightDeterministicNPDA PDAToRHPDA::convert ( const automaton::NPDA & pda ) { RealTimeHeightDeterministicNPDA res ( alphabet::Symbol { alphabet::BottomOfTheStackSymbol::BOTTOM_OF_THE_STACK } ); @@ -180,10 +180,10 @@ automaton::RealTimeHeightDeterministicNPDA PDAToRHPDA::convert ( const automaton return res; } -auto PDAToRHPDANPDA = PDAToRHPDA::RegistratorWrapper < automaton::RealTimeHeightDeterministicNPDA, automaton::NPDA > ( PDAToRHPDA::getInstance ( ), PDAToRHPDA::convert ); +auto PDAToRHPDANPDA = PDAToRHPDA::RegistratorWrapper < automaton::RealTimeHeightDeterministicNPDA, automaton::NPDA > ( PDAToRHPDA::convert ); automaton::Automaton PDAToRHPDA::convert ( const Automaton & automaton ) { - return getInstance ( ).dispatch ( automaton.getData ( ) ); + return dispatch ( automaton.getData ( ) ); } } diff --git a/alib2algo/src/automaton/transform/PDAToRHPDA.h b/alib2algo/src/automaton/transform/PDAToRHPDA.h index 0ba4c202ff6ec8ae4a38d39ffc2de7291ec3f037..2943c78c76c83ead52b8c072317c9374516175f7 100644 --- a/alib2algo/src/automaton/transform/PDAToRHPDA.h +++ b/alib2algo/src/automaton/transform/PDAToRHPDA.h @@ -18,7 +18,7 @@ namespace automaton { -class PDAToRHPDA : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class PDAToRHPDA : public std::SingleDispatch<PDAToRHPDA, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::RealTimeHeightDeterministicDPDA convert( const automaton::RealTimeHeightDeterministicDPDA & pda); static automaton::RealTimeHeightDeterministicDPDA convert( const automaton::DPDA & pda); @@ -29,11 +29,6 @@ public: * Computes epsilon closure of a state in epsilon nonfree automaton */ static automaton::Automaton convert( const automaton::Automaton & automaton ); - - static PDAToRHPDA& getInstance() { - static PDAToRHPDA res; - return res; - } }; } diff --git a/alib2algo/src/automaton/transform/RHPDAToPDA.cpp b/alib2algo/src/automaton/transform/RHPDAToPDA.cpp index cffd62e1c682b8d2272a5a39b29f62465853bdee..2ed51df4622c9992e8e6b4bb7058d966e81c21f3 100644 --- a/alib2algo/src/automaton/transform/RHPDAToPDA.cpp +++ b/alib2algo/src/automaton/transform/RHPDAToPDA.cpp @@ -153,7 +153,7 @@ automaton::DPDA RHPDAToPDA::convert ( const automaton::RealTimeHeightDeterminist return res; } -auto RHPDAToPDARealTimeHeightDeterministicDPDA = RHPDAToPDA::RegistratorWrapper < automaton::DPDA, automaton::RealTimeHeightDeterministicDPDA > ( RHPDAToPDA::getInstance ( ), RHPDAToPDA::convert ); +auto RHPDAToPDARealTimeHeightDeterministicDPDA = RHPDAToPDA::RegistratorWrapper < automaton::DPDA, automaton::RealTimeHeightDeterministicDPDA > ( RHPDAToPDA::convert ); // This may not work correctly -- generation of initial state and initial symbol automaton::NPDA RHPDAToPDA::convert ( const automaton::RealTimeHeightDeterministicNPDA & pda ) { @@ -269,10 +269,10 @@ automaton::NPDA RHPDAToPDA::convert ( const automaton::RealTimeHeightDeterminist return res; } -auto RHPDAToPDARealTimeHeightDeterministicNPDA = RHPDAToPDA::RegistratorWrapper < automaton::NPDA, automaton::RealTimeHeightDeterministicNPDA > ( RHPDAToPDA::getInstance ( ), RHPDAToPDA::convert ); +auto RHPDAToPDARealTimeHeightDeterministicNPDA = RHPDAToPDA::RegistratorWrapper < automaton::NPDA, automaton::RealTimeHeightDeterministicNPDA > ( RHPDAToPDA::convert ); automaton::Automaton RHPDAToPDA::convert ( const Automaton & automaton ) { - return getInstance ( ).dispatch ( automaton.getData ( ) ); + return dispatch ( automaton.getData ( ) ); } } diff --git a/alib2algo/src/automaton/transform/RHPDAToPDA.h b/alib2algo/src/automaton/transform/RHPDAToPDA.h index f785402fcbe38b6fc5852d15ee9624f3a0f8047c..42919f537fac0ce9d2906ce80da3c5a2bc3840d6 100644 --- a/alib2algo/src/automaton/transform/RHPDAToPDA.h +++ b/alib2algo/src/automaton/transform/RHPDAToPDA.h @@ -18,7 +18,7 @@ namespace automaton { -class RHPDAToPDA : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class RHPDAToPDA : public std::SingleDispatch<RHPDAToPDA, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::DPDA convert( const automaton::RealTimeHeightDeterministicDPDA & pda); static automaton::DPDA convert( const automaton::DPDA & pda); @@ -29,11 +29,6 @@ public: * Computes epsilon closure of a state in epsilon nonfree automaton */ static automaton::Automaton convert( const automaton::Automaton & automaton ); - - static RHPDAToPDA& getInstance() { - static RHPDAToPDA res; - return res; - } }; } diff --git a/alib2algo/src/automaton/transform/Reverse.cpp b/alib2algo/src/automaton/transform/Reverse.cpp index 8c76b74ceb07b5c0b010601c27b3eb458d0c30ed..8d3e836bd984e9b0da36da73b76ab6d5666591e1 100644 --- a/alib2algo/src/automaton/transform/Reverse.cpp +++ b/alib2algo/src/automaton/transform/Reverse.cpp @@ -17,7 +17,7 @@ namespace automaton { namespace transform { automaton::Automaton Reverse::convert(const Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } automaton::MultiInitialStateNFA Reverse::convert(const automaton::DFA& automaton) { @@ -34,7 +34,7 @@ automaton::MultiInitialStateNFA Reverse::convert(const automaton::DFA& automaton return res; } -auto ReverseDFA = Reverse::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::DFA>(Reverse::getInstance(), Reverse::convert); +auto ReverseDFA = Reverse::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::DFA>(Reverse::convert); automaton::MultiInitialStateNFA Reverse::convert(const automaton::NFA& automaton) { automaton::MultiInitialStateNFA res; @@ -51,7 +51,7 @@ automaton::MultiInitialStateNFA Reverse::convert(const automaton::NFA& automaton return res; } -auto ReverseNFA = Reverse::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::NFA>(Reverse::getInstance(), Reverse::convert); +auto ReverseNFA = Reverse::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::NFA>(Reverse::convert); automaton::MultiInitialStateNFA Reverse::convert(const automaton::MultiInitialStateNFA& automaton) { automaton::MultiInitialStateNFA res; @@ -68,7 +68,7 @@ automaton::MultiInitialStateNFA Reverse::convert(const automaton::MultiInitialSt return res; } -auto ReverseMultiInitialStateNFA = Reverse::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(Reverse::getInstance(), Reverse::convert); +auto ReverseMultiInitialStateNFA = Reverse::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(Reverse::convert); } /* namespace transform */ diff --git a/alib2algo/src/automaton/transform/Reverse.h b/alib2algo/src/automaton/transform/Reverse.h index a53b1027e3c8d00bd1da55092617a1f15d841f0d..ce4a8970efbd92535999fe681ddbbfd5b562a0de 100644 --- a/alib2algo/src/automaton/transform/Reverse.h +++ b/alib2algo/src/automaton/transform/Reverse.h @@ -16,7 +16,7 @@ namespace automaton { namespace transform { -class Reverse : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class Reverse : public std::SingleDispatch<Reverse, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::MultiInitialStateNFA convert(const automaton::DFA& automaton); static automaton::MultiInitialStateNFA convert(const automaton::NFA& automaton); @@ -28,11 +28,6 @@ public: * @return Automaton reverse automaton */ static automaton::Automaton convert( const automaton::Automaton & automaton ); - - static Reverse& getInstance() { - static Reverse res; - return res; - } }; } /* namespace transform */ diff --git a/alib2algo/src/grammar/convert/ToAutomaton.cpp b/alib2algo/src/grammar/convert/ToAutomaton.cpp index 4b0d7e0828a2d9fc31a70320d870a1964ba7da45..bb80a1e0ec1db7b209ef2ccf009680283ae33183 100644 --- a/alib2algo/src/grammar/convert/ToAutomaton.cpp +++ b/alib2algo/src/grammar/convert/ToAutomaton.cpp @@ -13,7 +13,7 @@ namespace grammar { namespace convert { automaton::Automaton ToAutomaton::convert(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } automaton::NFA ToAutomaton::convert(const grammar::LeftRG& grammar) { @@ -57,7 +57,7 @@ automaton::NFA ToAutomaton::convert(const grammar::LeftRG& grammar) { return automaton; } -auto ToAutomatonLeftRG = ToAutomaton::RegistratorWrapper<automaton::NFA, grammar::LeftRG>(ToAutomaton::getInstance(), ToAutomaton::convert); +auto ToAutomatonLeftRG = ToAutomaton::RegistratorWrapper<automaton::NFA, grammar::LeftRG>(ToAutomaton::convert); automaton::NFA ToAutomaton::convert(const grammar::RightRG& grammar) { std::map<alphabet::Symbol, automaton::State> stateMap; @@ -101,7 +101,7 @@ automaton::NFA ToAutomaton::convert(const grammar::RightRG& grammar) { return automaton; } -auto ToAutomatonRightRG = ToAutomaton::RegistratorWrapper<automaton::NFA, grammar::RightRG>(ToAutomaton::getInstance(), ToAutomaton::convert); +auto ToAutomatonRightRG = ToAutomaton::RegistratorWrapper<automaton::NFA, grammar::RightRG>(ToAutomaton::convert); template <class T> automaton::NPDA ToAutomaton::convert(const T& grammar) { @@ -124,8 +124,8 @@ automaton::NPDA ToAutomaton::convert(const T& grammar) { return automaton; } -auto ToAutomatonCFG = ToAutomaton::RegistratorWrapper<automaton::NPDA, grammar::CFG>(ToAutomaton::getInstance(), ToAutomaton::convert); -auto ToAutomatonEpsilonFreeCFG = ToAutomaton::RegistratorWrapper<automaton::NPDA, grammar::EpsilonFreeCFG>(ToAutomaton::getInstance(), ToAutomaton::convert); +auto ToAutomatonCFG = ToAutomaton::RegistratorWrapper<automaton::NPDA, grammar::CFG>(ToAutomaton::convert); +auto ToAutomatonEpsilonFreeCFG = ToAutomaton::RegistratorWrapper<automaton::NPDA, grammar::EpsilonFreeCFG>(ToAutomaton::convert); } /* namespace convert */ diff --git a/alib2algo/src/grammar/convert/ToAutomaton.h b/alib2algo/src/grammar/convert/ToAutomaton.h index 8c758077a098de96b1fa22314708fb333262a29d..02bf64047f3f847ed51a06702d5bc48ef909a394 100644 --- a/alib2algo/src/grammar/convert/ToAutomaton.h +++ b/alib2algo/src/grammar/convert/ToAutomaton.h @@ -28,7 +28,7 @@ namespace convert { * Converts regular grammar to nondeterministic finite automaton. * Sources: Melichar 2.98 (RightRG -> NFA) and 2.102 (LeftRG -> NFA). */ -class ToAutomaton : public std::SingleDispatch<automaton::Automaton, grammar::GrammarBase> { +class ToAutomaton : public std::SingleDispatch<ToAutomaton, automaton::Automaton, grammar::GrammarBase> { public: /** * Performs conversion. @@ -42,11 +42,6 @@ public: template <class T> static automaton::NPDA convert(const T& grammar); - - static ToAutomaton& getInstance() { - static ToAutomaton res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/grammar/convert/ToAutomatonBottomUp.cpp b/alib2algo/src/grammar/convert/ToAutomatonBottomUp.cpp index eb35eb9f5684d2557eae51bf3a23116dd68646de..f118086eae137b69bbcbd91ad1bafdae21e9de1f 100644 --- a/alib2algo/src/grammar/convert/ToAutomatonBottomUp.cpp +++ b/alib2algo/src/grammar/convert/ToAutomatonBottomUp.cpp @@ -14,7 +14,7 @@ namespace grammar { namespace convert { automaton::Automaton ToAutomatonBottomUp::convert(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } template <class T> @@ -46,8 +46,8 @@ automaton::NPDA ToAutomatonBottomUp::convert(const T& grammar) { return automaton; } -auto ToAutomatonBottomUpCFG = ToAutomatonBottomUp::RegistratorWrapper<automaton::NPDA, grammar::CFG>(ToAutomatonBottomUp::getInstance(), ToAutomatonBottomUp::convert); -auto ToAutomatonBottomUpEpsilonFreeCFG = ToAutomatonBottomUp::RegistratorWrapper<automaton::NPDA, grammar::EpsilonFreeCFG>(ToAutomatonBottomUp::getInstance(), ToAutomatonBottomUp::convert); +auto ToAutomatonBottomUpCFG = ToAutomatonBottomUp::RegistratorWrapper<automaton::NPDA, grammar::CFG>(ToAutomatonBottomUp::convert); +auto ToAutomatonBottomUpEpsilonFreeCFG = ToAutomatonBottomUp::RegistratorWrapper<automaton::NPDA, grammar::EpsilonFreeCFG>(ToAutomatonBottomUp::convert); } /* namespace convert */ diff --git a/alib2algo/src/grammar/convert/ToAutomatonBottomUp.h b/alib2algo/src/grammar/convert/ToAutomatonBottomUp.h index 740bdd86729107ab38bf2961a87a34f0ccdaff03..82fae9553ae78596d32b1cffccb1321a06bf0c55 100644 --- a/alib2algo/src/grammar/convert/ToAutomatonBottomUp.h +++ b/alib2algo/src/grammar/convert/ToAutomatonBottomUp.h @@ -23,7 +23,7 @@ namespace convert { /** */ -class ToAutomatonBottomUp : public std::SingleDispatch<automaton::Automaton, grammar::GrammarBase> { +class ToAutomatonBottomUp : public std::SingleDispatch<ToAutomatonBottomUp, automaton::Automaton, grammar::GrammarBase> { public: /** * Performs conversion. @@ -32,11 +32,6 @@ public: template <class T> static automaton::NPDA convert(const T& grammar); - - static ToAutomatonBottomUp& getInstance() { - static ToAutomatonBottomUp res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/grammar/convert/ToGrammarLeftRG.cpp b/alib2algo/src/grammar/convert/ToGrammarLeftRG.cpp index e62069acab88023f5747538769ebf2ae2cddd1aa..147dca8d073ec68ed9bdb39e5da7c40ab7ddce42 100644 --- a/alib2algo/src/grammar/convert/ToGrammarLeftRG.cpp +++ b/alib2algo/src/grammar/convert/ToGrammarLeftRG.cpp @@ -12,7 +12,7 @@ namespace grammar { namespace convert { grammar::LeftRG ToGrammarLeftRG::convert(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } grammar::LeftRG ToGrammarLeftRG::convert(const grammar::RightRG& grammar) { @@ -63,7 +63,7 @@ grammar::LeftRG ToGrammarLeftRG::convert(const grammar::RightRG& grammar) { return lrg; } -auto ToGrammarLeftRGRightRG = ToGrammarLeftRG::RegistratorWrapper<grammar::LeftRG, grammar::RightRG>(ToGrammarLeftRG::getInstance(), ToGrammarLeftRG::convert); +auto ToGrammarLeftRGRightRG = ToGrammarLeftRG::RegistratorWrapper<grammar::LeftRG, grammar::RightRG>(ToGrammarLeftRG::convert); } /* namespace convert */ diff --git a/alib2algo/src/grammar/convert/ToGrammarLeftRG.h b/alib2algo/src/grammar/convert/ToGrammarLeftRG.h index cc10f6b7e5a79786ffcb52ed156e4057fd8a57c0..429e06db6de95a703cdfc04414317027afd1e5a6 100644 --- a/alib2algo/src/grammar/convert/ToGrammarLeftRG.h +++ b/alib2algo/src/grammar/convert/ToGrammarLeftRG.h @@ -21,7 +21,7 @@ namespace convert { /** * Converts right regular grammar to left regular grammar. */ -class ToGrammarLeftRG : public std::SingleDispatch<grammar::LeftRG, grammar::GrammarBase> { +class ToGrammarLeftRG : public std::SingleDispatch<ToGrammarLeftRG, grammar::LeftRG, grammar::GrammarBase> { public: /** * Performs conversion. @@ -30,11 +30,6 @@ public: */ static grammar::LeftRG convert(const grammar::Grammar& grammar); static grammar::LeftRG convert(const grammar::RightRG& grammar); - - static ToGrammarLeftRG& getInstance() { - static ToGrammarLeftRG res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/grammar/convert/ToGrammarRightRG.cpp b/alib2algo/src/grammar/convert/ToGrammarRightRG.cpp index 8967e5f2f387b2a70fb3853c65c9ede3cf0f6641..a6f7ad1c009744549201f9c9c029ba25c4cf919c 100644 --- a/alib2algo/src/grammar/convert/ToGrammarRightRG.cpp +++ b/alib2algo/src/grammar/convert/ToGrammarRightRG.cpp @@ -12,7 +12,7 @@ namespace grammar { namespace convert { grammar::RightRG ToGrammarRightRG::convert(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } grammar::RightRG ToGrammarRightRG::convert(const grammar::LeftRG& grammar) { @@ -63,7 +63,7 @@ grammar::RightRG ToGrammarRightRG::convert(const grammar::LeftRG& grammar) { return rrg; } -auto ToGrammarRightRGLeftRG = ToGrammarRightRG::RegistratorWrapper<grammar::RightRG, grammar::LeftRG>(ToGrammarRightRG::getInstance(), ToGrammarRightRG::convert); +auto ToGrammarRightRGLeftRG = ToGrammarRightRG::RegistratorWrapper<grammar::RightRG, grammar::LeftRG>(ToGrammarRightRG::convert); } /* namespace convert */ diff --git a/alib2algo/src/grammar/convert/ToGrammarRightRG.h b/alib2algo/src/grammar/convert/ToGrammarRightRG.h index 9cf1098bd7f535ec25a687654131c2a7331e6235..dd96c13b8eff3f10026fe1f0e2900f70756b5075 100644 --- a/alib2algo/src/grammar/convert/ToGrammarRightRG.h +++ b/alib2algo/src/grammar/convert/ToGrammarRightRG.h @@ -21,7 +21,7 @@ namespace convert { /** * Converts left regular grammar to right regular grammar. */ -class ToGrammarRightRG : public std::SingleDispatch<grammar::RightRG, grammar::GrammarBase> { +class ToGrammarRightRG : public std::SingleDispatch<ToGrammarRightRG, grammar::RightRG, grammar::GrammarBase> { public: /** * Performs conversion. @@ -30,11 +30,6 @@ public: */ static grammar::RightRG convert(const grammar::Grammar& grammar); static grammar::RightRG convert(const grammar::LeftRG& grammar); - - static ToGrammarRightRG& getInstance() { - static ToGrammarRightRG res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/grammar/convert/ToRegExp.cpp b/alib2algo/src/grammar/convert/ToRegExp.cpp index 0a09fb53182505e1e675824d935a5f78d434d700..83d942aa8d4a23c6cf87dde2c321b7f3988f9f25 100644 --- a/alib2algo/src/grammar/convert/ToRegExp.cpp +++ b/alib2algo/src/grammar/convert/ToRegExp.cpp @@ -13,20 +13,20 @@ namespace grammar { namespace convert { regexp::RegExp ToRegExp::convert(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } regexp::RegExp ToRegExp::convert(const grammar::RightRG& grammar) { return regexp::RegExp(ToRegExpAlgebraic::convert(grammar)); } -auto ToRegExpRightRG = ToRegExp::RegistratorWrapper<regexp::RegExp, grammar::RightRG>(ToRegExp::getInstance(), ToRegExp::convert); +auto ToRegExpRightRG = ToRegExp::RegistratorWrapper<regexp::RegExp, grammar::RightRG>(ToRegExp::convert); regexp::RegExp ToRegExp::convert(const grammar::LeftRG& grammar) { return regexp::RegExp(ToRegExpAlgebraic::convert(grammar)); } -auto ToRegExpLeftRG = ToRegExp::RegistratorWrapper<regexp::RegExp, grammar::LeftRG>(ToRegExp::getInstance(), ToRegExp::convert); +auto ToRegExpLeftRG = ToRegExp::RegistratorWrapper<regexp::RegExp, grammar::LeftRG>(ToRegExp::convert); } /* namespace convert */ diff --git a/alib2algo/src/grammar/convert/ToRegExp.h b/alib2algo/src/grammar/convert/ToRegExp.h index e8bb4406b7508d4443f7ac4b6ba2bced7fd7c61d..8fd29781d778f3b02ca8cc18f2c69c0488be3d8a 100644 --- a/alib2algo/src/grammar/convert/ToRegExp.h +++ b/alib2algo/src/grammar/convert/ToRegExp.h @@ -20,7 +20,7 @@ namespace grammar { namespace convert { -class ToRegExp : public std::SingleDispatch<regexp::RegExp, grammar::GrammarBase> { +class ToRegExp : public std::SingleDispatch<ToRegExp, regexp::RegExp, grammar::GrammarBase> { public: /** * @return regexp equivalent to source right regular grammar. @@ -30,11 +30,6 @@ public: static regexp::RegExp convert(const grammar::RightRG& grammar); static regexp::RegExp convert(const grammar::LeftRG& grammar); - - static ToRegExp& getInstance() { - static ToRegExp res; - return res; - } }; } /* namespace covert */ diff --git a/alib2algo/src/grammar/convert/ToRegExpAlgebraic.cpp b/alib2algo/src/grammar/convert/ToRegExpAlgebraic.cpp index bfc555a63a5bc6bcab5e3d95b326854b130e03cc..5beee122411c8ae34a6a6fe467dccde74639e02e 100644 --- a/alib2algo/src/grammar/convert/ToRegExpAlgebraic.cpp +++ b/alib2algo/src/grammar/convert/ToRegExpAlgebraic.cpp @@ -18,7 +18,7 @@ namespace grammar { namespace convert { regexp::RegExp ToRegExpAlgebraic::convert(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } regexp::RegExp ToRegExpAlgebraic::convert(const grammar::LeftRG& grammar) { @@ -46,7 +46,7 @@ regexp::RegExp ToRegExpAlgebraic::convert(const grammar::LeftRG& grammar) { return regexp::RegExp{solver.solve(grammar.getInitialSymbol())}; } -auto ToRegExpAlgebraicLeftRG = ToRegExpAlgebraic::RegistratorWrapper<regexp::RegExp, grammar::LeftRG>(ToRegExpAlgebraic::getInstance(), ToRegExpAlgebraic::convert); +auto ToRegExpAlgebraicLeftRG = ToRegExpAlgebraic::RegistratorWrapper<regexp::RegExp, grammar::LeftRG>(ToRegExpAlgebraic::convert); regexp::RegExp ToRegExpAlgebraic::convert(const grammar::RightRG& grammar) { equations::RightRegularEquationSolver solver; @@ -73,7 +73,7 @@ regexp::RegExp ToRegExpAlgebraic::convert(const grammar::RightRG& grammar) { return regexp::RegExp{solver.solve(grammar.getInitialSymbol())}; } -auto ToRegExpAlgebraicRightRG = ToRegExpAlgebraic::RegistratorWrapper<regexp::RegExp, grammar::RightRG>(ToRegExpAlgebraic::getInstance(), ToRegExpAlgebraic::convert); +auto ToRegExpAlgebraicRightRG = ToRegExpAlgebraic::RegistratorWrapper<regexp::RegExp, grammar::RightRG>(ToRegExpAlgebraic::convert); } /* namespace convert */ diff --git a/alib2algo/src/grammar/convert/ToRegExpAlgebraic.h b/alib2algo/src/grammar/convert/ToRegExpAlgebraic.h index eeb66867e98c1781ff59fec2b2f94eda807b968e..4ada4c0ac2b466c59c5710dc03d7d60d8e07312a 100644 --- a/alib2algo/src/grammar/convert/ToRegExpAlgebraic.h +++ b/alib2algo/src/grammar/convert/ToRegExpAlgebraic.h @@ -20,7 +20,7 @@ namespace grammar { namespace convert { -class ToRegExpAlgebraic : public std::SingleDispatch<regexp::RegExp, grammar::GrammarBase> { +class ToRegExpAlgebraic : public std::SingleDispatch<ToRegExpAlgebraic, regexp::RegExp, grammar::GrammarBase> { public: /** * @return regexp equivalent to source right regular grammar. @@ -30,11 +30,6 @@ public: static regexp::RegExp convert(const grammar::RightRG& grammar); static regexp::RegExp convert(const grammar::LeftRG& grammar); - - static ToRegExpAlgebraic& getInstance() { - static ToRegExpAlgebraic res; - return res; - } }; } /* namespace covert */ diff --git a/alib2algo/src/grammar/generate/CockeYoungerKasami.cpp b/alib2algo/src/grammar/generate/CockeYoungerKasami.cpp index 8dc452f077b6eb9768a63e853111913f360a01ff..653c54274320c4271111133ed329ea648ab6bf1c 100644 --- a/alib2algo/src/grammar/generate/CockeYoungerKasami.cpp +++ b/alib2algo/src/grammar/generate/CockeYoungerKasami.cpp @@ -76,10 +76,10 @@ bool CockeYoungerKasami::generate ( const grammar::CNF & grammar, const string:: return data[stringSize - 1][0].count ( grammar.getInitialSymbol ( ) ); } -auto CockeYoungerKasamiCNF = CockeYoungerKasami::RegistratorWrapper < bool, grammar::CNF > ( CockeYoungerKasami::getInstance ( ), CockeYoungerKasami::generate ); +auto CockeYoungerKasamiCNF = CockeYoungerKasami::RegistratorWrapper < bool, grammar::CNF > ( CockeYoungerKasami::generate ); bool CockeYoungerKasami::generate ( const grammar::Grammar & grammar, const string::LinearString & string ) { - return getInstance ( ).dispatch ( grammar.getData ( ), string ); + return dispatch ( grammar.getData ( ), string ); } } /* namespace generate */ diff --git a/alib2algo/src/grammar/generate/CockeYoungerKasami.h b/alib2algo/src/grammar/generate/CockeYoungerKasami.h index 56b494660061f68bd0e0fc86799cdcb0e298c50f..f2a4086f288b3790e2e6dfcefa7c98d36537f80d 100644 --- a/alib2algo/src/grammar/generate/CockeYoungerKasami.h +++ b/alib2algo/src/grammar/generate/CockeYoungerKasami.h @@ -21,18 +21,12 @@ namespace generate { /** * Implements algorithms from Melichar, chapter 3.3 */ -class CockeYoungerKasami : public std::SingleDispatchLastStaticParam < bool, grammar::GrammarBase, const string::LinearString & > { +class CockeYoungerKasami : public std::SingleDispatchLastStaticParam < CockeYoungerKasami, bool, grammar::GrammarBase, const string::LinearString & > { public: static bool generate ( const grammar::Grammar & grammar, const string::LinearString & string ); static bool generate ( const grammar::CNF & grammar, const string::LinearString & string ); - static CockeYoungerKasami & getInstance ( ) { - static CockeYoungerKasami res; - - return res; - } - }; } /* namespace generate */ diff --git a/alib2algo/src/grammar/generate/GenerateUpToLength.cpp b/alib2algo/src/grammar/generate/GenerateUpToLength.cpp index 221495bb93b428445aab114ce0cc6164c5c85c27..b115a89c8a177eee931b46a80407c62e7dc4a373 100644 --- a/alib2algo/src/grammar/generate/GenerateUpToLength.cpp +++ b/alib2algo/src/grammar/generate/GenerateUpToLength.cpp @@ -61,14 +61,14 @@ std::set<string::LinearString> GenerateUpToLength::generate( const T & grammar, return res; } -auto GenerateUpToLengthEpsilonFreeCFG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::EpsilonFreeCFG>(GenerateUpToLength::getInstance(), GenerateUpToLength::generate); -auto GenerateUpToLengthGNF = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::GNF>(GenerateUpToLength::getInstance(), GenerateUpToLength::generate); -auto GenerateUpToLengthCNF = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::CNF>(GenerateUpToLength::getInstance(), GenerateUpToLength::generate); -auto GenerateUpToLengthLeftRG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::LeftRG>(GenerateUpToLength::getInstance(), GenerateUpToLength::generate); -auto GenerateUpToLengthRightRG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::RightRG>(GenerateUpToLength::getInstance(), GenerateUpToLength::generate); +auto GenerateUpToLengthEpsilonFreeCFG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::EpsilonFreeCFG>(GenerateUpToLength::generate); +auto GenerateUpToLengthGNF = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::GNF>(GenerateUpToLength::generate); +auto GenerateUpToLengthCNF = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::CNF>(GenerateUpToLength::generate); +auto GenerateUpToLengthLeftRG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::LeftRG>(GenerateUpToLength::generate); +auto GenerateUpToLengthRightRG = GenerateUpToLength::RegistratorWrapper<std::set<string::LinearString>, grammar::RightRG>(GenerateUpToLength::generate); std::set<string::LinearString> GenerateUpToLength::generate(const grammar::Grammar& grammar, unsigned length) { - return getInstance().dispatch(grammar.getData(), length); + return dispatch(grammar.getData(), length); } } /* namespace generate */ diff --git a/alib2algo/src/grammar/generate/GenerateUpToLength.h b/alib2algo/src/grammar/generate/GenerateUpToLength.h index 50e2e5a4de0d61f8c2f2fe128346287cd01435b3..afc67f0b30424901019507479631150a385e54ec 100644 --- a/alib2algo/src/grammar/generate/GenerateUpToLength.h +++ b/alib2algo/src/grammar/generate/GenerateUpToLength.h @@ -21,17 +21,12 @@ namespace generate { /** * Implements algorithms from Melichar, chapter 3.3 */ -class GenerateUpToLength : public std::SingleDispatchLastStaticParam<std::set<string::LinearString>, grammar::GrammarBase, unsigned> { +class GenerateUpToLength : public std::SingleDispatchLastStaticParam<GenerateUpToLength, std::set<string::LinearString>, grammar::GrammarBase, unsigned> { public: static std::set<string::LinearString> generate( const grammar::Grammar & grammar, unsigned length ); template<class T> static std::set<string::LinearString> generate( const T & grammar, unsigned length ); - - static GenerateUpToLength& getInstance() { - static GenerateUpToLength res; - return res; - } }; } /* namespace generate */ diff --git a/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.cpp b/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.cpp index 10dc776a801fe049e19d4f776856d3cc1a888463..e0465e48fa0eb1981a6289e52796ab02070a805c 100644 --- a/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.cpp +++ b/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.cpp @@ -79,10 +79,10 @@ grammar::CFG DeterministicLL1Grammar::convert ( const grammar::CFG & param ) { } } -auto DeterministicLL1GrammarCFG = DeterministicLL1Grammar::RegistratorWrapper < grammar::CFG, grammar::CFG > ( DeterministicLL1Grammar::getInstance ( ), DeterministicLL1Grammar::convert ); +auto DeterministicLL1GrammarCFG = DeterministicLL1Grammar::RegistratorWrapper < grammar::CFG, grammar::CFG > ( DeterministicLL1Grammar::convert ); grammar::Grammar DeterministicLL1Grammar::convert ( const grammar::Grammar & grammar ) { - return getInstance ( ).dispatch ( grammar.getData ( ) ); + return dispatch ( grammar.getData ( ) ); } } /* namespace parsing */ diff --git a/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.h b/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.h index 7c45b19fd7caaeed2ac4c7d360ddd3fa3df5309f..72a1d8b3fd109af549ef531cdd1dd2d9b14bb151 100644 --- a/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.h +++ b/alib2algo/src/grammar/parsing/DeterministicLL1Grammar.h @@ -16,18 +16,12 @@ namespace grammar { namespace parsing { -class DeterministicLL1Grammar : public std::SingleDispatch < grammar::Grammar, grammar::GrammarBase > { +class DeterministicLL1Grammar : public std::SingleDispatch < DeterministicLL1Grammar, grammar::Grammar, grammar::GrammarBase > { public: static grammar::CFG convert ( const grammar::CFG & grammar ); static grammar::Grammar convert ( const grammar::Grammar & grammar ); - static DeterministicLL1Grammar & getInstance ( ) { - static DeterministicLL1Grammar res; - - return res; - } - }; } /* namespace parsing */ diff --git a/alib2algo/src/grammar/parsing/First.cpp b/alib2algo/src/grammar/parsing/First.cpp index a90b39931c04c28f1528bfba8692c7390d64ca5b..db0071cd5608ed17ec67ddc41edca803e524613f 100644 --- a/alib2algo/src/grammar/parsing/First.cpp +++ b/alib2algo/src/grammar/parsing/First.cpp @@ -104,32 +104,32 @@ std::set < std::variant < alphabet::Symbol, string::Epsilon > > First::first ( c return first ( grammar.getTerminalAlphabet ( ), grammar.getNonterminalAlphabet ( ), firstNt, rhs ); } -auto FirstCFG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::CFG > ( First::getInstance1 ( ), First::first ); -auto FirstEpsilonFreeCFG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::EpsilonFreeCFG > ( First::getInstance1 ( ), First::first ); -auto FirstGNF = FirstBase1::RegistratorWrapper < FirstResult1, grammar::GNF > ( First::getInstance1 ( ), First::first ); -auto FirstCNF = FirstBase1::RegistratorWrapper < FirstResult1, grammar::CNF > ( First::getInstance1 ( ), First::first ); -auto FirstLG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::LG > ( First::getInstance1 ( ), First::first ); -auto FirstLeftLG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::LeftLG > ( First::getInstance1 ( ), First::first ); -auto FirstLeftRG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::LeftRG > ( First::getInstance1 ( ), First::first ); -auto FirstRightLG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::RightLG > ( First::getInstance1 ( ), First::first ); -auto FirstRightRG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::RightRG > ( First::getInstance1 ( ), First::first ); +auto FirstCFG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::CFG > ( First::first ); +auto FirstEpsilonFreeCFG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::EpsilonFreeCFG > ( First::first ); +auto FirstGNF = FirstBase1::RegistratorWrapper < FirstResult1, grammar::GNF > ( First::first ); +auto FirstCNF = FirstBase1::RegistratorWrapper < FirstResult1, grammar::CNF > ( First::first ); +auto FirstLG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::LG > ( First::first ); +auto FirstLeftLG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::LeftLG > ( First::first ); +auto FirstLeftRG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::LeftRG > ( First::first ); +auto FirstRightLG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::RightLG > ( First::first ); +auto FirstRightRG = FirstBase1::RegistratorWrapper < FirstResult1, grammar::RightRG > ( First::first ); std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > First::first ( const grammar::Grammar & grammar ) { - return getInstance1 ( ).dispatch ( grammar.getData ( ) ); + return FirstBase1::dispatch ( grammar.getData ( ) ); } -auto FirstCFG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::CFG > ( First::getInstance2 ( ), First::first ); -auto FirstEpsilonFreeCFG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::EpsilonFreeCFG > ( First::getInstance2 ( ), First::first ); -auto FirstGNF2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::GNF > ( First::getInstance2 ( ), First::first ); -auto FirstCNF2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::CNF > ( First::getInstance2 ( ), First::first ); -auto FirstLG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::LG > ( First::getInstance2 ( ), First::first ); -auto FirstLeftLG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::LeftLG > ( First::getInstance2 ( ), First::first ); -auto FirstLeftRG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::LeftRG > ( First::getInstance2 ( ), First::first ); -auto FirstRightLG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::RightLG > ( First::getInstance2 ( ), First::first ); -auto FirstRightRG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::RightRG > ( First::getInstance2 ( ), First::first ); +auto FirstCFG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::CFG > ( First::first ); +auto FirstEpsilonFreeCFG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::EpsilonFreeCFG > ( First::first ); +auto FirstGNF2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::GNF > ( First::first ); +auto FirstCNF2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::CNF > ( First::first ); +auto FirstLG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::LG > ( First::first ); +auto FirstLeftLG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::LeftLG > ( First::first ); +auto FirstLeftRG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::LeftRG > ( First::first ); +auto FirstRightLG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::RightLG > ( First::first ); +auto FirstRightRG2 = FirstBase2::RegistratorWrapper < FirstResult2, grammar::RightRG > ( First::first ); std::set < std::variant < alphabet::Symbol, string::Epsilon > > First::first ( const grammar::Grammar & grammar, const std::vector < alphabet::Symbol > & rhs ) { - return getInstance2 ( ).dispatch ( grammar.getData ( ), rhs ); + return FirstBase2::dispatch ( grammar.getData ( ), rhs ); } } /* namespace parsing */ diff --git a/alib2algo/src/grammar/parsing/First.h b/alib2algo/src/grammar/parsing/First.h index fb164a03ad3754798719cf6beeb098a28db32cf0..1a8813b6d38edc5103d0b31e7bf4f716fb30cd53 100644 --- a/alib2algo/src/grammar/parsing/First.h +++ b/alib2algo/src/grammar/parsing/First.h @@ -20,23 +20,19 @@ namespace grammar { namespace parsing { +class First; + typedef std::map < std::vector < alphabet::Symbol >, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > FirstResult1; -typedef std::SingleDispatch < FirstResult1, grammar::GrammarBase > FirstBase1; +typedef std::SingleDispatch < First, FirstResult1, grammar::GrammarBase > FirstBase1; typedef std::set < std::variant < alphabet::Symbol, string::Epsilon > > FirstResult2; -typedef std::SingleDispatchLastStaticParam < FirstResult2, grammar::GrammarBase, const std::vector < alphabet::Symbol > & > FirstBase2; +typedef std::SingleDispatchLastStaticParam < First, FirstResult2, grammar::GrammarBase, const std::vector < alphabet::Symbol > & > FirstBase2; class First : public FirstBase1, public FirstBase2 { static std::set < std::variant < alphabet::Symbol, string::Epsilon > > first ( const std::set < alphabet::Symbol > & terminals, const std::set < alphabet::Symbol > & nonterminals, const std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > & firstOfNonterminal, const std::vector < alphabet::Symbol > & rhs ); static std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > first ( const std::set < alphabet::Symbol > & terminals, const std::set < alphabet::Symbol > & nonterminals, const std::map < alphabet::Symbol, std::set < std::vector < alphabet::Symbol > > > & rules ); - static First & getInstance ( ) { - static First res; - - return res; - } - public: template < class T > static FirstResult1 first ( const T & grammar ); @@ -48,14 +44,6 @@ public: static FirstResult2 first ( const grammar::Grammar & grammar, const std::vector < alphabet::Symbol > & rhs ); - static FirstBase1 & getInstance1 ( ) { - return getInstance ( ); - } - - static FirstBase2 & getInstance2 ( ) { - return getInstance ( ); - } - }; } /* namespace parsing */ diff --git a/alib2algo/src/grammar/parsing/Follow.cpp b/alib2algo/src/grammar/parsing/Follow.cpp index ed48289ca05fd479c9dad09a15e61af127a991a3..5ecb9f1968646a7b53f5e68988e1379274062064 100644 --- a/alib2algo/src/grammar/parsing/Follow.cpp +++ b/alib2algo/src/grammar/parsing/Follow.cpp @@ -92,32 +92,32 @@ std::set < std::variant < alphabet::Symbol, string::Epsilon > > Follow::follow ( return follow ( grammar )[nt]; } -auto FollowCFG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::CFG > ( Follow::getInstance1 ( ), Follow::follow ); -auto FollowEpsilonFreeCFG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::EpsilonFreeCFG > ( Follow::getInstance1 ( ), Follow::follow ); -auto FollowGNF = FollowBase1::RegistratorWrapper < FollowResult1, grammar::GNF > ( Follow::getInstance1 ( ), Follow::follow ); -auto FollowCNF = FollowBase1::RegistratorWrapper < FollowResult1, grammar::CNF > ( Follow::getInstance1 ( ), Follow::follow ); -auto FollowLG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::LG > ( Follow::getInstance1 ( ), Follow::follow ); -auto FollowLeftLG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::LeftLG > ( Follow::getInstance1 ( ), Follow::follow ); -auto FollowLeftRG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::LeftRG > ( Follow::getInstance1 ( ), Follow::follow ); -auto FollowRightLG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::RightLG > ( Follow::getInstance1 ( ), Follow::follow ); -auto FollowRightRG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::RightRG > ( Follow::getInstance1 ( ), Follow::follow ); +auto FollowCFG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::CFG > ( Follow::follow ); +auto FollowEpsilonFreeCFG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::EpsilonFreeCFG > ( Follow::follow ); +auto FollowGNF = FollowBase1::RegistratorWrapper < FollowResult1, grammar::GNF > ( Follow::follow ); +auto FollowCNF = FollowBase1::RegistratorWrapper < FollowResult1, grammar::CNF > ( Follow::follow ); +auto FollowLG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::LG > ( Follow::follow ); +auto FollowLeftLG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::LeftLG > ( Follow::follow ); +auto FollowLeftRG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::LeftRG > ( Follow::follow ); +auto FollowRightLG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::RightLG > ( Follow::follow ); +auto FollowRightRG = FollowBase1::RegistratorWrapper < FollowResult1, grammar::RightRG > ( Follow::follow ); std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > Follow::follow ( const grammar::Grammar & grammar ) { - return getInstance1 ( ).dispatch ( grammar.getData ( ) ); + return FollowBase1::dispatch ( grammar.getData ( ) ); } -auto FollowCFG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::CFG > ( Follow::getInstance2 ( ), Follow::follow ); -auto FollowEpsilonFreeCFG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::EpsilonFreeCFG > ( Follow::getInstance2 ( ), Follow::follow ); -auto FollowGNF2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::GNF > ( Follow::getInstance2 ( ), Follow::follow ); -auto FollowCNF2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::CNF > ( Follow::getInstance2 ( ), Follow::follow ); -auto FollowLG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::LG > ( Follow::getInstance2 ( ), Follow::follow ); -auto FollowLeftLG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::LeftLG > ( Follow::getInstance2 ( ), Follow::follow ); -auto FollowLeftRG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::LeftRG > ( Follow::getInstance2 ( ), Follow::follow ); -auto FollowRightLG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::RightLG > ( Follow::getInstance2 ( ), Follow::follow ); -auto FollowRightRG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::RightRG > ( Follow::getInstance2 ( ), Follow::follow ); +auto FollowCFG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::CFG > ( Follow::follow ); +auto FollowEpsilonFreeCFG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::EpsilonFreeCFG > ( Follow::follow ); +auto FollowGNF2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::GNF > ( Follow::follow ); +auto FollowCNF2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::CNF > ( Follow::follow ); +auto FollowLG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::LG > ( Follow::follow ); +auto FollowLeftLG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::LeftLG > ( Follow::follow ); +auto FollowLeftRG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::LeftRG > ( Follow::follow ); +auto FollowRightLG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::RightLG > ( Follow::follow ); +auto FollowRightRG2 = FollowBase2::RegistratorWrapper < FollowResult2, grammar::RightRG > ( Follow::follow ); std::set < std::variant < alphabet::Symbol, string::Epsilon > > Follow::follow ( const grammar::Grammar & grammar, const alphabet::Symbol & nt ) { - return getInstance2 ( ).dispatch ( grammar.getData ( ), nt ); + return FollowBase2::dispatch ( grammar.getData ( ), nt ); } } /* namespace parsing */ diff --git a/alib2algo/src/grammar/parsing/Follow.h b/alib2algo/src/grammar/parsing/Follow.h index 5dd3012299fefe5f9dfb1268b7f087c88f4c8bfb..3fab8f22f6d03edc1c392490db22dbf567ff1fba 100644 --- a/alib2algo/src/grammar/parsing/Follow.h +++ b/alib2algo/src/grammar/parsing/Follow.h @@ -20,11 +20,13 @@ namespace grammar { namespace parsing { +class Follow; + typedef std::map < alphabet::Symbol, std::set < std::variant < alphabet::Symbol, string::Epsilon > > > FollowResult1; -typedef std::SingleDispatch < FollowResult1, grammar::GrammarBase > FollowBase1; +typedef std::SingleDispatch < Follow, FollowResult1, grammar::GrammarBase > FollowBase1; typedef std::set < std::variant < alphabet::Symbol, string::Epsilon > > FollowResult2; -typedef std::SingleDispatchLastStaticParam < FollowResult2, grammar::GrammarBase, const alphabet::Symbol & > FollowBase2; +typedef std::SingleDispatchLastStaticParam < Follow, FollowResult2, grammar::GrammarBase, const alphabet::Symbol & > FollowBase2; class Follow : public FollowBase1, public FollowBase2 { template < class T > diff --git a/alib2algo/src/grammar/parsing/LL1ParseTable.cpp b/alib2algo/src/grammar/parsing/LL1ParseTable.cpp index d8547f93e7686c0b8808a62e119c4a61de684cf4..a39a0111b6d770d75db3d4bb27abe0045d6c953d 100644 --- a/alib2algo/src/grammar/parsing/LL1ParseTable.cpp +++ b/alib2algo/src/grammar/parsing/LL1ParseTable.cpp @@ -50,18 +50,18 @@ std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alpha return res; } -auto LL1ParseTableCFG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::CFG > ( LL1ParseTable::getInstance ( ), LL1ParseTable::parseTable ); -auto LL1ParseTableEpsilonFreeCFG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::EpsilonFreeCFG > ( LL1ParseTable::getInstance ( ), LL1ParseTable::parseTable ); -auto LL1ParseTableGNF = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::GNF > ( LL1ParseTable::getInstance ( ), LL1ParseTable::parseTable ); -auto LL1ParseTableCNF = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::CNF > ( LL1ParseTable::getInstance ( ), LL1ParseTable::parseTable ); -auto LL1ParseTableLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LG > ( LL1ParseTable::getInstance ( ), LL1ParseTable::parseTable ); -auto LL1ParseTableLeftLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LeftLG > ( LL1ParseTable::getInstance ( ), LL1ParseTable::parseTable ); -auto LL1ParseTableLeftRG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LeftRG > ( LL1ParseTable::getInstance ( ), LL1ParseTable::parseTable ); -auto LL1ParseTableRightLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::RightLG > ( LL1ParseTable::getInstance ( ), LL1ParseTable::parseTable ); -auto LL1ParseTableRightRG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::RightRG > ( LL1ParseTable::getInstance ( ), LL1ParseTable::parseTable ); +auto LL1ParseTableCFG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::CFG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableEpsilonFreeCFG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::EpsilonFreeCFG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableGNF = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::GNF > ( LL1ParseTable::parseTable ); +auto LL1ParseTableCNF = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::CNF > ( LL1ParseTable::parseTable ); +auto LL1ParseTableLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableLeftLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LeftLG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableLeftRG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::LeftRG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableRightLG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::RightLG > ( LL1ParseTable::parseTable ); +auto LL1ParseTableRightRG = LL1ParseTable::RegistratorWrapper < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::RightRG > ( LL1ParseTable::parseTable ); std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > LL1ParseTable::parseTable ( const grammar::Grammar & grammar ) { - return getInstance ( ).dispatch ( grammar.getData ( ) ); + return dispatch ( grammar.getData ( ) ); } } /* namespace parsing */ diff --git a/alib2algo/src/grammar/parsing/LL1ParseTable.h b/alib2algo/src/grammar/parsing/LL1ParseTable.h index ff80dc31070855dcf3bdb73cb9cfb57e97f3446f..24fb7b5d86e5cb5aa641327e93236cf9b747674a 100644 --- a/alib2algo/src/grammar/parsing/LL1ParseTable.h +++ b/alib2algo/src/grammar/parsing/LL1ParseTable.h @@ -21,19 +21,13 @@ namespace grammar { namespace parsing { -class LL1ParseTable : public std::SingleDispatch < std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::GrammarBase > { +class LL1ParseTable : public std::SingleDispatch < LL1ParseTable, std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > >, grammar::GrammarBase > { public: template < class T > static std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTable ( const T & grammar ); static std::map < std::pair < std::variant < alphabet::Symbol, string::Epsilon >, alphabet::Symbol >, std::set < std::vector < alphabet::Symbol > > > parseTable ( const grammar::Grammar & grammar ); - static LL1ParseTable & getInstance ( ) { - static LL1ParseTable res; - - return res; - } - }; } /* namespace parsing */ diff --git a/alib2algo/src/grammar/properties/IsLanguageEmpty.cpp b/alib2algo/src/grammar/properties/IsLanguageEmpty.cpp index b1d5e6b6cddcd857dec5af972cd90be8ddf98679..e0f078078a427694e8cbf1e7f140d36d97d58e63 100644 --- a/alib2algo/src/grammar/properties/IsLanguageEmpty.cpp +++ b/alib2algo/src/grammar/properties/IsLanguageEmpty.cpp @@ -28,19 +28,15 @@ bool IsLanguageEmpty::isLanguageEmpty( const T & grammar ) { return grammar::properties::ProductiveNonterminals::getProductiveNonterminals( grammar ).count( grammar.getInitialSymbol( ) ); } -auto IsLanguageEmptyCFG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::CFG>(IsLanguageEmpty::getInstance(), IsLanguageEmpty::isLanguageEmpty); -auto IsLanguageEmptyEpsilonFreeCFG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::EpsilonFreeCFG>(IsLanguageEmpty::getInstance(), IsLanguageEmpty::isLanguageEmpty); -auto IsLanguageEmptyGNF = IsLanguageEmpty::RegistratorWrapper<bool, grammar::GNF>(IsLanguageEmpty::getInstance(), IsLanguageEmpty::isLanguageEmpty); -auto IsLanguageEmptyCNF = IsLanguageEmpty::RegistratorWrapper<bool, grammar::CNF>(IsLanguageEmpty::getInstance(), IsLanguageEmpty::isLanguageEmpty); -auto IsLanguageEmptyLG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::LG>(IsLanguageEmpty::getInstance(), IsLanguageEmpty::isLanguageEmpty); -auto IsLanguageEmptyLeftLG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::LeftLG>(IsLanguageEmpty::getInstance(), IsLanguageEmpty::isLanguageEmpty); -auto IsLanguageEmptyLeftRG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::LeftRG>(IsLanguageEmpty::getInstance(), IsLanguageEmpty::isLanguageEmpty); -auto IsLanguageEmptyRightLG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::RightLG>(IsLanguageEmpty::getInstance(), IsLanguageEmpty::isLanguageEmpty); -auto IsLanguageEmptyRightRG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::RightRG>(IsLanguageEmpty::getInstance(), IsLanguageEmpty::isLanguageEmpty); - -bool IsLanguageEmpty::isLanguageEmpty(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); -} +auto IsLanguageEmptyCFG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::CFG>(IsLanguageEmpty::isLanguageEmpty); +auto IsLanguageEmptyEpsilonFreeCFG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::EpsilonFreeCFG>(IsLanguageEmpty::isLanguageEmpty); +auto IsLanguageEmptyGNF = IsLanguageEmpty::RegistratorWrapper<bool, grammar::GNF>(IsLanguageEmpty::isLanguageEmpty); +auto IsLanguageEmptyCNF = IsLanguageEmpty::RegistratorWrapper<bool, grammar::CNF>(IsLanguageEmpty::isLanguageEmpty); +auto IsLanguageEmptyLG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::LG>(IsLanguageEmpty::isLanguageEmpty); +auto IsLanguageEmptyLeftLG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::LeftLG>(IsLanguageEmpty::isLanguageEmpty); +auto IsLanguageEmptyLeftRG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::LeftRG>(IsLanguageEmpty::isLanguageEmpty); +auto IsLanguageEmptyRightLG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::RightLG>(IsLanguageEmpty::isLanguageEmpty); +auto IsLanguageEmptyRightRG = IsLanguageEmpty::RegistratorWrapper<bool, grammar::RightRG>(IsLanguageEmpty::isLanguageEmpty); } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/IsLanguageEmpty.h b/alib2algo/src/grammar/properties/IsLanguageEmpty.h index 90c8f89d035befc9387f246ca06491afab5a6991..259809e9d4ac230dce1fef25aeb1271a2bc0961a 100644 --- a/alib2algo/src/grammar/properties/IsLanguageEmpty.h +++ b/alib2algo/src/grammar/properties/IsLanguageEmpty.h @@ -19,7 +19,7 @@ namespace properties { /** * Implements algorithms from Melichar, chapter 3.3 */ -class IsLanguageEmpty : public std::SingleDispatch<bool, grammar::GrammarBase> { +class IsLanguageEmpty : public std::SingleDispatch<IsLanguageEmpty, bool, grammar::GrammarBase> { public: static bool isLanguageEmpty( const grammar::Grammar & grammar ); @@ -31,11 +31,6 @@ public: */ template<class T> static bool isLanguageEmpty( const T & grammar ); - - static IsLanguageEmpty& getInstance() { - static IsLanguageEmpty res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.cpp b/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.cpp index 3046cfd9918ad119ee968a9687ffc1cb3e314bd2..31d89a30228e32b1fd4cc1ebd4b6d3f9708102ab 100644 --- a/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.cpp +++ b/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.cpp @@ -28,19 +28,15 @@ bool IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon( const T & grammar return grammar::properties::NullableNonterminals::getNullableNonterminals( grammar ).count( grammar.getInitialSymbol( ) ); } -auto IsLanguageGeneratingEpsilonCFG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::CFG>(IsLanguageGeneratingEpsilon::getInstance(), IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); -auto IsLanguageGeneratingEpsilonEpsilonFreeCFG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::EpsilonFreeCFG>(IsLanguageGeneratingEpsilon::getInstance(), IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); -auto IsLanguageGeneratingEpsilonGNF = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::GNF>(IsLanguageGeneratingEpsilon::getInstance(), IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); -auto IsLanguageGeneratingEpsilonCNF = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::CNF>(IsLanguageGeneratingEpsilon::getInstance(), IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); -auto IsLanguageGeneratingEpsilonLG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::LG>(IsLanguageGeneratingEpsilon::getInstance(), IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); -auto IsLanguageGeneratingEpsilonLeftLG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::LeftLG>(IsLanguageGeneratingEpsilon::getInstance(), IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); -auto IsLanguageGeneratingEpsilonLeftRG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::LeftRG>(IsLanguageGeneratingEpsilon::getInstance(), IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); -auto IsLanguageGeneratingEpsilonRightLG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::RightLG>(IsLanguageGeneratingEpsilon::getInstance(), IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); -auto IsLanguageGeneratingEpsilonRightRG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::RightRG>(IsLanguageGeneratingEpsilon::getInstance(), IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); - -bool IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); -} +auto IsLanguageGeneratingEpsilonCFG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::CFG>(IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); +auto IsLanguageGeneratingEpsilonEpsilonFreeCFG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::EpsilonFreeCFG>(IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); +auto IsLanguageGeneratingEpsilonGNF = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::GNF>(IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); +auto IsLanguageGeneratingEpsilonCNF = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::CNF>(IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); +auto IsLanguageGeneratingEpsilonLG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::LG>(IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); +auto IsLanguageGeneratingEpsilonLeftLG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::LeftLG>(IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); +auto IsLanguageGeneratingEpsilonLeftRG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::LeftRG>(IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); +auto IsLanguageGeneratingEpsilonRightLG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::RightLG>(IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); +auto IsLanguageGeneratingEpsilonRightRG = IsLanguageGeneratingEpsilon::RegistratorWrapper<bool, grammar::RightRG>(IsLanguageGeneratingEpsilon::isLanguageGeneratingEpsilon); } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.h b/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.h index 51e667026717518e6a806db4073ae9365dd163c5..2690886f1c47ca3d04af5cd777f9648dd4caecd5 100644 --- a/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.h +++ b/alib2algo/src/grammar/properties/IsLanguageGeneratingEpsilon.h @@ -19,7 +19,7 @@ namespace properties { /** * Implements algorithms from Melichar, chapter 3.3 */ -class IsLanguageGeneratingEpsilon : public std::SingleDispatch<bool, grammar::GrammarBase> { +class IsLanguageGeneratingEpsilon : public std::SingleDispatch<IsLanguageGeneratingEpsilon, bool, grammar::GrammarBase> { public: static bool isLanguageGeneratingEpsilon( const grammar::Grammar & grammar ); @@ -31,11 +31,6 @@ public: */ template<class T> static bool isLanguageGeneratingEpsilon( const T & grammar ); - - static IsLanguageGeneratingEpsilon& getInstance() { - static IsLanguageGeneratingEpsilon res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.cpp b/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.cpp index 5293f219d34f4f9995771afe37d8bfd628359032..a07c4280fa83cf5b2201366b67ac4d15d2a020a1 100644 --- a/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.cpp +++ b/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.cpp @@ -57,18 +57,18 @@ std::set<alphabet::Symbol> NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle return Ni.at(i); } -auto NonterminalUnitRuleCycleCFG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CFG>(NonterminalUnitRuleCycle::getInstance(), NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); -auto NonterminalUnitRuleCycleEpsilonFreeCFG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::EpsilonFreeCFG>(NonterminalUnitRuleCycle::getInstance(), NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); -auto NonterminalUnitRuleCycleGNF = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::GNF>(NonterminalUnitRuleCycle::getInstance(), NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); -auto NonterminalUnitRuleCycleCNF = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CNF>(NonterminalUnitRuleCycle::getInstance(), NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); -auto NonterminalUnitRuleCycleLG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LG>(NonterminalUnitRuleCycle::getInstance(), NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); -auto NonterminalUnitRuleCycleLeftLG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftLG>(NonterminalUnitRuleCycle::getInstance(), NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); -auto NonterminalUnitRuleCycleLeftRG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftRG>(NonterminalUnitRuleCycle::getInstance(), NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); -auto NonterminalUnitRuleCycleRightLG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightLG>(NonterminalUnitRuleCycle::getInstance(), NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); -auto NonterminalUnitRuleCycleRightRG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightRG>(NonterminalUnitRuleCycle::getInstance(), NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); +auto NonterminalUnitRuleCycleCFG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CFG>(NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); +auto NonterminalUnitRuleCycleEpsilonFreeCFG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::EpsilonFreeCFG>(NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); +auto NonterminalUnitRuleCycleGNF = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::GNF>(NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); +auto NonterminalUnitRuleCycleCNF = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CNF>(NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); +auto NonterminalUnitRuleCycleLG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LG>(NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); +auto NonterminalUnitRuleCycleLeftLG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftLG>(NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); +auto NonterminalUnitRuleCycleLeftRG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftRG>(NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); +auto NonterminalUnitRuleCycleRightLG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightLG>(NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); +auto NonterminalUnitRuleCycleRightRG = NonterminalUnitRuleCycle::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightRG>(NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle); std::set<alphabet::Symbol> NonterminalUnitRuleCycle::getNonterminalUnitRuleCycle(const grammar::Grammar& grammar, const alphabet::Symbol& nonterminal) { - return getInstance().dispatch(grammar.getData(), nonterminal); + return dispatch(grammar.getData(), nonterminal); } } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.h b/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.h index 90a9d400aedce1e92d37d0f41237211a34a77568..42a5ec68969c45e11e1d86432aa85a07558cf58f 100644 --- a/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.h +++ b/alib2algo/src/grammar/properties/NonterminalUnitRuleCycle.h @@ -20,7 +20,7 @@ namespace properties { /** * Implements algorithms from Melichar, chapter 3.3 */ -class NonterminalUnitRuleCycle : public std::SingleDispatchLastStaticParam<std::set<alphabet::Symbol>, grammar::GrammarBase, const alphabet::Symbol&> { +class NonterminalUnitRuleCycle : public std::SingleDispatchLastStaticParam<NonterminalUnitRuleCycle, std::set<alphabet::Symbol>, grammar::GrammarBase, const alphabet::Symbol&> { public: static std::set<alphabet::Symbol> getNonterminalUnitRuleCycle( const grammar::Grammar & grammar, const alphabet::Symbol& nonterminal ); @@ -35,11 +35,6 @@ public: */ template<class T> static std::set<alphabet::Symbol> getNonterminalUnitRuleCycle(const T& grammar, const alphabet::Symbol& nonterminal); - - static NonterminalUnitRuleCycle& getInstance() { - static NonterminalUnitRuleCycle res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/NullableNonterminals.cpp b/alib2algo/src/grammar/properties/NullableNonterminals.cpp index 3749bf0c4bfa00d13c4c5591f0b72a387e2f3bc2..2ea13a7c6307aaa041743b7747c4965a526310f8 100644 --- a/alib2algo/src/grammar/properties/NullableNonterminals.cpp +++ b/alib2algo/src/grammar/properties/NullableNonterminals.cpp @@ -51,19 +51,15 @@ std::set<alphabet::Symbol> NullableNonterminals::getNullableNonterminals(const T return Ni.at(i); } -auto NullableNonterminalsCFG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CFG>(NullableNonterminals::getInstance(), NullableNonterminals::getNullableNonterminals); -auto NullableNonterminalsEpsilonFreeCFG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::EpsilonFreeCFG>(NullableNonterminals::getInstance(), NullableNonterminals::getNullableNonterminals); -auto NullableNonterminalsGNF = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::GNF>(NullableNonterminals::getInstance(), NullableNonterminals::getNullableNonterminals); -auto NullableNonterminalsCNF = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CNF>(NullableNonterminals::getInstance(), NullableNonterminals::getNullableNonterminals); -auto NullableNonterminalsLG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LG>(NullableNonterminals::getInstance(), NullableNonterminals::getNullableNonterminals); -auto NullableNonterminalsLeftLG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftLG>(NullableNonterminals::getInstance(), NullableNonterminals::getNullableNonterminals); -auto NullableNonterminalsLeftRG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftRG>(NullableNonterminals::getInstance(), NullableNonterminals::getNullableNonterminals); -auto NullableNonterminalsRightLG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightLG>(NullableNonterminals::getInstance(), NullableNonterminals::getNullableNonterminals); -auto NullableNonterminalsRightRG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightRG>(NullableNonterminals::getInstance(), NullableNonterminals::getNullableNonterminals); - -std::set<alphabet::Symbol> NullableNonterminals::getNullableNonterminals(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); -} +auto NullableNonterminalsCFG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CFG>(NullableNonterminals::getNullableNonterminals); +auto NullableNonterminalsEpsilonFreeCFG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::EpsilonFreeCFG>(NullableNonterminals::getNullableNonterminals); +auto NullableNonterminalsGNF = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::GNF>(NullableNonterminals::getNullableNonterminals); +auto NullableNonterminalsCNF = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CNF>(NullableNonterminals::getNullableNonterminals); +auto NullableNonterminalsLG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LG>(NullableNonterminals::getNullableNonterminals); +auto NullableNonterminalsLeftLG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftLG>(NullableNonterminals::getNullableNonterminals); +auto NullableNonterminalsLeftRG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftRG>(NullableNonterminals::getNullableNonterminals); +auto NullableNonterminalsRightLG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightLG>(NullableNonterminals::getNullableNonterminals); +auto NullableNonterminalsRightRG = NullableNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightRG>(NullableNonterminals::getNullableNonterminals); } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/NullableNonterminals.h b/alib2algo/src/grammar/properties/NullableNonterminals.h index 40e8bfed97e6e29fa48b3be7b0ccdd641fd6e2c8..ac600e9e58bf7af980ed9e621b6a58cbdb74f61f 100644 --- a/alib2algo/src/grammar/properties/NullableNonterminals.h +++ b/alib2algo/src/grammar/properties/NullableNonterminals.h @@ -20,7 +20,7 @@ namespace properties { /** * Implements algorithms from Melichar, chapter 3.3 */ -class NullableNonterminals : public std::SingleDispatch<std::set<alphabet::Symbol>, grammar::GrammarBase> { +class NullableNonterminals : public std::SingleDispatch<NullableNonterminals, std::set<alphabet::Symbol>, grammar::GrammarBase> { public: static std::set<alphabet::Symbol> getNullableNonterminals( const grammar::Grammar & grammar ); @@ -35,11 +35,6 @@ public: */ template<class T> static std::set<alphabet::Symbol> getNullableNonterminals(const T& grammar); - - static NullableNonterminals& getInstance() { - static NullableNonterminals res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/ProductiveNonterminals.cpp b/alib2algo/src/grammar/properties/ProductiveNonterminals.cpp index e32f023dc1b882b5deabcda7f85509c20e7f4b14..9ad0e33fdf4bce489242340a4336e2a60afa290f 100644 --- a/alib2algo/src/grammar/properties/ProductiveNonterminals.cpp +++ b/alib2algo/src/grammar/properties/ProductiveNonterminals.cpp @@ -56,19 +56,15 @@ std::set<alphabet::Symbol> ProductiveNonterminals::getProductiveNonterminals( co return Ni.at( i ); } -auto ProductiveNonterminalsCFG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CFG>(ProductiveNonterminals::getInstance(), ProductiveNonterminals::getProductiveNonterminals); -auto ProductiveNonterminalsEpsilonFreeCFG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::EpsilonFreeCFG>(ProductiveNonterminals::getInstance(), ProductiveNonterminals::getProductiveNonterminals); -auto ProductiveNonterminalsGNF = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::GNF>(ProductiveNonterminals::getInstance(), ProductiveNonterminals::getProductiveNonterminals); -auto ProductiveNonterminalsCNF = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CNF>(ProductiveNonterminals::getInstance(), ProductiveNonterminals::getProductiveNonterminals); -auto ProductiveNonterminalsLG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LG>(ProductiveNonterminals::getInstance(), ProductiveNonterminals::getProductiveNonterminals); -auto ProductiveNonterminalsLeftLG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftLG>(ProductiveNonterminals::getInstance(), ProductiveNonterminals::getProductiveNonterminals); -auto ProductiveNonterminalsLeftRG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftRG>(ProductiveNonterminals::getInstance(), ProductiveNonterminals::getProductiveNonterminals); -auto ProductiveNonterminalsRightLG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightLG>(ProductiveNonterminals::getInstance(), ProductiveNonterminals::getProductiveNonterminals); -auto ProductiveNonterminalsRightRG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightRG>(ProductiveNonterminals::getInstance(), ProductiveNonterminals::getProductiveNonterminals); - -std::set<alphabet::Symbol> ProductiveNonterminals::getProductiveNonterminals(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); -} +auto ProductiveNonterminalsCFG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CFG>(ProductiveNonterminals::getProductiveNonterminals); +auto ProductiveNonterminalsEpsilonFreeCFG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::EpsilonFreeCFG>(ProductiveNonterminals::getProductiveNonterminals); +auto ProductiveNonterminalsGNF = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::GNF>(ProductiveNonterminals::getProductiveNonterminals); +auto ProductiveNonterminalsCNF = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CNF>(ProductiveNonterminals::getProductiveNonterminals); +auto ProductiveNonterminalsLG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LG>(ProductiveNonterminals::getProductiveNonterminals); +auto ProductiveNonterminalsLeftLG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftLG>(ProductiveNonterminals::getProductiveNonterminals); +auto ProductiveNonterminalsLeftRG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftRG>(ProductiveNonterminals::getProductiveNonterminals); +auto ProductiveNonterminalsRightLG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightLG>(ProductiveNonterminals::getProductiveNonterminals); +auto ProductiveNonterminalsRightRG = ProductiveNonterminals::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightRG>(ProductiveNonterminals::getProductiveNonterminals); } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/ProductiveNonterminals.h b/alib2algo/src/grammar/properties/ProductiveNonterminals.h index ad733c4cb1224f8f9ce3bc222189884fe99e4b32..d2b61431940fe62613f04771a00f874c6dedc6f3 100644 --- a/alib2algo/src/grammar/properties/ProductiveNonterminals.h +++ b/alib2algo/src/grammar/properties/ProductiveNonterminals.h @@ -20,7 +20,7 @@ namespace properties { /** * Implements algorithms from Melichar, chapter 3.3 */ -class ProductiveNonterminals : public std::SingleDispatch<std::set<alphabet::Symbol>, grammar::GrammarBase> { +class ProductiveNonterminals : public std::SingleDispatch<ProductiveNonterminals, std::set<alphabet::Symbol>, grammar::GrammarBase> { public: static std::set<alphabet::Symbol> getProductiveNonterminals( const grammar::Grammar & grammar ); @@ -29,11 +29,6 @@ public: */ template<class T> static std::set<alphabet::Symbol> getProductiveNonterminals( const T & grammar ); - - static ProductiveNonterminals& getInstance() { - static ProductiveNonterminals res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/RecursiveNonterminal.cpp b/alib2algo/src/grammar/properties/RecursiveNonterminal.cpp index b9bcb55ae7fd6f6b82887309386724fe88116225..da8472085290bd35378f0edcdfa58889b6e8960b 100644 --- a/alib2algo/src/grammar/properties/RecursiveNonterminal.cpp +++ b/alib2algo/src/grammar/properties/RecursiveNonterminal.cpp @@ -63,18 +63,18 @@ bool RecursiveNonterminal::isNonterminalRecursive ( const T & grammar, const alp return false; } -auto RecursiveNonterminalCFG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::CFG > ( RecursiveNonterminal::getInstance ( ), RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalEpsilonFreeCFG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::EpsilonFreeCFG > ( RecursiveNonterminal::getInstance ( ), RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalGNF = RecursiveNonterminal::RegistratorWrapper < bool, grammar::GNF > ( RecursiveNonterminal::getInstance ( ), RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalCNF = RecursiveNonterminal::RegistratorWrapper < bool, grammar::CNF > ( RecursiveNonterminal::getInstance ( ), RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalLG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::LG > ( RecursiveNonterminal::getInstance ( ), RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalLeftLG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::LeftLG > ( RecursiveNonterminal::getInstance ( ), RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalLeftRG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::LeftRG > ( RecursiveNonterminal::getInstance ( ), RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalRightLG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::RightLG > ( RecursiveNonterminal::getInstance ( ), RecursiveNonterminal::isNonterminalRecursive ); -auto RecursiveNonterminalRightRG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::RightRG > ( RecursiveNonterminal::getInstance ( ), RecursiveNonterminal::isNonterminalRecursive ); +auto RecursiveNonterminalCFG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::CFG > ( RecursiveNonterminal::isNonterminalRecursive ); +auto RecursiveNonterminalEpsilonFreeCFG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::EpsilonFreeCFG > ( RecursiveNonterminal::isNonterminalRecursive ); +auto RecursiveNonterminalGNF = RecursiveNonterminal::RegistratorWrapper < bool, grammar::GNF > ( RecursiveNonterminal::isNonterminalRecursive ); +auto RecursiveNonterminalCNF = RecursiveNonterminal::RegistratorWrapper < bool, grammar::CNF > ( RecursiveNonterminal::isNonterminalRecursive ); +auto RecursiveNonterminalLG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::LG > ( RecursiveNonterminal::isNonterminalRecursive ); +auto RecursiveNonterminalLeftLG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::LeftLG > ( RecursiveNonterminal::isNonterminalRecursive ); +auto RecursiveNonterminalLeftRG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::LeftRG > ( RecursiveNonterminal::isNonterminalRecursive ); +auto RecursiveNonterminalRightLG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::RightLG > ( RecursiveNonterminal::isNonterminalRecursive ); +auto RecursiveNonterminalRightRG = RecursiveNonterminal::RegistratorWrapper < bool, grammar::RightRG > ( RecursiveNonterminal::isNonterminalRecursive ); bool RecursiveNonterminal::isNonterminalRecursive ( const grammar::Grammar & grammar, const alphabet::Symbol & nonterminal ) { - return getInstance ( ).dispatch ( grammar.getData ( ), nonterminal ); + return dispatch ( grammar.getData ( ), nonterminal ); } } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/RecursiveNonterminal.h b/alib2algo/src/grammar/properties/RecursiveNonterminal.h index 5a45ca7a47e647f3df7e05cdded02186042a6550..2795ef2abf85dd1f7fb2b724ce04f0fe0a31d7eb 100644 --- a/alib2algo/src/grammar/properties/RecursiveNonterminal.h +++ b/alib2algo/src/grammar/properties/RecursiveNonterminal.h @@ -20,7 +20,7 @@ namespace properties { /** * Implements algorithms from Melichar, chapter 3.3 */ -class RecursiveNonterminal : public std::SingleDispatchLastStaticParam < bool, grammar::GrammarBase, const alphabet::Symbol & > { +class RecursiveNonterminal : public std::SingleDispatchLastStaticParam < RecursiveNonterminal, bool, grammar::GrammarBase, const alphabet::Symbol & > { public: static bool isNonterminalRecursive ( const grammar::Grammar & grammar, const alphabet::Symbol & nonterminal ); @@ -34,12 +34,6 @@ public: template < class T > static bool isNonterminalRecursive ( const T & grammar, const alphabet::Symbol & nonterminal ); - static RecursiveNonterminal & getInstance ( ) { - static RecursiveNonterminal res; - - return res; - } - }; } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/UnreachableSymbols.cpp b/alib2algo/src/grammar/properties/UnreachableSymbols.cpp index 3f83b5dd7fd5a15f1f928578e55583507814fcfe..021483cde4200b16687c0deaadf19625182c749c 100644 --- a/alib2algo/src/grammar/properties/UnreachableSymbols.cpp +++ b/alib2algo/src/grammar/properties/UnreachableSymbols.cpp @@ -57,19 +57,15 @@ std::set<alphabet::Symbol> UnreachableSymbols::getUnreachableSymbols( const T & return Vi.at( i ); } -auto UnreachableSymbolsCFG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CFG>(UnreachableSymbols::getInstance(), UnreachableSymbols::getUnreachableSymbols); -auto UnreachableSymbolsEpsilonFreeCFG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::EpsilonFreeCFG>(UnreachableSymbols::getInstance(), UnreachableSymbols::getUnreachableSymbols); -auto UnreachableSymbolsGNF = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::GNF>(UnreachableSymbols::getInstance(), UnreachableSymbols::getUnreachableSymbols); -auto UnreachableSymbolsCNF = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CNF>(UnreachableSymbols::getInstance(), UnreachableSymbols::getUnreachableSymbols); -auto UnreachableSymbolsLG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LG>(UnreachableSymbols::getInstance(), UnreachableSymbols::getUnreachableSymbols); -auto UnreachableSymbolsLeftLG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftLG>(UnreachableSymbols::getInstance(), UnreachableSymbols::getUnreachableSymbols); -auto UnreachableSymbolsLeftRG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftRG>(UnreachableSymbols::getInstance(), UnreachableSymbols::getUnreachableSymbols); -auto UnreachableSymbolsRightLG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightLG>(UnreachableSymbols::getInstance(), UnreachableSymbols::getUnreachableSymbols); -auto UnreachableSymbolsRightRG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightRG>(UnreachableSymbols::getInstance(), UnreachableSymbols::getUnreachableSymbols); - -std::set<alphabet::Symbol> UnreachableSymbols::getUnreachableSymbols(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); -} +auto UnreachableSymbolsCFG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CFG>(UnreachableSymbols::getUnreachableSymbols); +auto UnreachableSymbolsEpsilonFreeCFG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::EpsilonFreeCFG>(UnreachableSymbols::getUnreachableSymbols); +auto UnreachableSymbolsGNF = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::GNF>(UnreachableSymbols::getUnreachableSymbols); +auto UnreachableSymbolsCNF = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::CNF>(UnreachableSymbols::getUnreachableSymbols); +auto UnreachableSymbolsLG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LG>(UnreachableSymbols::getUnreachableSymbols); +auto UnreachableSymbolsLeftLG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftLG>(UnreachableSymbols::getUnreachableSymbols); +auto UnreachableSymbolsLeftRG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::LeftRG>(UnreachableSymbols::getUnreachableSymbols); +auto UnreachableSymbolsRightLG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightLG>(UnreachableSymbols::getUnreachableSymbols); +auto UnreachableSymbolsRightRG = UnreachableSymbols::RegistratorWrapper<std::set<alphabet::Symbol>, grammar::RightRG>(UnreachableSymbols::getUnreachableSymbols); } /* namespace properties */ diff --git a/alib2algo/src/grammar/properties/UnreachableSymbols.h b/alib2algo/src/grammar/properties/UnreachableSymbols.h index 4cd5c2774e2e4fada32e05b10567d1ba95635811..ac3f934de7e2de699f3ec19814c3053c6953187b 100644 --- a/alib2algo/src/grammar/properties/UnreachableSymbols.h +++ b/alib2algo/src/grammar/properties/UnreachableSymbols.h @@ -20,7 +20,7 @@ namespace properties { /** * Implements algorithms from Melichar, chapter 3.3 */ -class UnreachableSymbols : public std::SingleDispatch<std::set<alphabet::Symbol>, grammar::GrammarBase> { +class UnreachableSymbols : public std::SingleDispatch<UnreachableSymbols, std::set<alphabet::Symbol>, grammar::GrammarBase> { public: static std::set<alphabet::Symbol> getUnreachableSymbols( const grammar::Grammar & grammar ); @@ -29,11 +29,6 @@ public: */ template<class T> static std::set<alphabet::Symbol> getUnreachableSymbols( const T & grammar ); - - static UnreachableSymbols& getInstance() { - static UnreachableSymbols res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/grammar/simplify/EpsilonRemover.cpp b/alib2algo/src/grammar/simplify/EpsilonRemover.cpp index 9540ae0f80c796d1e52f2d10dac7da7b068d9a52..2a6a6476db8c593d908fd3c4f1981ea0adc614df 100644 --- a/alib2algo/src/grammar/simplify/EpsilonRemover.cpp +++ b/alib2algo/src/grammar/simplify/EpsilonRemover.cpp @@ -56,58 +56,58 @@ grammar::EpsilonFreeCFG EpsilonRemover::remove(const grammar::CFG& origGrammar) return removeInternal(origGrammar); } -auto EpsilonRemoverCFG = EpsilonRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::CFG>(EpsilonRemover::getInstance(), EpsilonRemover::remove); +auto EpsilonRemoverCFG = EpsilonRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::CFG>(EpsilonRemover::remove); grammar::EpsilonFreeCFG EpsilonRemover::remove(const grammar::EpsilonFreeCFG& origGrammar) { return origGrammar; } -auto EpsilonRemoverEpsilonFreeCFG = EpsilonRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(EpsilonRemover::getInstance(), EpsilonRemover::remove); +auto EpsilonRemoverEpsilonFreeCFG = EpsilonRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(EpsilonRemover::remove); grammar::CNF EpsilonRemover::remove(const grammar::CNF& origGrammar) { return origGrammar; } -auto EpsilonRemoverCNF = EpsilonRemover::RegistratorWrapper<grammar::CNF, grammar::CNF>(EpsilonRemover::getInstance(), EpsilonRemover::remove); +auto EpsilonRemoverCNF = EpsilonRemover::RegistratorWrapper<grammar::CNF, grammar::CNF>(EpsilonRemover::remove); grammar::GNF EpsilonRemover::remove(const grammar::GNF& origGrammar) { return origGrammar; } -auto EpsilonRemoverGNF = EpsilonRemover::RegistratorWrapper<grammar::GNF, grammar::GNF>(EpsilonRemover::getInstance(), EpsilonRemover::remove); +auto EpsilonRemoverGNF = EpsilonRemover::RegistratorWrapper<grammar::GNF, grammar::GNF>(EpsilonRemover::remove); grammar::EpsilonFreeCFG EpsilonRemover::remove(const grammar::LG& origGrammar) { return removeInternal(origGrammar); } -auto EpsilonRemoverLG = EpsilonRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::LG>(EpsilonRemover::getInstance(), EpsilonRemover::remove); +auto EpsilonRemoverLG = EpsilonRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::LG>(EpsilonRemover::remove); grammar::EpsilonFreeCFG EpsilonRemover::remove(const grammar::LeftLG& origGrammar) { return removeInternal(origGrammar); } -auto EpsilonRemoverLeftLG = EpsilonRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::LeftLG>(EpsilonRemover::getInstance(), EpsilonRemover::remove); +auto EpsilonRemoverLeftLG = EpsilonRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::LeftLG>(EpsilonRemover::remove); grammar::LeftRG EpsilonRemover::remove(const grammar::LeftRG& origGrammar) { return origGrammar; } -auto EpsilonRemoverLeftRG = EpsilonRemover::RegistratorWrapper<grammar::LeftRG, grammar::LeftRG>(EpsilonRemover::getInstance(), EpsilonRemover::remove); +auto EpsilonRemoverLeftRG = EpsilonRemover::RegistratorWrapper<grammar::LeftRG, grammar::LeftRG>(EpsilonRemover::remove); grammar::EpsilonFreeCFG EpsilonRemover::remove(const grammar::RightLG& origGrammar) { return removeInternal(origGrammar); } -auto EpsilonRemoverRightLG = EpsilonRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::RightLG>(EpsilonRemover::getInstance(), EpsilonRemover::remove); +auto EpsilonRemoverRightLG = EpsilonRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::RightLG>(EpsilonRemover::remove); grammar::RightRG EpsilonRemover::remove(const grammar::RightRG& origGrammar) { return origGrammar; } -auto EpsilonRemoverRightRG = EpsilonRemover::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(EpsilonRemover::getInstance(), EpsilonRemover::remove); +auto EpsilonRemoverRightRG = EpsilonRemover::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(EpsilonRemover::remove); grammar::Grammar EpsilonRemover::remove(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/EpsilonRemover.h b/alib2algo/src/grammar/simplify/EpsilonRemover.h index 99bd856111414228adeb123c7d0e25bc840e9989..d9593f164b38317f47d54cdcfa6eee5e8aa5eb11 100644 --- a/alib2algo/src/grammar/simplify/EpsilonRemover.h +++ b/alib2algo/src/grammar/simplify/EpsilonRemover.h @@ -28,7 +28,7 @@ namespace grammar { namespace simplify { -class EpsilonRemover : public std::SingleDispatch<grammar::Grammar, grammar::GrammarBase> { +class EpsilonRemover : public std::SingleDispatch<EpsilonRemover, grammar::Grammar, grammar::GrammarBase> { public: static grammar::Grammar remove( const grammar::Grammar & grammar ); @@ -41,11 +41,6 @@ public: static grammar::LeftRG remove( const grammar::LeftRG & grammar ); static grammar::EpsilonFreeCFG remove( const grammar::RightLG & grammar ); static grammar::RightRG remove( const grammar::RightRG & grammar ); - - static EpsilonRemover& getInstance() { - static EpsilonRemover res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/LeftRecursionRemover.cpp b/alib2algo/src/grammar/simplify/LeftRecursionRemover.cpp index f66fc5c232f387b9bc6177f8afe6b38b5ab3805b..859d53bb1d175008716351099044c1c270709ed7 100644 --- a/alib2algo/src/grammar/simplify/LeftRecursionRemover.cpp +++ b/alib2algo/src/grammar/simplify/LeftRecursionRemover.cpp @@ -126,7 +126,7 @@ grammar::EpsilonFreeCFG LeftRecursionRemover::remove(const grammar::EpsilonFreeC return step; } -auto LeftRecursionRemoverEpsilonFreeCFG = LeftRecursionRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(LeftRecursionRemover::getInstance(), LeftRecursionRemover::remove); +auto LeftRecursionRemoverEpsilonFreeCFG = LeftRecursionRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(LeftRecursionRemover::remove); grammar::EpsilonFreeCFG LeftRecursionRemover::remove(const grammar::CNF& origGrammar) { EpsilonFreeCFG tmp(origGrammar.getInitialSymbol()); @@ -146,40 +146,40 @@ grammar::EpsilonFreeCFG LeftRecursionRemover::remove(const grammar::CNF& origGra return remove(tmp); } -auto LeftRecursionRemoverCNF = LeftRecursionRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::CNF>(LeftRecursionRemover::getInstance(), LeftRecursionRemover::remove); +auto LeftRecursionRemoverCNF = LeftRecursionRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::CNF>(LeftRecursionRemover::remove); grammar::GNF LeftRecursionRemover::remove(const grammar::GNF& origGrammar) { return origGrammar; } -auto LeftRecursionRemoverGNF = LeftRecursionRemover::RegistratorWrapper<grammar::GNF, grammar::GNF>(LeftRecursionRemover::getInstance(), LeftRecursionRemover::remove); +auto LeftRecursionRemoverGNF = LeftRecursionRemover::RegistratorWrapper<grammar::GNF, grammar::GNF>(LeftRecursionRemover::remove); grammar::RightRG LeftRecursionRemover::remove(const grammar::RightRG& origGrammar) { return origGrammar; } -auto LeftRecursionRemoverRightRG = LeftRecursionRemover::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(LeftRecursionRemover::getInstance(), LeftRecursionRemover::remove); +auto LeftRecursionRemoverRightRG = LeftRecursionRemover::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(LeftRecursionRemover::remove); grammar::RightLG LeftRecursionRemover::remove(const grammar::RightLG& origGrammar) { return origGrammar; } -auto LeftRecursionRemoverRightLG = LeftRecursionRemover::RegistratorWrapper<grammar::RightLG, grammar::RightLG>(LeftRecursionRemover::getInstance(), LeftRecursionRemover::remove); +auto LeftRecursionRemoverRightLG = LeftRecursionRemover::RegistratorWrapper<grammar::RightLG, grammar::RightLG>(LeftRecursionRemover::remove); grammar::RightRG LeftRecursionRemover::remove(const grammar::LeftRG& origGrammar) { return convert::ToGrammarRightRG::convert(origGrammar); } -auto LeftRecursionRemoverLeftRG = LeftRecursionRemover::RegistratorWrapper<grammar::RightRG, grammar::LeftRG>(LeftRecursionRemover::getInstance(), LeftRecursionRemover::remove); +auto LeftRecursionRemoverLeftRG = LeftRecursionRemover::RegistratorWrapper<grammar::RightRG, grammar::LeftRG>(LeftRecursionRemover::remove); grammar::RightLG LeftRecursionRemover::remove(const grammar::LeftLG& /* origGrammar */) { throw exception::CommonException("LeftRecursionRemover: Removing from LeftLG NYI"); // TODO } -auto LeftRecursionRemoverLeftLG = LeftRecursionRemover::RegistratorWrapper<grammar::RightLG, grammar::LeftLG>(LeftRecursionRemover::getInstance(), LeftRecursionRemover::remove); +auto LeftRecursionRemoverLeftLG = LeftRecursionRemover::RegistratorWrapper<grammar::RightLG, grammar::LeftLG>(LeftRecursionRemover::remove); grammar::Grammar LeftRecursionRemover::remove(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/LeftRecursionRemover.h b/alib2algo/src/grammar/simplify/LeftRecursionRemover.h index 1d29cada43d2e48002aedb800e0b49f5b0bc038b..81f8441fb725966b4e378d30275d053ac1a2a2a8 100644 --- a/alib2algo/src/grammar/simplify/LeftRecursionRemover.h +++ b/alib2algo/src/grammar/simplify/LeftRecursionRemover.h @@ -28,7 +28,7 @@ namespace grammar { namespace simplify { -class LeftRecursionRemover : public std::SingleDispatch<grammar::Grammar, grammar::GrammarBase> { +class LeftRecursionRemover : public std::SingleDispatch<LeftRecursionRemover, grammar::Grammar, grammar::GrammarBase> { public: static grammar::Grammar remove( const grammar::Grammar & grammar ); @@ -39,11 +39,6 @@ public: static grammar::RightLG remove( const grammar::RightLG & grammar ); static grammar::RightRG remove( const grammar::LeftRG & grammar ); static grammar::RightLG remove( const grammar::LeftLG & grammar ); - - static LeftRecursionRemover& getInstance() { - static LeftRecursionRemover res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/SimpleRulesRemover.cpp b/alib2algo/src/grammar/simplify/SimpleRulesRemover.cpp index 1d161897235b8834b219e20fd7112ef7ee487ba6..5972b4e1bb6ae3ffcf09b64e23947e479e2968f4 100644 --- a/alib2algo/src/grammar/simplify/SimpleRulesRemover.cpp +++ b/alib2algo/src/grammar/simplify/SimpleRulesRemover.cpp @@ -71,58 +71,58 @@ grammar::CFG SimpleRulesRemover::remove(const grammar::CFG& origGrammar) { return removeNonEpsilonFree(origGrammar); } -auto SimpleRulesRemoverCFG = SimpleRulesRemover::RegistratorWrapper<grammar::CFG, grammar::CFG>(SimpleRulesRemover::getInstance(), SimpleRulesRemover::remove); +auto SimpleRulesRemoverCFG = SimpleRulesRemover::RegistratorWrapper<grammar::CFG, grammar::CFG>(SimpleRulesRemover::remove); grammar::EpsilonFreeCFG SimpleRulesRemover::remove(const grammar::EpsilonFreeCFG& origGrammar) { return removeEpsilonFree(origGrammar); } -auto SimpleRulesRemoverEpsilonFreeCFG = SimpleRulesRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(SimpleRulesRemover::getInstance(), SimpleRulesRemover::remove); +auto SimpleRulesRemoverEpsilonFreeCFG = SimpleRulesRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(SimpleRulesRemover::remove); grammar::CNF SimpleRulesRemover::remove(const grammar::CNF& origGrammar) { return origGrammar; } -auto SimpleRulesRemoverCNF = SimpleRulesRemover::RegistratorWrapper<grammar::CNF, grammar::CNF>(SimpleRulesRemover::getInstance(), SimpleRulesRemover::remove); +auto SimpleRulesRemoverCNF = SimpleRulesRemover::RegistratorWrapper<grammar::CNF, grammar::CNF>(SimpleRulesRemover::remove); grammar::GNF SimpleRulesRemover::remove(const grammar::GNF& origGrammar) { return origGrammar; } -auto SimpleRulesRemoverGNF = SimpleRulesRemover::RegistratorWrapper<grammar::GNF, grammar::GNF>(SimpleRulesRemover::getInstance(), SimpleRulesRemover::remove); +auto SimpleRulesRemoverGNF = SimpleRulesRemover::RegistratorWrapper<grammar::GNF, grammar::GNF>(SimpleRulesRemover::remove); grammar::LG SimpleRulesRemover::remove(const grammar::LG& origGrammar) { return removeNonEpsilonFree(origGrammar); } -auto SimpleRulesRemoverLG = SimpleRulesRemover::RegistratorWrapper<grammar::LG, grammar::LG>(SimpleRulesRemover::getInstance(), SimpleRulesRemover::remove); +auto SimpleRulesRemoverLG = SimpleRulesRemover::RegistratorWrapper<grammar::LG, grammar::LG>(SimpleRulesRemover::remove); grammar::LeftLG SimpleRulesRemover::remove(const grammar::LeftLG& origGrammar) { return removeNonEpsilonFree(origGrammar); } -auto SimpleRulesRemoverLeftLG = SimpleRulesRemover::RegistratorWrapper<grammar::LeftLG, grammar::LeftLG>(SimpleRulesRemover::getInstance(), SimpleRulesRemover::remove); +auto SimpleRulesRemoverLeftLG = SimpleRulesRemover::RegistratorWrapper<grammar::LeftLG, grammar::LeftLG>(SimpleRulesRemover::remove); grammar::LeftRG SimpleRulesRemover::remove(const grammar::LeftRG& origGrammar) { return origGrammar; } -auto SimpleRulesRemoverLeftRG = SimpleRulesRemover::RegistratorWrapper<grammar::LeftRG, grammar::LeftRG>(SimpleRulesRemover::getInstance(), SimpleRulesRemover::remove); +auto SimpleRulesRemoverLeftRG = SimpleRulesRemover::RegistratorWrapper<grammar::LeftRG, grammar::LeftRG>(SimpleRulesRemover::remove); grammar::RightLG SimpleRulesRemover::remove(const grammar::RightLG& origGrammar) { return removeNonEpsilonFree(origGrammar); } -auto SimpleRulesRemoverRightLG = SimpleRulesRemover::RegistratorWrapper<grammar::RightLG, grammar::RightLG>(SimpleRulesRemover::getInstance(), SimpleRulesRemover::remove); +auto SimpleRulesRemoverRightLG = SimpleRulesRemover::RegistratorWrapper<grammar::RightLG, grammar::RightLG>(SimpleRulesRemover::remove); grammar::RightRG SimpleRulesRemover::remove(const grammar::RightRG& origGrammar) { return origGrammar; } -auto SimpleRulesRemoverRightRG = SimpleRulesRemover::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(SimpleRulesRemover::getInstance(), SimpleRulesRemover::remove); +auto SimpleRulesRemoverRightRG = SimpleRulesRemover::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(SimpleRulesRemover::remove); grammar::Grammar SimpleRulesRemover::remove(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/SimpleRulesRemover.h b/alib2algo/src/grammar/simplify/SimpleRulesRemover.h index ee78e7a5fa83b72247c4b19f08ad546ed556d5d4..e4dcc4dc0f6d637c8f22002b6e9a0d094af5280b 100644 --- a/alib2algo/src/grammar/simplify/SimpleRulesRemover.h +++ b/alib2algo/src/grammar/simplify/SimpleRulesRemover.h @@ -28,7 +28,7 @@ namespace grammar { namespace simplify { -class SimpleRulesRemover : public std::SingleDispatch<grammar::Grammar, grammar::GrammarBase> { +class SimpleRulesRemover : public std::SingleDispatch<SimpleRulesRemover, grammar::Grammar, grammar::GrammarBase> { public: static grammar::Grammar remove( const grammar::Grammar & grammar ); @@ -41,11 +41,6 @@ public: static grammar::LeftRG remove( const grammar::LeftRG & grammar ); static grammar::RightLG remove( const grammar::RightLG & grammar ); static grammar::RightRG remove( const grammar::RightRG & grammar ); - - static SimpleRulesRemover& getInstance() { - static SimpleRulesRemover res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/ToCNF.cpp b/alib2algo/src/grammar/simplify/ToCNF.cpp index 9e32b3f8d626a3e9f6c90bad53f45733b00e4fdd..01784881c902062e0ff0b7861b2dda18f82a985f 100644 --- a/alib2algo/src/grammar/simplify/ToCNF.cpp +++ b/alib2algo/src/grammar/simplify/ToCNF.cpp @@ -121,58 +121,58 @@ grammar::CNF ToCNF::convert(const grammar::CFG& origGrammar) { return convertInternal(grammar::simplify::SimpleRulesRemover::remove(grammar::simplify::EpsilonRemover::remove(origGrammar))); } -auto ToCNFCFG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::CFG>(ToCNF::getInstance(), ToCNF::convert); +auto ToCNFCFG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::CFG>(ToCNF::convert); grammar::CNF ToCNF::convert(const grammar::EpsilonFreeCFG& origGrammar) { return convertInternal(grammar::simplify::SimpleRulesRemover::remove(origGrammar)); } -auto ToCNFEpsilonFreeCFG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::EpsilonFreeCFG>(ToCNF::getInstance(), ToCNF::convert); +auto ToCNFEpsilonFreeCFG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::EpsilonFreeCFG>(ToCNF::convert); grammar::CNF ToCNF::convert(const grammar::CNF& origGrammar) { return origGrammar; } -auto ToCNFCNF = ToCNF::RegistratorWrapper<grammar::CNF, grammar::CNF>(ToCNF::getInstance(), ToCNF::convert); +auto ToCNFCNF = ToCNF::RegistratorWrapper<grammar::CNF, grammar::CNF>(ToCNF::convert); grammar::CNF ToCNF::convert(const grammar::GNF& origGrammar) { return convertInternal(origGrammar); } -auto ToCNFGNF = ToCNF::RegistratorWrapper<grammar::CNF, grammar::GNF>(ToCNF::getInstance(), ToCNF::convert); +auto ToCNFGNF = ToCNF::RegistratorWrapper<grammar::CNF, grammar::GNF>(ToCNF::convert); grammar::CNF ToCNF::convert(const grammar::LG& origGrammar) { return convertInternal(grammar::simplify::SimpleRulesRemover::remove(grammar::simplify::EpsilonRemover::remove(origGrammar))); } -auto ToCNFLG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::LG>(ToCNF::getInstance(), ToCNF::convert); +auto ToCNFLG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::LG>(ToCNF::convert); grammar::CNF ToCNF::convert(const grammar::LeftLG& origGrammar) { return convertInternal(grammar::simplify::SimpleRulesRemover::remove(grammar::simplify::EpsilonRemover::remove(origGrammar))); } -auto ToCNFLeftLG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::LeftLG>(ToCNF::getInstance(), ToCNF::convert); +auto ToCNFLeftLG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::LeftLG>(ToCNF::convert); grammar::CNF ToCNF::convert(const grammar::LeftRG& origGrammar) { return convertInternal(origGrammar); } -auto ToCNFLeftRG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::LeftRG>(ToCNF::getInstance(), ToCNF::convert); +auto ToCNFLeftRG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::LeftRG>(ToCNF::convert); grammar::CNF ToCNF::convert(const grammar::RightLG& origGrammar) { return convertInternal(grammar::simplify::SimpleRulesRemover::remove(grammar::simplify::EpsilonRemover::remove(origGrammar))); } -auto ToCNFRightLG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::RightLG>(ToCNF::getInstance(), ToCNF::convert); +auto ToCNFRightLG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::RightLG>(ToCNF::convert); grammar::CNF ToCNF::convert(const grammar::RightRG& origGrammar) { return convertInternal(origGrammar); } -auto ToCNFRightRG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::RightRG>(ToCNF::getInstance(), ToCNF::convert); +auto ToCNFRightRG = ToCNF::RegistratorWrapper<grammar::CNF, grammar::RightRG>(ToCNF::convert); grammar::Grammar ToCNF::convert(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/ToCNF.h b/alib2algo/src/grammar/simplify/ToCNF.h index 12b43ad94629a8c4fb6088e23c3c6790d1f64b4f..34f783ddbb2f04cd56483a5523eea756a7915ce4 100644 --- a/alib2algo/src/grammar/simplify/ToCNF.h +++ b/alib2algo/src/grammar/simplify/ToCNF.h @@ -28,7 +28,7 @@ namespace grammar { namespace simplify { -class ToCNF : public std::SingleDispatch<grammar::Grammar, grammar::GrammarBase> { +class ToCNF : public std::SingleDispatch<ToCNF, grammar::Grammar, grammar::GrammarBase> { public: static grammar::Grammar convert( const grammar::Grammar & grammar ); @@ -41,11 +41,6 @@ public: static grammar::CNF convert( const grammar::LeftRG & grammar ); static grammar::CNF convert( const grammar::RightLG & grammar ); static grammar::CNF convert( const grammar::RightRG & grammar ); - - static ToCNF& getInstance() { - static ToCNF res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/ToGNF.cpp b/alib2algo/src/grammar/simplify/ToGNF.cpp index 99fd0fbddd66558f0d9c9739b1696597d2d56273..eaca2a11029ddf1388bde08243a53bbd59a59915 100644 --- a/alib2algo/src/grammar/simplify/ToGNF.cpp +++ b/alib2algo/src/grammar/simplify/ToGNF.cpp @@ -91,58 +91,58 @@ grammar::GNF ToGNF::convert(const grammar::CFG& origGrammar) { return convertInternal(grammar::simplify::SimpleRulesRemover::remove(grammar::simplify::LeftRecursionRemover::remove(grammar::simplify::EpsilonRemover::remove(origGrammar)))); } -auto ToGNFCFG = ToGNF::RegistratorWrapper<grammar::GNF, grammar::CFG>(ToGNF::getInstance(), ToGNF::convert); +auto ToGNFCFG = ToGNF::RegistratorWrapper<grammar::GNF, grammar::CFG>(ToGNF::convert); grammar::GNF ToGNF::convert(const grammar::EpsilonFreeCFG& origGrammar) { return convertInternal(grammar::simplify::SimpleRulesRemover::remove(grammar::simplify::LeftRecursionRemover::remove(origGrammar))); } -auto ToGNFEpsilonFreeCFG = ToGNF::RegistratorWrapper<grammar::GNF, grammar::EpsilonFreeCFG>(ToGNF::getInstance(), ToGNF::convert); +auto ToGNFEpsilonFreeCFG = ToGNF::RegistratorWrapper<grammar::GNF, grammar::EpsilonFreeCFG>(ToGNF::convert); grammar::GNF ToGNF::convert(const grammar::CNF& origGrammar) { return convertInternal(grammar::simplify::LeftRecursionRemover::remove(origGrammar)); } -auto ToGNFCNF = ToGNF::RegistratorWrapper<grammar::GNF, grammar::CNF>(ToGNF::getInstance(), ToGNF::convert); +auto ToGNFCNF = ToGNF::RegistratorWrapper<grammar::GNF, grammar::CNF>(ToGNF::convert); grammar::GNF ToGNF::convert(const grammar::GNF& origGrammar) { return origGrammar; } -auto ToGNFGNF = ToGNF::RegistratorWrapper<grammar::GNF, grammar::GNF>(ToGNF::getInstance(), ToGNF::convert); +auto ToGNFGNF = ToGNF::RegistratorWrapper<grammar::GNF, grammar::GNF>(ToGNF::convert); grammar::GNF ToGNF::convert(const grammar::LG& origGrammar) { return convertInternal(grammar::simplify::SimpleRulesRemover::remove(grammar::simplify::LeftRecursionRemover::remove(grammar::simplify::EpsilonRemover::remove(origGrammar)))); } -auto ToGNFLG = ToGNF::RegistratorWrapper<grammar::GNF, grammar::LG>(ToGNF::getInstance(), ToGNF::convert); +auto ToGNFLG = ToGNF::RegistratorWrapper<grammar::GNF, grammar::LG>(ToGNF::convert); grammar::GNF ToGNF::convert(const grammar::LeftLG& origGrammar) { return convertInternal(grammar::simplify::SimpleRulesRemover::remove(grammar::simplify::LeftRecursionRemover::remove(grammar::simplify::EpsilonRemover::remove(origGrammar)))); } -auto ToGNFLeftLG = ToGNF::RegistratorWrapper<grammar::GNF, grammar::LeftLG>(ToGNF::getInstance(), ToGNF::convert); +auto ToGNFLeftLG = ToGNF::RegistratorWrapper<grammar::GNF, grammar::LeftLG>(ToGNF::convert); grammar::RightRG ToGNF::convert(const grammar::LeftRG& origGrammar) { return convert::ToGrammarRightRG::convert(origGrammar); } -auto ToGNFLeftRG = ToGNF::RegistratorWrapper<grammar::RightRG, grammar::LeftRG>(ToGNF::getInstance(), ToGNF::convert); +auto ToGNFLeftRG = ToGNF::RegistratorWrapper<grammar::RightRG, grammar::LeftRG>(ToGNF::convert); grammar::GNF ToGNF::convert(const grammar::RightLG& origGrammar) { return convertInternal(grammar::simplify::SimpleRulesRemover::remove(grammar::simplify::LeftRecursionRemover::remove(grammar::simplify::EpsilonRemover::remove(origGrammar)))); } -auto ToGNFRightLG = ToGNF::RegistratorWrapper<grammar::GNF, grammar::RightLG>(ToGNF::getInstance(), ToGNF::convert); +auto ToGNFRightLG = ToGNF::RegistratorWrapper<grammar::GNF, grammar::RightLG>(ToGNF::convert); grammar::RightRG ToGNF::convert(const grammar::RightRG& origGrammar) { return origGrammar; } -auto ToGNFRightRG = ToGNF::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(ToGNF::getInstance(), ToGNF::convert); +auto ToGNFRightRG = ToGNF::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(ToGNF::convert); grammar::Grammar ToGNF::convert(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/ToGNF.h b/alib2algo/src/grammar/simplify/ToGNF.h index b61d57f47d5e77255dda77a7670b8ebf1bef6d94..5560de2f75bbefe58c113a74814a9a5c6668c242 100644 --- a/alib2algo/src/grammar/simplify/ToGNF.h +++ b/alib2algo/src/grammar/simplify/ToGNF.h @@ -28,7 +28,7 @@ namespace grammar { namespace simplify { -class ToGNF : public std::SingleDispatch<grammar::Grammar, grammar::GrammarBase> { +class ToGNF : public std::SingleDispatch<ToGNF, grammar::Grammar, grammar::GrammarBase> { public: static grammar::Grammar convert( const grammar::Grammar & grammar ); @@ -41,11 +41,6 @@ public: static grammar::RightRG convert( const grammar::LeftRG & grammar ); static grammar::GNF convert( const grammar::RightLG & grammar ); static grammar::RightRG convert( const grammar::RightRG & grammar ); - - static ToGNF& getInstance() { - static ToGNF res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/Trim.cpp b/alib2algo/src/grammar/simplify/Trim.cpp index 96ca1109e8bbc19fb22aa1a9f14a4695ab9e3f2c..51ff41fd65210aeef6af2aa18da4c5719a2a43b2 100644 --- a/alib2algo/src/grammar/simplify/Trim.cpp +++ b/alib2algo/src/grammar/simplify/Trim.cpp @@ -29,18 +29,18 @@ T Trim::trim( const T & grammar ) { return grammar::simplify::UnreachableSymbolsRemover::remove( grammar::simplify::UnproductiveSymbolsRemover::remove( grammar ) ); } -auto TrimCFG = Trim::RegistratorWrapper<grammar::CFG, grammar::CFG>(Trim::getInstance(), Trim::trim); -auto TrimEpsilonFreeCFG = Trim::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(Trim::getInstance(), Trim::trim); -auto TrimGNF = Trim::RegistratorWrapper<grammar::GNF, grammar::GNF>(Trim::getInstance(), Trim::trim); -auto TrimCNF = Trim::RegistratorWrapper<grammar::CNF, grammar::CNF>(Trim::getInstance(), Trim::trim); -auto TrimLG = Trim::RegistratorWrapper<grammar::LG, grammar::LG>(Trim::getInstance(), Trim::trim); -auto TrimLeftLG = Trim::RegistratorWrapper<grammar::LeftLG, grammar::LeftLG>(Trim::getInstance(), Trim::trim); -auto TrimLeftRG = Trim::RegistratorWrapper<grammar::LeftRG, grammar::LeftRG>(Trim::getInstance(), Trim::trim); -auto TrimRightLG = Trim::RegistratorWrapper<grammar::RightLG, grammar::RightLG>(Trim::getInstance(), Trim::trim); -auto TrimRightRG = Trim::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(Trim::getInstance(), Trim::trim); +auto TrimCFG = Trim::RegistratorWrapper<grammar::CFG, grammar::CFG>(Trim::trim); +auto TrimEpsilonFreeCFG = Trim::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(Trim::trim); +auto TrimGNF = Trim::RegistratorWrapper<grammar::GNF, grammar::GNF>(Trim::trim); +auto TrimCNF = Trim::RegistratorWrapper<grammar::CNF, grammar::CNF>(Trim::trim); +auto TrimLG = Trim::RegistratorWrapper<grammar::LG, grammar::LG>(Trim::trim); +auto TrimLeftLG = Trim::RegistratorWrapper<grammar::LeftLG, grammar::LeftLG>(Trim::trim); +auto TrimLeftRG = Trim::RegistratorWrapper<grammar::LeftRG, grammar::LeftRG>(Trim::trim); +auto TrimRightLG = Trim::RegistratorWrapper<grammar::RightLG, grammar::RightLG>(Trim::trim); +auto TrimRightRG = Trim::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(Trim::trim); grammar::Grammar Trim::trim(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/Trim.h b/alib2algo/src/grammar/simplify/Trim.h index 390e4a5b6ecdcb5c65dcb7a47e408e709e7978e1..f202a802c15d9a3cce3af75fbf63747b882b02ca 100644 --- a/alib2algo/src/grammar/simplify/Trim.h +++ b/alib2algo/src/grammar/simplify/Trim.h @@ -18,7 +18,7 @@ namespace simplify { /** * Implements algorithms from Melichar, chapter 3.3 */ -class Trim : public std::SingleDispatch<grammar::Grammar, grammar::GrammarBase> { +class Trim : public std::SingleDispatch<Trim, grammar::Grammar, grammar::GrammarBase> { public: static grammar::Grammar trim( const grammar::Grammar & grammar ); @@ -27,11 +27,6 @@ public: */ template<class T> static T trim( const T & grammar ); - - static Trim& getInstance() { - static Trim res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.cpp b/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.cpp index 0fd8fbd7731ac6b817782f78ce7dbd2fe7bc2d09..347cef0f08e3fb694ef2dd63cc9d48cc1acac495 100644 --- a/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.cpp +++ b/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.cpp @@ -60,18 +60,18 @@ T UnproductiveSymbolsRemover::remove( const T & grammar ) { return ret; } -auto UnproductiveSymbolsRemoverCFG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::CFG, grammar::CFG>(UnproductiveSymbolsRemover::getInstance(), UnproductiveSymbolsRemover::remove); -auto UnproductiveSymbolsRemoverEpsilonFreeCFG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(UnproductiveSymbolsRemover::getInstance(), UnproductiveSymbolsRemover::remove); -auto UnproductiveSymbolsRemoverGNF = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::GNF, grammar::GNF>(UnproductiveSymbolsRemover::getInstance(), UnproductiveSymbolsRemover::remove); -auto UnproductiveSymbolsRemoverCNF = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::CNF, grammar::CNF>(UnproductiveSymbolsRemover::getInstance(), UnproductiveSymbolsRemover::remove); -auto UnproductiveSymbolsRemoverLG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::LG, grammar::LG>(UnproductiveSymbolsRemover::getInstance(), UnproductiveSymbolsRemover::remove); -auto UnproductiveSymbolsRemoverLeftLG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::LeftLG, grammar::LeftLG>(UnproductiveSymbolsRemover::getInstance(), UnproductiveSymbolsRemover::remove); -auto UnproductiveSymbolsRemoverLeftRG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::LeftRG, grammar::LeftRG>(UnproductiveSymbolsRemover::getInstance(), UnproductiveSymbolsRemover::remove); -auto UnproductiveSymbolsRemoverRightLG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::RightLG, grammar::RightLG>(UnproductiveSymbolsRemover::getInstance(), UnproductiveSymbolsRemover::remove); -auto UnproductiveSymbolsRemoverRightRG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(UnproductiveSymbolsRemover::getInstance(), UnproductiveSymbolsRemover::remove); +auto UnproductiveSymbolsRemoverCFG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::CFG, grammar::CFG>(UnproductiveSymbolsRemover::remove); +auto UnproductiveSymbolsRemoverEpsilonFreeCFG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(UnproductiveSymbolsRemover::remove); +auto UnproductiveSymbolsRemoverGNF = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::GNF, grammar::GNF>(UnproductiveSymbolsRemover::remove); +auto UnproductiveSymbolsRemoverCNF = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::CNF, grammar::CNF>(UnproductiveSymbolsRemover::remove); +auto UnproductiveSymbolsRemoverLG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::LG, grammar::LG>(UnproductiveSymbolsRemover::remove); +auto UnproductiveSymbolsRemoverLeftLG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::LeftLG, grammar::LeftLG>(UnproductiveSymbolsRemover::remove); +auto UnproductiveSymbolsRemoverLeftRG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::LeftRG, grammar::LeftRG>(UnproductiveSymbolsRemover::remove); +auto UnproductiveSymbolsRemoverRightLG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::RightLG, grammar::RightLG>(UnproductiveSymbolsRemover::remove); +auto UnproductiveSymbolsRemoverRightRG = UnproductiveSymbolsRemover::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(UnproductiveSymbolsRemover::remove); grammar::Grammar UnproductiveSymbolsRemover::remove(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.h b/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.h index c368d5414dbc21c6912c8d7681625af6e2002860..5e5ac35f40660fac13f59fe526fc9d8818651ffb 100644 --- a/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.h +++ b/alib2algo/src/grammar/simplify/UnproductiveSymbolsRemover.h @@ -18,7 +18,7 @@ namespace simplify { /** * Implements algorithms from Melichar, chapter 3.3 */ -class UnproductiveSymbolsRemover : public std::SingleDispatch<grammar::Grammar, grammar::GrammarBase> { +class UnproductiveSymbolsRemover : public std::SingleDispatch<UnproductiveSymbolsRemover, grammar::Grammar, grammar::GrammarBase> { public: static grammar::Grammar remove( const grammar::Grammar & automaton ); @@ -27,11 +27,6 @@ public: */ template<class T> static T remove( const T & grammar ); - - static UnproductiveSymbolsRemover& getInstance() { - static UnproductiveSymbolsRemover res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.cpp b/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.cpp index ff6fb77601e583df589325fa36f566a125c67703..a66909439f1c36944cc74970909f278a805949e7 100644 --- a/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.cpp +++ b/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.cpp @@ -59,18 +59,18 @@ T UnreachableSymbolsRemover::remove( const T & grammar) { return ret; } -auto UnreachableSymbolsRemoverCFG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::CFG, grammar::CFG>(UnreachableSymbolsRemover::getInstance(), UnreachableSymbolsRemover::remove); -auto UnreachableSymbolsRemoverEpsilonFreeCFG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(UnreachableSymbolsRemover::getInstance(), UnreachableSymbolsRemover::remove); -auto UnreachableSymbolsRemoverGNF = UnreachableSymbolsRemover::RegistratorWrapper<grammar::GNF, grammar::GNF>(UnreachableSymbolsRemover::getInstance(), UnreachableSymbolsRemover::remove); -auto UnreachableSymbolsRemoverCNF = UnreachableSymbolsRemover::RegistratorWrapper<grammar::CNF, grammar::CNF>(UnreachableSymbolsRemover::getInstance(), UnreachableSymbolsRemover::remove); -auto UnreachableSymbolsRemoverLG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::LG, grammar::LG>(UnreachableSymbolsRemover::getInstance(), UnreachableSymbolsRemover::remove); -auto UnreachableSymbolsRemoverLeftLG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::LeftLG, grammar::LeftLG>(UnreachableSymbolsRemover::getInstance(), UnreachableSymbolsRemover::remove); -auto UnreachableSymbolsRemoverLeftRG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::LeftRG, grammar::LeftRG>(UnreachableSymbolsRemover::getInstance(), UnreachableSymbolsRemover::remove); -auto UnreachableSymbolsRemoverRightLG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::RightLG, grammar::RightLG>(UnreachableSymbolsRemover::getInstance(), UnreachableSymbolsRemover::remove); -auto UnreachableSymbolsRemoverRightRG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(UnreachableSymbolsRemover::getInstance(), UnreachableSymbolsRemover::remove); +auto UnreachableSymbolsRemoverCFG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::CFG, grammar::CFG>(UnreachableSymbolsRemover::remove); +auto UnreachableSymbolsRemoverEpsilonFreeCFG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::EpsilonFreeCFG, grammar::EpsilonFreeCFG>(UnreachableSymbolsRemover::remove); +auto UnreachableSymbolsRemoverGNF = UnreachableSymbolsRemover::RegistratorWrapper<grammar::GNF, grammar::GNF>(UnreachableSymbolsRemover::remove); +auto UnreachableSymbolsRemoverCNF = UnreachableSymbolsRemover::RegistratorWrapper<grammar::CNF, grammar::CNF>(UnreachableSymbolsRemover::remove); +auto UnreachableSymbolsRemoverLG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::LG, grammar::LG>(UnreachableSymbolsRemover::remove); +auto UnreachableSymbolsRemoverLeftLG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::LeftLG, grammar::LeftLG>(UnreachableSymbolsRemover::remove); +auto UnreachableSymbolsRemoverLeftRG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::LeftRG, grammar::LeftRG>(UnreachableSymbolsRemover::remove); +auto UnreachableSymbolsRemoverRightLG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::RightLG, grammar::RightLG>(UnreachableSymbolsRemover::remove); +auto UnreachableSymbolsRemoverRightRG = UnreachableSymbolsRemover::RegistratorWrapper<grammar::RightRG, grammar::RightRG>(UnreachableSymbolsRemover::remove); grammar::Grammar UnreachableSymbolsRemover::remove(const grammar::Grammar& grammar) { - return getInstance().dispatch(grammar.getData()); + return dispatch(grammar.getData()); } } /* namespace simplify */ diff --git a/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h b/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h index 79445806d313b1fc4068c5483ba5e5be56227f9b..226fcd19b523f5d596a1ed895b6f058b3ec4e733 100644 --- a/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h +++ b/alib2algo/src/grammar/simplify/UnreachableSymbolsRemover.h @@ -18,7 +18,7 @@ namespace simplify { /** * Implements algorithms from Melichar, chapter 3.3 */ -class UnreachableSymbolsRemover : public std::SingleDispatch<grammar::Grammar, grammar::GrammarBase> { +class UnreachableSymbolsRemover : public std::SingleDispatch<UnreachableSymbolsRemover, grammar::Grammar, grammar::GrammarBase> { public: static grammar::Grammar remove( const grammar::Grammar & automaton ); @@ -27,11 +27,6 @@ public: */ template<class T> static T remove( const T & grammar ); - - static UnreachableSymbolsRemover& getInstance() { - static UnreachableSymbolsRemover res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/graph/embedding/HopcroftTarjan.cpp b/alib2algo/src/graph/embedding/HopcroftTarjan.cpp index 510a841cb76bff0fe08802837bf73ac855a8f8b3..c3591c7cff60357b4e5b0caf19164be604c2ca2d 100644 --- a/alib2algo/src/graph/embedding/HopcroftTarjan.cpp +++ b/alib2algo/src/graph/embedding/HopcroftTarjan.cpp @@ -641,7 +641,7 @@ bool PLANAR(graph &G, bool embed, HopcroftTarjan::Result &res) HopcroftTarjan::Result HopcroftTarjan::hopcrofttarjan(const Graph &graph) { - return getInstance().dispatch(graph.getData()); + return dispatch(graph.getData()); } HopcroftTarjan::Result HopcroftTarjan::hopcrofttarjan(const DirectedGraph &graph) diff --git a/alib2algo/src/graph/embedding/HopcroftTarjan.h b/alib2algo/src/graph/embedding/HopcroftTarjan.h index 7b94cbe73d9bce2a946e661e475bde58acc1d60d..859acf4ea14fafa5ea23138c4051ccdd4deea891 100644 --- a/alib2algo/src/graph/embedding/HopcroftTarjan.h +++ b/alib2algo/src/graph/embedding/HopcroftTarjan.h @@ -14,7 +14,7 @@ namespace embedding { // Computes combinatorial embedding of bidirected biconnected simple planar graph -class HopcroftTarjan : public std::SingleDispatch<std::unordered_map<Node, std::vector<Node>>, graph::GraphBase> +class HopcroftTarjan : public std::SingleDispatch<HopcroftTarjan, std::unordered_map<Node, std::vector<Node>>, graph::GraphBase> { public: typedef std::unordered_map<Node, std::vector<Node>> Result; @@ -23,11 +23,6 @@ public: static Result hopcrofttarjan(const DirectedGraph &graph); static Result hopcrofttarjan(const UndirectedGraph &graph); - - static HopcroftTarjan &getInstance() { - static HopcroftTarjan res; - return res; - } }; } // namespace embedding diff --git a/alib2algo/src/graph/shortestpath/BellmanFord.cpp b/alib2algo/src/graph/shortestpath/BellmanFord.cpp index 96a45e1d98f715ec23533e9b2ab2f23306ebc07d..7fa75d2b8fd5f0716c31a57fb2791f37cafb03e6 100644 --- a/alib2algo/src/graph/shortestpath/BellmanFord.cpp +++ b/alib2algo/src/graph/shortestpath/BellmanFord.cpp @@ -104,7 +104,7 @@ static BellmanFord::Result bellmanford_impl(const UndirectedGraph &graph, const BellmanFord::Result BellmanFord::bellmanford(const Graph &graph, const Node &start) { - return getInstance().dispatch(graph.getData(), start); + return dispatch(graph.getData(), start); } BellmanFord::Result BellmanFord::bellmanford(const DirectedGraph &graph, const Node &start) @@ -112,14 +112,14 @@ BellmanFord::Result BellmanFord::bellmanford(const DirectedGraph &graph, const N return bellmanford_impl(graph, start); } -auto BellmanFordDirectedGraph = BellmanFord::RegistratorWrapper<BellmanFord::Result, graph::DirectedGraph>(BellmanFord::getInstance(), BellmanFord::bellmanford); +auto BellmanFordDirectedGraph = BellmanFord::RegistratorWrapper<BellmanFord::Result, graph::DirectedGraph>(BellmanFord::bellmanford); BellmanFord::Result BellmanFord::bellmanford(const UndirectedGraph &graph, const Node &start) { return bellmanford_impl(graph, start); } -auto BellmanFordUndirectedGraph = BellmanFord::RegistratorWrapper<BellmanFord::Result, graph::UndirectedGraph>(BellmanFord::getInstance(), BellmanFord::bellmanford); +auto BellmanFordUndirectedGraph = BellmanFord::RegistratorWrapper<BellmanFord::Result, graph::UndirectedGraph>(BellmanFord::bellmanford); } // namespace shortestpath diff --git a/alib2algo/src/graph/shortestpath/BellmanFord.h b/alib2algo/src/graph/shortestpath/BellmanFord.h index 652bcfceab0a48bd4fca0412ba2a3c77414db79a..c94a735da07ddb6f15ce2f64d367173303c49801 100644 --- a/alib2algo/src/graph/shortestpath/BellmanFord.h +++ b/alib2algo/src/graph/shortestpath/BellmanFord.h @@ -17,7 +17,7 @@ namespace shortestpath { // // note: negative-weight undirected edge = negative-weight cycle -class BellmanFord : public std::SingleDispatchLastStaticParam<std::unordered_map<Node, int>, graph::GraphBase, const Node&> { +class BellmanFord : public std::SingleDispatchLastStaticParam<BellmanFord, std::unordered_map<Node, int>, graph::GraphBase, const Node&> { public: typedef std::unordered_map<Node, int> Result; @@ -25,11 +25,6 @@ public: static Result bellmanford(const DirectedGraph &graph, const Node &start); static Result bellmanford(const UndirectedGraph &graph, const Node &start); - - static BellmanFord& getInstance() { - static BellmanFord res; - return res; - } }; } // namespace shortestpath diff --git a/alib2algo/src/graph/shortestpath/Dijkstra.cpp b/alib2algo/src/graph/shortestpath/Dijkstra.cpp index 855f9080dc1b262e5730163d4c129de6b95455f0..06dfc0627cf840a2a19dc042f7081aa7735ec712 100644 --- a/alib2algo/src/graph/shortestpath/Dijkstra.cpp +++ b/alib2algo/src/graph/shortestpath/Dijkstra.cpp @@ -120,7 +120,7 @@ static Dijkstra::Result dijkstra_impl(const T &graph, const Node &start) Dijkstra::Result Dijkstra::dijkstra(const Graph &graph, const Node &start) { - return getInstance().dispatch(graph.getData(), start); + return dispatch(graph.getData(), start); } Dijkstra::Result Dijkstra::dijkstra(const DirectedGraph &graph, const Node &start) @@ -128,14 +128,14 @@ Dijkstra::Result Dijkstra::dijkstra(const DirectedGraph &graph, const Node &star return dijkstra_impl(graph, start); } -auto DijkstraDirectedGraph = Dijkstra::RegistratorWrapper<Dijkstra::Result, graph::DirectedGraph>(Dijkstra::getInstance(), Dijkstra::dijkstra); +auto DijkstraDirectedGraph = Dijkstra::RegistratorWrapper<Dijkstra::Result, graph::DirectedGraph>(Dijkstra::dijkstra); Dijkstra::Result Dijkstra::dijkstra(const UndirectedGraph &graph, const Node &start) { return dijkstra_impl(graph, start); } -auto DijkstraUndirectedGraph = Dijkstra::RegistratorWrapper<Dijkstra::Result, graph::UndirectedGraph>(Dijkstra::getInstance(), Dijkstra::dijkstra); +auto DijkstraUndirectedGraph = Dijkstra::RegistratorWrapper<Dijkstra::Result, graph::UndirectedGraph>(Dijkstra::dijkstra); } // namespace shortestpath diff --git a/alib2algo/src/graph/shortestpath/Dijkstra.h b/alib2algo/src/graph/shortestpath/Dijkstra.h index c58fd73d3e0420d130e7cc4022a9933a32605654..b3bdcbc6609b8f8e36c393824edf33dc7b427b26 100644 --- a/alib2algo/src/graph/shortestpath/Dijkstra.h +++ b/alib2algo/src/graph/shortestpath/Dijkstra.h @@ -14,7 +14,7 @@ namespace shortestpath { // Dijkstra only works on graphs without negative-weight edges (>= 0) -class Dijkstra : public std::SingleDispatchLastStaticParam<std::unordered_map<Node, int>, graph::GraphBase, const Node&> { +class Dijkstra : public std::SingleDispatchLastStaticParam<Dijkstra, std::unordered_map<Node, int>, graph::GraphBase, const Node&> { public: typedef std::unordered_map<Node, int> Result; @@ -22,11 +22,6 @@ public: static Result dijkstra(const DirectedGraph &graph, const Node &start); static Result dijkstra(const UndirectedGraph &graph, const Node &start); - - static Dijkstra& getInstance() { - static Dijkstra res; - return res; - } }; } // namespace shortestpath diff --git a/alib2algo/src/graph/shortestpath/FloydWarshall.cpp b/alib2algo/src/graph/shortestpath/FloydWarshall.cpp index a6ea765e20ffca5452df6f6639994076e23a3ffb..2f35ed637f7060ace94dcca04fa4653b32667bf8 100644 --- a/alib2algo/src/graph/shortestpath/FloydWarshall.cpp +++ b/alib2algo/src/graph/shortestpath/FloydWarshall.cpp @@ -59,7 +59,7 @@ static FloydWarshall::Result floydwarshall_impl(const T &graph) FloydWarshall::Result FloydWarshall::floydwarshall(const Graph &graph) { - return getInstance().dispatch(graph.getData()); + return dispatch(graph.getData()); } FloydWarshall::Result FloydWarshall::floydwarshall(const DirectedGraph &graph) @@ -67,14 +67,14 @@ FloydWarshall::Result FloydWarshall::floydwarshall(const DirectedGraph &graph) return floydwarshall_impl(graph); } -auto FloydWarshallDirectedGraph = FloydWarshall::RegistratorWrapper<FloydWarshall::Result, graph::DirectedGraph>(FloydWarshall::getInstance(), FloydWarshall::floydwarshall); +auto FloydWarshallDirectedGraph = FloydWarshall::RegistratorWrapper<FloydWarshall::Result, graph::DirectedGraph>(FloydWarshall::floydwarshall); FloydWarshall::Result FloydWarshall::floydwarshall(const UndirectedGraph &graph) { return floydwarshall_impl(graph); } -auto FloydWarshallUndirectedGraph = FloydWarshall::RegistratorWrapper<FloydWarshall::Result, graph::UndirectedGraph>(FloydWarshall::getInstance(), FloydWarshall::floydwarshall); +auto FloydWarshallUndirectedGraph = FloydWarshall::RegistratorWrapper<FloydWarshall::Result, graph::UndirectedGraph>(FloydWarshall::floydwarshall); } // namespace shortestpath diff --git a/alib2algo/src/graph/shortestpath/FloydWarshall.h b/alib2algo/src/graph/shortestpath/FloydWarshall.h index b5c4df159c34c516082eba4fdc980a67c6b0a3d3..92dc8099de01dba429562df20d572ae895cfcae0 100644 --- a/alib2algo/src/graph/shortestpath/FloydWarshall.h +++ b/alib2algo/src/graph/shortestpath/FloydWarshall.h @@ -18,7 +18,7 @@ namespace shortestpath { // note: negative-weight undirected edge = negative-weight cycle // note: std::numeric_limits<int>::max() is used as infinity -class FloydWarshall : public std::SingleDispatch<std::unordered_map<Node, std::unordered_map<Node, int>>, graph::GraphBase> { +class FloydWarshall : public std::SingleDispatch<FloydWarshall, std::unordered_map<Node, std::unordered_map<Node, int>>, graph::GraphBase> { public: typedef std::unordered_map<Node, std::unordered_map<Node, int>> Result; @@ -26,11 +26,6 @@ public: static Result floydwarshall(const DirectedGraph &graph); static Result floydwarshall(const UndirectedGraph &graph); - - static FloydWarshall& getInstance() { - static FloydWarshall res; - return res; - } }; } // namespace shortestpath diff --git a/alib2algo/src/graph/sort/TopologicalSort.cpp b/alib2algo/src/graph/sort/TopologicalSort.cpp index c5f49b5686377bf46456b4c1bf1996ad634dd49f..faeed17d0b3a8ea7d153333493e2b392f806c369 100644 --- a/alib2algo/src/graph/sort/TopologicalSort.cpp +++ b/alib2algo/src/graph/sort/TopologicalSort.cpp @@ -24,14 +24,14 @@ static TopologicalSort::Result topsort_impl(const DirectedGraph &graph) { } TopologicalSort::Result TopologicalSort::topologicalsort(const Graph &graph) { - return getInstance().dispatch(graph.getData()); + return dispatch(graph.getData()); } TopologicalSort::Result TopologicalSort::topologicalsort(const DirectedGraph &graph) { return topsort_impl(graph); } -auto TopologicalSortDirectedGraph = TopologicalSort::RegistratorWrapper<TopologicalSort::Result, graph::DirectedGraph>(TopologicalSort::getInstance(), TopologicalSort::topologicalsort); +auto TopologicalSortDirectedGraph = TopologicalSort::RegistratorWrapper<TopologicalSort::Result, graph::DirectedGraph>(TopologicalSort::topologicalsort); } // namespace sort diff --git a/alib2algo/src/graph/sort/TopologicalSort.h b/alib2algo/src/graph/sort/TopologicalSort.h index 99177037c7edf2219d379c957bd04b5cefacfb44..5332cf87f16f6eeb8532aab8d0e0d1e581e98241 100644 --- a/alib2algo/src/graph/sort/TopologicalSort.h +++ b/alib2algo/src/graph/sort/TopologicalSort.h @@ -12,18 +12,13 @@ namespace graph { namespace sort { -class TopologicalSort : public std::SingleDispatch<std::list<Node>, graph::GraphBase> { +class TopologicalSort : public std::SingleDispatch<TopologicalSort, std::list<Node>, graph::GraphBase> { public: typedef std::list<Node> Result; static Result topologicalsort(const Graph &graph); static Result topologicalsort(const DirectedGraph &graph); - - static TopologicalSort& getInstance() { - static TopologicalSort res; - return res; - } }; } // namespace sort diff --git a/alib2algo/src/graph/spanningtree/JarnikPrim.cpp b/alib2algo/src/graph/spanningtree/JarnikPrim.cpp index 8a85cc98bd554f7f02de7edd220590426de13ecb..4dfedd082a8f389466bc37a26c371a18ca0cc215 100644 --- a/alib2algo/src/graph/spanningtree/JarnikPrim.cpp +++ b/alib2algo/src/graph/spanningtree/JarnikPrim.cpp @@ -94,14 +94,14 @@ static UndirectedGraph jarnikprim_impl(const UndirectedGraph &graph, const Node } Graph JarnikPrim::jarnikprim(const Graph &graph, const Node &start) { - return getInstance().dispatch(graph.getData(), start); + return dispatch(graph.getData(), start); } UndirectedGraph JarnikPrim::jarnikprim(const UndirectedGraph &graph, const Node &start) { return jarnikprim_impl(graph, start); } -auto JarnikPrimUndirectedGraph = JarnikPrim::RegistratorWrapper<graph::UndirectedGraph, graph::UndirectedGraph>(JarnikPrim::getInstance(), JarnikPrim::jarnikprim); +auto JarnikPrimUndirectedGraph = JarnikPrim::RegistratorWrapper<graph::UndirectedGraph, graph::UndirectedGraph>(JarnikPrim::jarnikprim); } // namespace spanningtree diff --git a/alib2algo/src/graph/spanningtree/JarnikPrim.h b/alib2algo/src/graph/spanningtree/JarnikPrim.h index 8ab0b1ecac0153e4cada240aed9d8646bc782788..4b695e1c61265965fc0f472a14a5d3d99603c3b3 100644 --- a/alib2algo/src/graph/spanningtree/JarnikPrim.h +++ b/alib2algo/src/graph/spanningtree/JarnikPrim.h @@ -10,16 +10,11 @@ namespace graph { namespace spanningtree { -class JarnikPrim : public std::SingleDispatchLastStaticParam<graph::Graph, graph::GraphBase, const Node&> { +class JarnikPrim : public std::SingleDispatchLastStaticParam<JarnikPrim, graph::Graph, graph::GraphBase, const Node&> { public: static Graph jarnikprim(const Graph &graph, const Node &start); static UndirectedGraph jarnikprim(const UndirectedGraph &graph, const Node &start); - - static JarnikPrim& getInstance() { - static JarnikPrim res; - return res; - } }; } // namespace spanningtree diff --git a/alib2algo/src/regexp/convert/ToAutomaton.cpp b/alib2algo/src/regexp/convert/ToAutomaton.cpp index 562997d84f1bda8a4bb90a094a643205b392eaa1..d8b58eefd2987093157530bff29cb536c103b6a4 100644 --- a/alib2algo/src/regexp/convert/ToAutomaton.cpp +++ b/alib2algo/src/regexp/convert/ToAutomaton.cpp @@ -13,20 +13,20 @@ namespace regexp { namespace convert { automaton::Automaton ToAutomaton::convert(const regexp::RegExp& regexp) { - return getInstance().dispatch(regexp.getData()); + return dispatch(regexp.getData()); } automaton::Automaton ToAutomaton::convert(const regexp::FormalRegExp& regexp) { return automaton::Automaton(ToAutomatonGlushkov::convert(regexp)); } -auto ToAutomatonFormalRegExp = ToAutomaton::RegistratorWrapper<automaton::Automaton, regexp::FormalRegExp>(ToAutomaton::getInstance(), ToAutomaton::convert); +auto ToAutomatonFormalRegExp = ToAutomaton::RegistratorWrapper<automaton::Automaton, regexp::FormalRegExp>(ToAutomaton::convert); automaton::Automaton ToAutomaton::convert(const regexp::UnboundedRegExp& regexp) { return automaton::Automaton(ToAutomatonGlushkov::convert(regexp)); } -auto ToAutomatonUnboundedRegExp = ToAutomaton::RegistratorWrapper<automaton::Automaton, regexp::UnboundedRegExp>(ToAutomaton::getInstance(), ToAutomaton::convert); +auto ToAutomatonUnboundedRegExp = ToAutomaton::RegistratorWrapper<automaton::Automaton, regexp::UnboundedRegExp>( ToAutomaton::convert); } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToAutomaton.h b/alib2algo/src/regexp/convert/ToAutomaton.h index 81588b21afc711a76dd8d286f19016394c43c46e..a182d29e307d85098218bd7fd221522ea07c806e 100644 --- a/alib2algo/src/regexp/convert/ToAutomaton.h +++ b/alib2algo/src/regexp/convert/ToAutomaton.h @@ -20,7 +20,7 @@ namespace regexp { namespace convert { -class ToAutomaton : public std::SingleDispatch<automaton::Automaton, regexp::RegExpBase> { +class ToAutomaton : public std::SingleDispatch<ToAutomaton, automaton::Automaton, regexp::RegExpBase> { public: /** * Performs conversion. @@ -31,10 +31,6 @@ public: static automaton::Automaton convert(const regexp::FormalRegExp& regexp); static automaton::Automaton convert(const regexp::UnboundedRegExp& regexp); - static ToAutomaton& getInstance() { - static ToAutomaton res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToAutomatonDerivation.cpp b/alib2algo/src/regexp/convert/ToAutomatonDerivation.cpp index 92c6f35c66e2a4bacec028a9b8a3a66721fa9a88..772eb7e3057c39d309a91398ef490b82c5aaefca 100644 --- a/alib2algo/src/regexp/convert/ToAutomatonDerivation.cpp +++ b/alib2algo/src/regexp/convert/ToAutomatonDerivation.cpp @@ -24,7 +24,7 @@ namespace regexp { namespace convert { automaton::DFA ToAutomatonDerivation::convert(const regexp::RegExp& regexp) { - return getInstance().dispatch(regexp.getData()); + return dispatch(regexp.getData()); } template<class T> @@ -101,8 +101,8 @@ automaton::DFA ToAutomatonDerivation::convert(const T& regexp) { return automaton; } -auto ToAutomatonDerivationFormalRegExp = ToAutomatonDerivation::RegistratorWrapper<automaton::DFA, regexp::FormalRegExp>(ToAutomatonDerivation::getInstance(), ToAutomatonDerivation::convert); -auto ToAutomatonDerivationUnboundedRegExp = ToAutomatonDerivation::RegistratorWrapper<automaton::DFA, regexp::UnboundedRegExp>(ToAutomatonDerivation::getInstance(), ToAutomatonDerivation::convert); +auto ToAutomatonDerivationFormalRegExp = ToAutomatonDerivation::RegistratorWrapper<automaton::DFA, regexp::FormalRegExp>( ToAutomatonDerivation::convert); +auto ToAutomatonDerivationUnboundedRegExp = ToAutomatonDerivation::RegistratorWrapper<automaton::DFA, regexp::UnboundedRegExp>( ToAutomatonDerivation::convert); } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToAutomatonDerivation.h b/alib2algo/src/regexp/convert/ToAutomatonDerivation.h index a030d076f23fad32c0b57eec112518daee01a2e4..516be2e74a3af618006fb4422259929a41629237 100644 --- a/alib2algo/src/regexp/convert/ToAutomatonDerivation.h +++ b/alib2algo/src/regexp/convert/ToAutomatonDerivation.h @@ -24,7 +24,7 @@ namespace convert { * Converts regular expression to finite automaton using BrzozowskiDerivation algorithm (derivations of regular expressions). * Source: Melichar 2.110 */ -class ToAutomatonDerivation : public std::SingleDispatch<automaton::DFA, regexp::RegExpBase> { +class ToAutomatonDerivation : public std::SingleDispatch<ToAutomatonDerivation, automaton::DFA, regexp::RegExpBase> { public: /** * Performs conversion. @@ -34,11 +34,6 @@ public: template<class T> static automaton::DFA convert(const T& regexp); - - static ToAutomatonDerivation& getInstance() { - static ToAutomatonDerivation res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToAutomatonGlushkov.cpp b/alib2algo/src/regexp/convert/ToAutomatonGlushkov.cpp index cc07ddbd44f13623bf630acfc0f99dd3f40c0bb6..9cf17b3d950570d8d404dc76020071b6294f9438 100644 --- a/alib2algo/src/regexp/convert/ToAutomatonGlushkov.cpp +++ b/alib2algo/src/regexp/convert/ToAutomatonGlushkov.cpp @@ -26,7 +26,7 @@ namespace regexp { namespace convert { automaton::NFA ToAutomatonGlushkov::convert(const regexp::RegExp& regexp) { - return getInstance().dispatch(regexp.getData()); + return dispatch(regexp.getData()); } automaton::NFA ToAutomatonGlushkov::convert(const regexp::UnboundedRegExp& regexp) { @@ -82,14 +82,14 @@ automaton::NFA ToAutomatonGlushkov::convert(const regexp::UnboundedRegExp& regex return automaton; } -auto ToAutomatonGlushkovUnboundedRegExp = ToAutomatonGlushkov::RegistratorWrapper<automaton::NFA, regexp::UnboundedRegExp>(ToAutomatonGlushkov::getInstance(), ToAutomatonGlushkov::convert); +auto ToAutomatonGlushkovUnboundedRegExp = ToAutomatonGlushkov::RegistratorWrapper<automaton::NFA, regexp::UnboundedRegExp>( ToAutomatonGlushkov::convert); automaton::NFA ToAutomatonGlushkov::convert(const regexp::FormalRegExp& /* regexp */) { throw exception::CommonException("Glushkov: Converting FormalRegExp NYI"); // TODO } -auto ToAutomatonGlushkovFormalRegExp = ToAutomatonGlushkov::RegistratorWrapper<automaton::NFA, regexp::FormalRegExp>(ToAutomatonGlushkov::getInstance(), ToAutomatonGlushkov::convert); +auto ToAutomatonGlushkovFormalRegExp = ToAutomatonGlushkov::RegistratorWrapper<automaton::NFA, regexp::FormalRegExp>(ToAutomatonGlushkov::convert); } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToAutomatonGlushkov.h b/alib2algo/src/regexp/convert/ToAutomatonGlushkov.h index df2dca05c88416a0e46a31f0bef6299ccf481a38..f1448081413ed5c59660293a07dc383198744a33 100644 --- a/alib2algo/src/regexp/convert/ToAutomatonGlushkov.h +++ b/alib2algo/src/regexp/convert/ToAutomatonGlushkov.h @@ -24,7 +24,7 @@ namespace convert { * Converts regular expression to finite automaton using Glushkov's NFA construction algorithm. * Source: Melichar 2.107 */ -class ToAutomatonGlushkov : public std::SingleDispatch<automaton::NFA, regexp::RegExpBase> { +class ToAutomatonGlushkov : public std::SingleDispatch<ToAutomatonGlushkov, automaton::NFA, regexp::RegExpBase> { public: /** * Performs conversion. @@ -36,10 +36,6 @@ public: static automaton::NFA convert(const regexp::UnboundedRegExp& re); static automaton::NFA convert(const regexp::FormalRegExp& re); - static ToAutomatonGlushkov& getInstance() { - static ToAutomatonGlushkov res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp b/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp index 4c731479ffaaff6acad88b10e8d582ff142f21a2..af32b3cbc7e6b831027fd7e8a421c91e069097c4 100644 --- a/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp +++ b/alib2algo/src/regexp/convert/ToAutomatonThompson.cpp @@ -14,7 +14,7 @@ namespace regexp { namespace convert { automaton::EpsilonNFA ToAutomatonThompson::convert(const regexp::RegExp& regexp) { - return getInstance().dispatch(regexp.getData()); + return dispatch(regexp.getData()); } template<class T> @@ -35,8 +35,8 @@ automaton::EpsilonNFA ToAutomatonThompson::convert(const T& regexp) { return automaton; } -auto ToAutomatonThompsonFormalRegExp = ToAutomatonThompson::RegistratorWrapper<automaton::EpsilonNFA, regexp::FormalRegExp>(ToAutomatonThompson::getInstance(), ToAutomatonThompson::convert); -auto ToAutomatonThompsonUnboundedRegExp = ToAutomatonThompson::RegistratorWrapper<automaton::EpsilonNFA, regexp::UnboundedRegExp>(ToAutomatonThompson::getInstance(), ToAutomatonThompson::convert); +auto ToAutomatonThompsonFormalRegExp = ToAutomatonThompson::RegistratorWrapper<automaton::EpsilonNFA, regexp::FormalRegExp>(ToAutomatonThompson::convert); +auto ToAutomatonThompsonUnboundedRegExp = ToAutomatonThompson::RegistratorWrapper<automaton::EpsilonNFA, regexp::UnboundedRegExp>(ToAutomatonThompson::convert); // ---------------------------------------------------------------------------- diff --git a/alib2algo/src/regexp/convert/ToAutomatonThompson.h b/alib2algo/src/regexp/convert/ToAutomatonThompson.h index e84832bccf09660e5d36d1904fe6f15a560ba865..5d639411c63f9e51789f32c5f3339c9f32892a61 100644 --- a/alib2algo/src/regexp/convert/ToAutomatonThompson.h +++ b/alib2algo/src/regexp/convert/ToAutomatonThompson.h @@ -29,7 +29,7 @@ namespace convert { * http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.7450&rep=rep1&type=ps * Melichar 2.112 */ -class ToAutomatonThompson : public std::SingleDispatch<automaton::EpsilonNFA, regexp::RegExpBase>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { +class ToAutomatonThompson : public std::SingleDispatch<ToAutomatonThompson, automaton::EpsilonNFA, regexp::RegExpBase>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { public: ToAutomatonThompson() {} @@ -60,11 +60,6 @@ private: static const ToAutomatonThompson TO_AUTOMATON_THOMPSON; -public: - static ToAutomatonThompson& getInstance() { - static ToAutomatonThompson res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToGrammar.cpp b/alib2algo/src/regexp/convert/ToGrammar.cpp index 50c5faf3f92978da2b5e6c348fb40109b7a6cd28..58cd1d371170cc09ced0fe56aa59a940ccbdda09 100644 --- a/alib2algo/src/regexp/convert/ToGrammar.cpp +++ b/alib2algo/src/regexp/convert/ToGrammar.cpp @@ -13,20 +13,20 @@ namespace regexp { namespace convert { grammar::Grammar ToGrammar::convert(const regexp::RegExp& regexp) { - return getInstance().dispatch(regexp.getData()); + return dispatch(regexp.getData()); } grammar::Grammar ToGrammar::convert(const regexp::FormalRegExp& regexp) { return grammar::Grammar(ToGrammarRightRGGlushkov::convert(regexp)); } -auto ToGrammarFormalRegExp = ToGrammar::RegistratorWrapper<grammar::Grammar, regexp::FormalRegExp>(ToGrammar::getInstance(), ToGrammar::convert); +auto ToGrammarFormalRegExp = ToGrammar::RegistratorWrapper<grammar::Grammar, regexp::FormalRegExp>(ToGrammar::convert); grammar::Grammar ToGrammar::convert(const regexp::UnboundedRegExp& regexp) { return grammar::Grammar(ToGrammarRightRGGlushkov::convert(regexp)); } -auto ToGrammarUnboundedRegExp = ToGrammar::RegistratorWrapper<grammar::Grammar, regexp::UnboundedRegExp>(ToGrammar::getInstance(), ToGrammar::convert); +auto ToGrammarUnboundedRegExp = ToGrammar::RegistratorWrapper<grammar::Grammar, regexp::UnboundedRegExp>(ToGrammar::convert); } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToGrammar.h b/alib2algo/src/regexp/convert/ToGrammar.h index f252482a1ed0c553e0fc4f2e864984d86d9e95b7..34fca8150119e7c9768fb2501d9824dfe933276d 100644 --- a/alib2algo/src/regexp/convert/ToGrammar.h +++ b/alib2algo/src/regexp/convert/ToGrammar.h @@ -18,7 +18,7 @@ namespace regexp { namespace convert { -class ToGrammar : public std::SingleDispatch<grammar::Grammar, regexp::RegExpBase> { +class ToGrammar : public std::SingleDispatch<ToGrammar, grammar::Grammar, regexp::RegExpBase> { public: /** * Performs conversion. @@ -29,10 +29,6 @@ public: static grammar::Grammar convert(const regexp::FormalRegExp& regexp); static grammar::Grammar convert(const regexp::UnboundedRegExp& regexp); - static ToGrammar& getInstance() { - static ToGrammar res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.cpp b/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.cpp index 508d6a93d56eb17b41f9bfbbf1076a1a29e2b618..5d688cae8fa55bea54ba7d2bf761a7385815e2ef 100644 --- a/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.cpp +++ b/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.cpp @@ -25,7 +25,7 @@ namespace regexp { namespace convert { grammar::RightRG ToGrammarRightRGDerivation::convert(const regexp::RegExp& regexp) { - return getInstance().dispatch(regexp.getData()); + return dispatch(regexp.getData()); } template<class T> @@ -102,8 +102,8 @@ grammar::RightRG ToGrammarRightRGDerivation::convert(const T& regexp) { return grammar; } -auto ToGrammarRightRGDerivationUnboundedRegExp = ToGrammarRightRGDerivation::RegistratorWrapper<grammar::RightRG, regexp::UnboundedRegExp>(ToGrammarRightRGDerivation::getInstance(), ToGrammarRightRGDerivation::convert); -auto ToGrammarRightRGDerivationFormalRegExp = ToGrammarRightRGDerivation::RegistratorWrapper<grammar::RightRG, regexp::FormalRegExp>(ToGrammarRightRGDerivation::getInstance(), ToGrammarRightRGDerivation::convert); +auto ToGrammarRightRGDerivationUnboundedRegExp = ToGrammarRightRGDerivation::RegistratorWrapper<grammar::RightRG, regexp::UnboundedRegExp>(ToGrammarRightRGDerivation::convert); +auto ToGrammarRightRGDerivationFormalRegExp = ToGrammarRightRGDerivation::RegistratorWrapper<grammar::RightRG, regexp::FormalRegExp>(ToGrammarRightRGDerivation::convert); } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.h b/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.h index b2102616dd7fb634a9e680db864e954389faf556..9da2e21e691203055c4eeaf1dd4479af0f788a4a 100644 --- a/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.h +++ b/alib2algo/src/regexp/convert/ToGrammarRightRGDerivation.h @@ -23,7 +23,7 @@ namespace convert { * Converts reg. expression to right regular grammar using brzozowski derivation algorithm. * Source: Melichar 2.137 */ -class ToGrammarRightRGDerivation : public std::SingleDispatch<grammar::RightRG, regexp::RegExpBase> { +class ToGrammarRightRGDerivation : public std::SingleDispatch<ToGrammarRightRGDerivation, grammar::RightRG, regexp::RegExpBase> { public: /** * Performs conversion. @@ -34,10 +34,6 @@ public: template <class T> static grammar::RightRG convert(const T& regexp); - static ToGrammarRightRGDerivation& getInstance() { - static ToGrammarRightRGDerivation res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToGrammarRightRGGlushkov.cpp b/alib2algo/src/regexp/convert/ToGrammarRightRGGlushkov.cpp index 2f57d53d1718a4fca4d39c40b2d3d35c2bb54625..d0db89f8124f8dcf92bc96635a8e6c2b62978041 100644 --- a/alib2algo/src/regexp/convert/ToGrammarRightRGGlushkov.cpp +++ b/alib2algo/src/regexp/convert/ToGrammarRightRGGlushkov.cpp @@ -28,7 +28,7 @@ namespace regexp { namespace convert { grammar::RightRG ToGrammarRightRGGlushkov::convert(const regexp::RegExp& regexp) { - return getInstance().dispatch(regexp.getData()); + return dispatch(regexp.getData()); } grammar::RightRG ToGrammarRightRGGlushkov::convert(const regexp::UnboundedRegExp& regexp) { @@ -88,13 +88,13 @@ grammar::RightRG ToGrammarRightRGGlushkov::convert(const regexp::UnboundedRegExp return grammar; } -auto ToGrammarRightRGGlushkovUnboundedRegExp = ToGrammarRightRGGlushkov::RegistratorWrapper<grammar::RightRG, regexp::UnboundedRegExp>(ToGrammarRightRGGlushkov::getInstance(), ToGrammarRightRGGlushkov::convert); +auto ToGrammarRightRGGlushkovUnboundedRegExp = ToGrammarRightRGGlushkov::RegistratorWrapper<grammar::RightRG, regexp::UnboundedRegExp>(ToGrammarRightRGGlushkov::convert); grammar::RightRG ToGrammarRightRGGlushkov::convert(const regexp::FormalRegExp& /* regexp */) { throw exception::CommonException("Glushkov: Converting FormalRegExp NYI"); // TODO } -auto ToGrammarRightRGGlushkovFormalRegExp = ToGrammarRightRGGlushkov::RegistratorWrapper<grammar::RightRG, regexp::FormalRegExp>(ToGrammarRightRGGlushkov::getInstance(), ToGrammarRightRGGlushkov::convert); +auto ToGrammarRightRGGlushkovFormalRegExp = ToGrammarRightRGGlushkov::RegistratorWrapper<grammar::RightRG, regexp::FormalRegExp>(ToGrammarRightRGGlushkov::convert); } /* namespace convert */ diff --git a/alib2algo/src/regexp/convert/ToGrammarRightRGGlushkov.h b/alib2algo/src/regexp/convert/ToGrammarRightRGGlushkov.h index 550fbc4de183f8a5496a2695bdfb4e021e341849..1fdc152e6e9655410189fa5aeae6d3463070a165 100644 --- a/alib2algo/src/regexp/convert/ToGrammarRightRGGlushkov.h +++ b/alib2algo/src/regexp/convert/ToGrammarRightRGGlushkov.h @@ -24,7 +24,7 @@ namespace convert { * Converts regular expression to right regular grammar using Glushkov algorithm. * Source: None yet. */ -class ToGrammarRightRGGlushkov : public std::SingleDispatch<grammar::RightRG, regexp::RegExpBase> { +class ToGrammarRightRGGlushkov : public std::SingleDispatch<ToGrammarRightRGGlushkov, grammar::RightRG, regexp::RegExpBase> { public: /** * Performs conversion. @@ -35,11 +35,6 @@ public: static grammar::RightRG convert(const regexp::FormalRegExp& regexp); static grammar::RightRG convert(const regexp::UnboundedRegExp& regexp); - - static ToGrammarRightRGGlushkov& getInstance() { - static ToGrammarRightRGGlushkov res; - return res; - } }; } /* namespace convert */ diff --git a/alib2algo/src/regexp/properties/RegExpEmpty.cpp b/alib2algo/src/regexp/properties/RegExpEmpty.cpp index c2e5196cb450b69f20df12b584843d47f00634d7..f48545af05d5d4f4a03c4ecd8244b70fe3129f52 100644 --- a/alib2algo/src/regexp/properties/RegExpEmpty.cpp +++ b/alib2algo/src/regexp/properties/RegExpEmpty.cpp @@ -14,7 +14,7 @@ namespace regexp { namespace properties { bool RegExpEmpty::languageIsEmpty(const regexp::RegExp& regexp) { - return getInstance().dispatch(regexp.getData()); + return dispatch(regexp.getData()); } bool RegExpEmpty::languageIsEmpty(const regexp::FormalRegExpElement& regexp) { @@ -27,7 +27,7 @@ bool RegExpEmpty::languageIsEmpty(const regexp::FormalRegExp& regexp) { return languageIsEmpty(regexp.getRegExp()); } -auto RegExpEmptyFormalRegExp = RegExpEmpty::RegistratorWrapper<bool, regexp::FormalRegExp>(RegExpEmpty::getInstance(), RegExpEmpty::languageIsEmpty); +auto RegExpEmptyFormalRegExp = RegExpEmpty::RegistratorWrapper<bool, regexp::FormalRegExp>( RegExpEmpty::languageIsEmpty); bool RegExpEmpty::languageIsEmpty(const regexp::UnboundedRegExpElement& regexp) { bool out; @@ -39,7 +39,7 @@ bool RegExpEmpty::languageIsEmpty(const regexp::UnboundedRegExp& regexp) { return languageIsEmpty(regexp.getRegExp()); } -auto RegExpEmptyUnboundedRegExp = RegExpEmpty::RegistratorWrapper<bool, regexp::UnboundedRegExp>(RegExpEmpty::getInstance(), RegExpEmpty::languageIsEmpty); +auto RegExpEmptyUnboundedRegExp = RegExpEmpty::RegistratorWrapper<bool, regexp::UnboundedRegExp>( RegExpEmpty::languageIsEmpty); // ---------------------------------------------------------------------------- diff --git a/alib2algo/src/regexp/properties/RegExpEmpty.h b/alib2algo/src/regexp/properties/RegExpEmpty.h index 598f7e5d178bec69f3b7750600c9b59b1aa1390c..1a8d19d4c0b1b65898768feb8d7251ee829e5967 100644 --- a/alib2algo/src/regexp/properties/RegExpEmpty.h +++ b/alib2algo/src/regexp/properties/RegExpEmpty.h @@ -24,7 +24,7 @@ namespace properties { * Determines whether regular expression is empty (regexp == \0) * */ -class RegExpEmpty : public std::SingleDispatch<bool, regexp::RegExpBase>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { +class RegExpEmpty : public std::SingleDispatch<RegExpEmpty, bool, regexp::RegExpBase>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { public: RegExpEmpty() {} @@ -53,11 +53,6 @@ private: static const RegExpEmpty REG_EXP_EMPTY; -public: - static RegExpEmpty& getInstance() { - static RegExpEmpty res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/regexp/properties/RegExpEpsilon.cpp b/alib2algo/src/regexp/properties/RegExpEpsilon.cpp index b87ccd26bed3e0cdc5cd9d6300969eae4abba187..faa983486722b553b7d1e7588c0a27a4c8e4ea87 100644 --- a/alib2algo/src/regexp/properties/RegExpEpsilon.cpp +++ b/alib2algo/src/regexp/properties/RegExpEpsilon.cpp @@ -14,7 +14,7 @@ namespace regexp { namespace properties { bool RegExpEpsilon::languageContainsEpsilon(const regexp::RegExp& regexp) { - return getInstance().dispatch(regexp.getData()); + return dispatch(regexp.getData()); } bool RegExpEpsilon::languageContainsEpsilon(const regexp::FormalRegExpElement& regexp) { @@ -27,7 +27,7 @@ bool RegExpEpsilon::languageContainsEpsilon(const regexp::FormalRegExp& regexp) return languageContainsEpsilon(regexp.getRegExp()); } -auto RegExpEpsilonFormalRegExp = RegExpEpsilon::RegistratorWrapper<bool, regexp::FormalRegExp>(RegExpEpsilon::getInstance(), RegExpEpsilon::languageContainsEpsilon); +auto RegExpEpsilonFormalRegExp = RegExpEpsilon::RegistratorWrapper<bool, regexp::FormalRegExp>( RegExpEpsilon::languageContainsEpsilon); bool RegExpEpsilon::languageContainsEpsilon(const regexp::UnboundedRegExpElement& regexp) { bool out; @@ -39,7 +39,7 @@ bool RegExpEpsilon::languageContainsEpsilon(const regexp::UnboundedRegExp& regex return languageContainsEpsilon(regexp.getRegExp()); } -auto RegExpEpsilonUnboundedRegExp = RegExpEpsilon::RegistratorWrapper<bool, regexp::UnboundedRegExp>(RegExpEpsilon::getInstance(), RegExpEpsilon::languageContainsEpsilon); +auto RegExpEpsilonUnboundedRegExp = RegExpEpsilon::RegistratorWrapper<bool, regexp::UnboundedRegExp>( RegExpEpsilon::languageContainsEpsilon); // --------------------------------------------------------------------------- diff --git a/alib2algo/src/regexp/properties/RegExpEpsilon.h b/alib2algo/src/regexp/properties/RegExpEpsilon.h index ac9ba2968c706a2552f70132695b742d98a6e1ac..d7a6a6e108ce9e8cedf0e62814efa516c365165e 100644 --- a/alib2algo/src/regexp/properties/RegExpEpsilon.h +++ b/alib2algo/src/regexp/properties/RegExpEpsilon.h @@ -24,7 +24,7 @@ namespace properties { * Checks, whether regexp (or its subtree) describes epsilon (empty string). * */ -class RegExpEpsilon : public std::SingleDispatch<bool, regexp::RegExpBase>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { +class RegExpEpsilon : public std::SingleDispatch<RegExpEpsilon, bool, regexp::RegExpBase>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { public: RegExpEpsilon() {} @@ -52,12 +52,6 @@ private: void Visit(void* data, const regexp::FormalRegExpEpsilon& epsilon) const; static const RegExpEpsilon REG_EXP_EPSILON; - -public: - static RegExpEpsilon& getInstance() { - static RegExpEpsilon res; - return res; - } }; } /* namespace properties */ diff --git a/alib2algo/src/regexp/simplify/RegExpOptimize.cpp b/alib2algo/src/regexp/simplify/RegExpOptimize.cpp index add99cb51a7c89813d7b1a1d0ce5f355afe6e2ee..18d388c32015afb66957eb1075d295112a4a7d5a 100644 --- a/alib2algo/src/regexp/simplify/RegExpOptimize.cpp +++ b/alib2algo/src/regexp/simplify/RegExpOptimize.cpp @@ -20,7 +20,7 @@ namespace simplify { regexp::RegExp RegExpOptimize::optimize(const regexp::RegExp& regexp) { - return getInstance().dispatch(regexp.getData()); + return dispatch(regexp.getData()); } FormalRegExp RegExpOptimize::optimize( FormalRegExp const & regexp ) @@ -34,7 +34,7 @@ FormalRegExp RegExpOptimize::optimize( FormalRegExp const & regexp ) return ret; } -auto RegExpOptimizeFormalRegEpx = RegExpOptimize::RegistratorWrapper<FormalRegExp, FormalRegExp>(RegExpOptimize::getInstance(), RegExpOptimize::optimize); +auto RegExpOptimizeFormalRegEpx = RegExpOptimize::RegistratorWrapper<FormalRegExp, FormalRegExp>(RegExpOptimize::optimize); void RegExpOptimize::optimize( FormalRegExpElement & element ) { @@ -94,7 +94,7 @@ UnboundedRegExp RegExpOptimize::optimize( UnboundedRegExp const & regexp ) return ret; } -auto RegExpOptimizeUnboundedRegEpx = RegExpOptimize::RegistratorWrapper<UnboundedRegExp, UnboundedRegExp>(RegExpOptimize::getInstance(), RegExpOptimize::optimize); +auto RegExpOptimizeUnboundedRegEpx = RegExpOptimize::RegistratorWrapper<UnboundedRegExp, UnboundedRegExp>(RegExpOptimize::optimize); void RegExpOptimize::optimize( UnboundedRegExpElement & element ) { UnboundedRegExpElement* optimized = RegExpOptimize::REG_EXP_OPTIMIZE.optimize( & element ); diff --git a/alib2algo/src/regexp/simplify/RegExpOptimize.h b/alib2algo/src/regexp/simplify/RegExpOptimize.h index 3c36ccbba59106b808de6a5865d86f84a5cfb412..e8d24797f90e888234071395085682ee0bdd5073 100644 --- a/alib2algo/src/regexp/simplify/RegExpOptimize.h +++ b/alib2algo/src/regexp/simplify/RegExpOptimize.h @@ -61,7 +61,7 @@ namespace simplify { * * - X1 : -> : a* + \e = a* */ -class RegExpOptimize : public std::SingleDispatch<regexp::RegExp, regexp::RegExpBase> +class RegExpOptimize : public std::SingleDispatch<RegExpOptimize, regexp::RegExp, regexp::RegExpBase> { public: RegExpOptimize() {} @@ -133,12 +133,6 @@ private: bool X1( regexp::FormalRegExpElement * & node ) const; static const RegExpOptimize REG_EXP_OPTIMIZE; - -public: - static RegExpOptimize& getInstance() { - static RegExpOptimize res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/regexp/transform/RegExpDerivation.cpp b/alib2algo/src/regexp/transform/RegExpDerivation.cpp index fd826efb6990fccc7e510e5e43285dc8e39b2283..8a4fdf13b30ad39bf95516a4dbb60139d4497a82 100644 --- a/alib2algo/src/regexp/transform/RegExpDerivation.cpp +++ b/alib2algo/src/regexp/transform/RegExpDerivation.cpp @@ -15,7 +15,7 @@ namespace regexp { regexp::RegExp RegExpDerivation::derivation(const regexp::RegExp& regexp, const string::LinearString& string) { - return getInstance().dispatch(regexp.getData(), string); + return dispatch(regexp.getData(), string); } regexp::FormalRegExp RegExpDerivation::derivation(const regexp::FormalRegExp& regexp, const string::LinearString& string) @@ -35,7 +35,7 @@ regexp::FormalRegExp RegExpDerivation::derivation(const regexp::FormalRegExp& re return res; } -auto RegExpDerivationFormalRegExp = RegExpDerivation::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpDerivation::getInstance(), RegExpDerivation::derivation); +auto RegExpDerivationFormalRegExp = RegExpDerivation::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpDerivation::derivation); regexp::UnboundedRegExp RegExpDerivation::derivation(const regexp::UnboundedRegExp& regexp, const string::LinearString& string) { @@ -54,7 +54,7 @@ regexp::UnboundedRegExp RegExpDerivation::derivation(const regexp::UnboundedRegE return res; } -auto RegExpDerivationUnboundedRegExp = RegExpDerivation::RegistratorWrapper<regexp::UnboundedRegExp, regexp::UnboundedRegExp>(RegExpDerivation::getInstance(), RegExpDerivation::derivation); +auto RegExpDerivationUnboundedRegExp = RegExpDerivation::RegistratorWrapper<regexp::UnboundedRegExp, regexp::UnboundedRegExp>(RegExpDerivation::derivation); // ---------------------------------------------------------------------------- diff --git a/alib2algo/src/regexp/transform/RegExpDerivation.h b/alib2algo/src/regexp/transform/RegExpDerivation.h index ad6b98361b96058e93dc4d5dac790c29c42db1e2..6649a57ea2e65d28181bb7b49e9eadda3322512d 100644 --- a/alib2algo/src/regexp/transform/RegExpDerivation.h +++ b/alib2algo/src/regexp/transform/RegExpDerivation.h @@ -27,7 +27,7 @@ namespace regexp { * - Melichar, definition 2.91 in chapter 2.4.3 * - Brzozowski, J. A. - Derivatives of regular expressions (1964) */ -class RegExpDerivation : public std::SingleDispatchLastStaticParam<regexp::RegExp, regexp::RegExpBase, const string::LinearString&>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { +class RegExpDerivation : public std::SingleDispatchLastStaticParam<RegExpDerivation, regexp::RegExp, regexp::RegExpBase, const string::LinearString&>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { public: RegExpDerivation() {} @@ -57,12 +57,6 @@ private: void Visit(void*, const regexp::UnboundedRegExpEmpty& empty) const; static const RegExpDerivation REGEXP_DERIVATION; - -public: - static RegExpDerivation& getInstance() { - static RegExpDerivation res; - return res; - } }; } /* namespace regexp */ diff --git a/alib2algo/src/regexp/transform/RegExpIntegral.cpp b/alib2algo/src/regexp/transform/RegExpIntegral.cpp index 4483c6638dd85a7dc89a6e39290a6862747f3433..35036c9e60179022916771f3c155b906a4b17095 100644 --- a/alib2algo/src/regexp/transform/RegExpIntegral.cpp +++ b/alib2algo/src/regexp/transform/RegExpIntegral.cpp @@ -14,7 +14,7 @@ namespace regexp regexp::RegExp RegExpIntegral::integral(const regexp::RegExp& regexp, const string::LinearString& string) { - return getInstance().dispatch(regexp.getData(), string); + return dispatch(regexp.getData(), string); } regexp::FormalRegExp RegExpIntegral::integral(const regexp::FormalRegExp& regexp, const string::LinearString& string) @@ -36,7 +36,7 @@ regexp::FormalRegExp RegExpIntegral::integral(const regexp::FormalRegExp& regexp return res; } -auto RegExpIntegralFormalRegExp = RegExpIntegral::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpIntegral::getInstance(), RegExpIntegral::integral); +auto RegExpIntegralFormalRegExp = RegExpIntegral::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpIntegral::integral); regexp::UnboundedRegExp RegExpIntegral::integral(const regexp::UnboundedRegExp& regexp, const string::LinearString& string) { @@ -57,7 +57,7 @@ regexp::UnboundedRegExp RegExpIntegral::integral(const regexp::UnboundedRegExp& return res; } -auto RegExpIntegralUnboundedRegExp = RegExpIntegral::RegistratorWrapper<regexp::UnboundedRegExp, regexp::UnboundedRegExp>(RegExpIntegral::getInstance(), RegExpIntegral::integral); +auto RegExpIntegralUnboundedRegExp = RegExpIntegral::RegistratorWrapper<regexp::UnboundedRegExp, regexp::UnboundedRegExp>(RegExpIntegral::integral); // ---------------------------------------------------------------------------- diff --git a/alib2algo/src/regexp/transform/RegExpIntegral.h b/alib2algo/src/regexp/transform/RegExpIntegral.h index 4dc79e6330f100e4b62608b6a3456112386de04e..3f201c2029c4b942c99c26f51f98c31ce959936a 100644 --- a/alib2algo/src/regexp/transform/RegExpIntegral.h +++ b/alib2algo/src/regexp/transform/RegExpIntegral.h @@ -25,7 +25,7 @@ namespace regexp * Calculates integral of regular expression * Source: Melichar definition 2.93 in chapter 2.4.4 */ -class RegExpIntegral : public std::SingleDispatchLastStaticParam<regexp::RegExp, regexp::RegExpBase, const string::LinearString&>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor +class RegExpIntegral : public std::SingleDispatchLastStaticParam<RegExpIntegral, regexp::RegExp, regexp::RegExpBase, const string::LinearString&>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { public: RegExpIntegral() {} @@ -56,12 +56,6 @@ private: void Visit(void*, const regexp::UnboundedRegExpEmpty& empty) const; static const RegExpIntegral REGEXP_INTEGRAL; - -public: - static RegExpIntegral& getInstance() { - static RegExpIntegral res; - return res; - } }; } /* namespace regexp */ diff --git a/alib2algo/src/regexp/transform/RegExpIterate.cpp b/alib2algo/src/regexp/transform/RegExpIterate.cpp index d425fcae64790c9273a2193c860ce65e2dc2945a..68aa68e99ba7e4f6044e128f24fa9b066b5d0b01 100644 --- a/alib2algo/src/regexp/transform/RegExpIterate.cpp +++ b/alib2algo/src/regexp/transform/RegExpIterate.cpp @@ -12,19 +12,19 @@ namespace regexp { regexp::RegExp RegExpIterate::iterate(const regexp::RegExp& regexp) { - return getInstance().dispatch(regexp.getData()); + return dispatch(regexp.getData()); } regexp::FormalRegExp RegExpIterate::iterate(const regexp::FormalRegExp& regexp) { return regexp::FormalRegExp(regexp::FormalRegExpIteration(regexp.getRegExp())); } -auto RegExpIterateFormalRegExpFormalRegExp = RegExpIterate::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpIterate::getInstance(), RegExpIterate::iterate); +auto RegExpIterateFormalRegExpFormalRegExp = RegExpIterate::RegistratorWrapper<regexp::FormalRegExp, regexp::FormalRegExp>(RegExpIterate::iterate); regexp::UnboundedRegExp RegExpIterate::iterate(const regexp::UnboundedRegExp& regexp) { return regexp::UnboundedRegExp(regexp::UnboundedRegExpIteration(regexp.getRegExp())); } -auto RegExpIterateUnboundedRegExpUnboundedRegExp = RegExpIterate::RegistratorWrapper<regexp::UnboundedRegExp, regexp::UnboundedRegExp>(RegExpIterate::getInstance(), RegExpIterate::iterate); +auto RegExpIterateUnboundedRegExpUnboundedRegExp = RegExpIterate::RegistratorWrapper<regexp::UnboundedRegExp, regexp::UnboundedRegExp>(RegExpIterate::iterate); } /* namespace regexp */ diff --git a/alib2algo/src/regexp/transform/RegExpIterate.h b/alib2algo/src/regexp/transform/RegExpIterate.h index e149a619fa81fde357226a908fb33bd06b00d79e..9e5dbee817402157b932ac8dd75f3ec9032f41dd 100644 --- a/alib2algo/src/regexp/transform/RegExpIterate.h +++ b/alib2algo/src/regexp/transform/RegExpIterate.h @@ -20,17 +20,12 @@ namespace regexp { * Iterates two regexpses * */ -class RegExpIterate : public std::SingleDispatch<regexp::RegExp, regexp::RegExpBase> { +class RegExpIterate : public std::SingleDispatch<RegExpIterate, regexp::RegExp, regexp::RegExpBase> { public: static regexp::RegExp iterate(const regexp::RegExp& regexp); static regexp::FormalRegExp iterate(const regexp::FormalRegExp& regexp); static regexp::UnboundedRegExp iterate(const regexp::UnboundedRegExp& regexp); - - static RegExpIterate& getInstance() { - static RegExpIterate res; - return res; - } }; } /* namespace regexp */ diff --git a/alib2algo/src/string/generate/RandomSubstringFactory.cpp b/alib2algo/src/string/generate/RandomSubstringFactory.cpp index 1248e1b7c30f0df7cfcef2b098f52faae50f217c..4c2d212cd474a3722ca4174a2fc73465b5570591 100644 --- a/alib2algo/src/string/generate/RandomSubstringFactory.cpp +++ b/alib2algo/src/string/generate/RandomSubstringFactory.cpp @@ -18,7 +18,7 @@ namespace string { namespace generate { string::String RandomSubstringFactory::generateSubstring ( size_t size, const string::String & v ) { - return getInstance ( ).dispatch ( size, v.getData ( ) ); + return dispatch ( size, v.getData ( ) ); } string::LinearString RandomSubstringFactory::generateSubstring ( size_t size, const string::LinearString & string ) { @@ -34,7 +34,7 @@ string::LinearString RandomSubstringFactory::generateSubstring ( size_t size, co }; } -auto RandomSubstringFactoryLinearString = RandomSubstringFactory::RegistratorWrapper < string::LinearString, string::LinearString > ( RandomSubstringFactory::getInstance ( ), RandomSubstringFactory::generateSubstring ); +auto RandomSubstringFactoryLinearString = RandomSubstringFactory::RegistratorWrapper < string::LinearString, string::LinearString > ( RandomSubstringFactory::generateSubstring ); } /* namespace generate */ diff --git a/alib2algo/src/string/generate/RandomSubstringFactory.h b/alib2algo/src/string/generate/RandomSubstringFactory.h index 9d3895fda27a86c1a19b1ecc82d60dae2e0e8b7f..e9e8304a27cc84da889c6941955cc6d637d7b77c 100644 --- a/alib2algo/src/string/generate/RandomSubstringFactory.h +++ b/alib2algo/src/string/generate/RandomSubstringFactory.h @@ -16,18 +16,12 @@ namespace string { namespace generate { -class RandomSubstringFactory : public std::SingleDispatchFirstStaticParam < string::String, size_t, string::StringBase > { +class RandomSubstringFactory : public std::SingleDispatchFirstStaticParam < RandomSubstringFactory, string::String, size_t, string::StringBase > { public: static string::String generateSubstring ( size_t size, const string::String & ); static string::LinearString generateSubstring ( size_t size, const string::LinearString & ); - static RandomSubstringFactory & getInstance ( ) { - static RandomSubstringFactory res; - - return res; - } - }; } /* namespace generate */ diff --git a/alib2algo/src/string/simplify/NormalizeAlphabet.cpp b/alib2algo/src/string/simplify/NormalizeAlphabet.cpp index 52dbd3f031522f2a8d5cd4785cdabe9bdd98b22a..bfb81842b04382c2b77d54e1bda8dcd4b0d454d0 100644 --- a/alib2algo/src/string/simplify/NormalizeAlphabet.cpp +++ b/alib2algo/src/string/simplify/NormalizeAlphabet.cpp @@ -18,7 +18,7 @@ namespace string { namespace simplify { string::String NormalizeAlphabet::normalize(const string::String& string) { - return getInstance().dispatch(string.getData()); + return dispatch(string.getData()); } string::LinearString NormalizeAlphabet::normalize(const string::LinearString& string) { @@ -45,7 +45,7 @@ string::LinearString NormalizeAlphabet::normalize(const string::LinearString& st return result; } -auto NormalizeAlphabetLinearString = NormalizeAlphabet::RegistratorWrapper<string::LinearString, string::LinearString>(NormalizeAlphabet::getInstance(), NormalizeAlphabet::normalize); +auto NormalizeAlphabetLinearString = NormalizeAlphabet::RegistratorWrapper<string::LinearString, string::LinearString>(NormalizeAlphabet::normalize); } /* namespace simplify */ diff --git a/alib2algo/src/string/simplify/NormalizeAlphabet.h b/alib2algo/src/string/simplify/NormalizeAlphabet.h index a406f17b10bcc1f91207a1f0d5098a11127536d6..72260afaa5392d0b43a013f0a9ab7d9d0b3e12f9 100644 --- a/alib2algo/src/string/simplify/NormalizeAlphabet.h +++ b/alib2algo/src/string/simplify/NormalizeAlphabet.h @@ -17,7 +17,7 @@ namespace string { namespace simplify { -class NormalizeAlphabet : public std::SingleDispatch<string::String, string::StringBase> { +class NormalizeAlphabet : public std::SingleDispatch<NormalizeAlphabet, string::String, string::StringBase> { public: /** * @param dfa automaton to normalize @@ -25,11 +25,6 @@ public: static string::String normalize(const string::String& str); static string::LinearString normalize(const string::LinearString& str); - - static NormalizeAlphabet& getInstance() { - static NormalizeAlphabet res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/string/simplify/NormalizeRotation.cpp b/alib2algo/src/string/simplify/NormalizeRotation.cpp index 55c0b06809405008e271b3502d164929cf4e6efc..b55f435850544d1662d5f7a095eaf76841e14e34 100644 --- a/alib2algo/src/string/simplify/NormalizeRotation.cpp +++ b/alib2algo/src/string/simplify/NormalizeRotation.cpp @@ -14,7 +14,7 @@ namespace string { namespace simplify { string::String NormalizeRotation::normalize(const string::String& string) { - return getInstance().dispatch(string.getData()); + return dispatch(string.getData()); } string::CyclicString NormalizeRotation::normalize(const string::CyclicString& string) { @@ -54,7 +54,7 @@ string::CyclicString NormalizeRotation::normalize(const string::CyclicString& st return string::CyclicString { string.getAlphabet(), rotated }; } -auto NormalizeRotationCyclicString = NormalizeRotation::RegistratorWrapper<string::CyclicString, string::CyclicString>(NormalizeRotation::getInstance(), NormalizeRotation::normalize); +auto NormalizeRotationCyclicString = NormalizeRotation::RegistratorWrapper<string::CyclicString, string::CyclicString>(NormalizeRotation::normalize); } /* namespace simplify */ diff --git a/alib2algo/src/string/simplify/NormalizeRotation.h b/alib2algo/src/string/simplify/NormalizeRotation.h index da3c3d539f239f0a7316cbf1b4b4e00d5e2b3977..4352a866bdabfae7d41d80153cc03b2e97bb3968 100644 --- a/alib2algo/src/string/simplify/NormalizeRotation.h +++ b/alib2algo/src/string/simplify/NormalizeRotation.h @@ -17,7 +17,7 @@ namespace string { namespace simplify { -class NormalizeRotation : public std::SingleDispatch<string::String, string::StringBase> { +class NormalizeRotation : public std::SingleDispatch<NormalizeRotation, string::String, string::StringBase> { public: /** * Performs conversion. @@ -26,11 +26,6 @@ public: static string::String normalize(const string::String& string); static string::CyclicString normalize(const string::CyclicString& string); - - static NormalizeRotation& getInstance() { - static NormalizeRotation res; - return res; - } }; } /* namespace simplify */ diff --git a/alib2algo/src/stringology/exact/BackwardDAWGMatching.cpp b/alib2algo/src/stringology/exact/BackwardDAWGMatching.cpp index 7525455699fa4862bd6394a4390e976cd27e0a2b..6e05ae41f6d5a4fccc4fb76d81343987309bebc0 100644 --- a/alib2algo/src/stringology/exact/BackwardDAWGMatching.cpp +++ b/alib2algo/src/stringology/exact/BackwardDAWGMatching.cpp @@ -3,7 +3,7 @@ */ #include "BackwardDAWGMatching.hpp" -#include "SuffixAutomaton.hpp" +#include "SuffixAutomaton.h" #include <string/LinearString.h> #include <alphabet/Symbol.h> diff --git a/alib2algo/src/stringology/exact/BackwardOracleMatching.cpp b/alib2algo/src/stringology/exact/BackwardOracleMatching.cpp index 793edb37fb12999445230c6e377b053a9f86e15b..44eeee1d28e144bc5968ef709caa30a7c3a15702 100644 --- a/alib2algo/src/stringology/exact/BackwardOracleMatching.cpp +++ b/alib2algo/src/stringology/exact/BackwardOracleMatching.cpp @@ -3,7 +3,7 @@ */ #include "BackwardOracleMatching.hpp" -#include "FactorOracleAutomaton.hpp" +#include "FactorOracleAutomaton.h" #include <string/LinearString.h> #include <alphabet/Symbol.h> diff --git a/alib2algo/src/stringology/exact/BadCharacterShiftTable.cpp b/alib2algo/src/stringology/exact/BadCharacterShiftTable.cpp index fe6b9f05e9284302f23ab5e93c24ff7c7fa28ce3..ae0a9a84ac63681eb3b34df0e5960bc2323c6dba 100644 --- a/alib2algo/src/stringology/exact/BadCharacterShiftTable.cpp +++ b/alib2algo/src/stringology/exact/BadCharacterShiftTable.cpp @@ -15,7 +15,7 @@ namespace stringology { namespace exact { std::map<alphabet::Symbol, size_t> BadCharacterShiftTable::bcs(const string::String& pattern) { - return getInstance().dispatch(pattern.getData()); + return dispatch(pattern.getData()); } std::map<alphabet::Symbol, size_t> BadCharacterShiftTable::bcs(const string::LinearString& pattern) { @@ -40,7 +40,7 @@ std::map<alphabet::Symbol, size_t> BadCharacterShiftTable::bcs(const string::Lin return bcs; } -auto BadCharacterShiftTableLinearString = BadCharacterShiftTable::RegistratorWrapper<std::map<alphabet::Symbol, size_t>, string::LinearString>(BadCharacterShiftTable::getInstance(), BadCharacterShiftTable::bcs); +auto BadCharacterShiftTableLinearString = BadCharacterShiftTable::RegistratorWrapper<std::map<alphabet::Symbol, size_t>, string::LinearString>(BadCharacterShiftTable::bcs); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BadCharacterShiftTable.h b/alib2algo/src/stringology/exact/BadCharacterShiftTable.h index 50da49f5ccc1aab50f28faf9578f2d0c1cce09ba..b8f97bc5f4aa9cca5b42929b789447ddb5ffbb04 100644 --- a/alib2algo/src/stringology/exact/BadCharacterShiftTable.h +++ b/alib2algo/src/stringology/exact/BadCharacterShiftTable.h @@ -23,7 +23,7 @@ namespace exact { * Computation of BCS table for BMH from MI(E+\eps)-EVY course 2014 * To get rid of zeros in BCS table we ignore last haystack character */ -class BadCharacterShiftTable : public std::SingleDispatch < std::map < alphabet::Symbol, size_t >, string::StringBase > { +class BadCharacterShiftTable : public std::SingleDispatch < BadCharacterShiftTable, std::map < alphabet::Symbol, size_t >, string::StringBase > { public: /** * Search for pattern in linear string. @@ -33,12 +33,6 @@ public: static std::map < alphabet::Symbol, size_t > bcs ( const string::LinearString & pattern ); - static BadCharacterShiftTable & getInstance ( ) { - static BadCharacterShiftTable res; - - return res; - } - }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BorderArray.cpp b/alib2algo/src/stringology/exact/BorderArray.cpp index c989dcf706bc32746085e251b84987f0a48a1d76..2b2ad25be70c9b2d7b004a5331aa4905a0d76498 100644 --- a/alib2algo/src/stringology/exact/BorderArray.cpp +++ b/alib2algo/src/stringology/exact/BorderArray.cpp @@ -18,7 +18,7 @@ namespace stringology { namespace exact { std::vector<unsigned> BorderArray::construct(const string::String& string) { - return getInstance().dispatch(string.getData()); + return dispatch(string.getData()); } std::vector<unsigned> BorderArray::construct(const string::LinearString& string) { @@ -41,7 +41,7 @@ std::vector<unsigned> BorderArray::construct(const string::LinearString& string) return res; } -auto BorderArrayLinearString = BorderArray::RegistratorWrapper<std::vector<unsigned>, string::LinearString>(BorderArray::getInstance(), BorderArray::construct); +auto BorderArrayLinearString = BorderArray::RegistratorWrapper<std::vector<unsigned>, string::LinearString>(BorderArray::construct); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/BorderArray.h b/alib2algo/src/stringology/exact/BorderArray.h index 84184ccdb84788b3830f25e14556dea655bcd88c..8e526ccbe7e2ecda438e4f7918fbe388e135cc88 100644 --- a/alib2algo/src/stringology/exact/BorderArray.h +++ b/alib2algo/src/stringology/exact/BorderArray.h @@ -16,7 +16,7 @@ namespace stringology { namespace exact { -class BorderArray : public std::SingleDispatch<std::vector<unsigned>, string::StringBase> { +class BorderArray : public std::SingleDispatch<BorderArray, std::vector<unsigned>, string::StringBase> { public: /** * Computes border array of string @@ -26,11 +26,6 @@ public: static std::vector<unsigned> construct(const string::String& string); static std::vector<unsigned> construct(const string::LinearString& string); - - static BorderArray& getInstance() { - static BorderArray res; - return res; - } }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactFactorAutomaton.cpp b/alib2algo/src/stringology/exact/ExactFactorAutomaton.cpp index 75344ef5351af9a151c958cb38b45fa4c83d55be..db2c1c4581edc81f6cf7e677838228344b77319d 100644 --- a/alib2algo/src/stringology/exact/ExactFactorAutomaton.cpp +++ b/alib2algo/src/stringology/exact/ExactFactorAutomaton.cpp @@ -16,7 +16,7 @@ namespace stringology { namespace exact { automaton::Automaton ExactFactorAutomaton::construct(const string::String& text) { - return getInstance().dispatch(text.getData()); + return dispatch(text.getData()); } automaton::EpsilonNFA ExactFactorAutomaton::construct(const string::LinearString& text) { @@ -34,7 +34,7 @@ automaton::EpsilonNFA ExactFactorAutomaton::construct(const string::LinearString return res; } -auto ExactFactorAutomatonLinearString = ExactFactorAutomaton::RegistratorWrapper<automaton::EpsilonNFA, string::LinearString>(ExactFactorAutomaton::getInstance(), ExactFactorAutomaton::construct); +auto ExactFactorAutomatonLinearString = ExactFactorAutomaton::RegistratorWrapper<automaton::EpsilonNFA, string::LinearString>(ExactFactorAutomaton::construct); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactFactorAutomaton.h b/alib2algo/src/stringology/exact/ExactFactorAutomaton.h index 31b510c8ff8d5af2bb2202af7b2cfb651fdf7a40..1b2ec32e409c1b4f129f874ceac6057121ed70c9 100644 --- a/alib2algo/src/stringology/exact/ExactFactorAutomaton.h +++ b/alib2algo/src/stringology/exact/ExactFactorAutomaton.h @@ -18,7 +18,7 @@ namespace stringology { namespace exact { -class ExactFactorAutomaton : public std::SingleDispatch<automaton::Automaton, string::StringBase> { +class ExactFactorAutomaton : public std::SingleDispatch<ExactFactorAutomaton, automaton::Automaton, string::StringBase> { public: /** * Performs conversion. @@ -27,11 +27,6 @@ public: static automaton::Automaton construct(const string::String& text); static automaton::EpsilonNFA construct(const string::LinearString& text); - - static ExactFactorAutomaton& getInstance() { - static ExactFactorAutomaton res; - return res; - } }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactMatchingAutomaton.cpp b/alib2algo/src/stringology/exact/ExactMatchingAutomaton.cpp index dbc1647aeb27faf48571bc12b636e6bbfe51a46c..43de9b48f1fbd70d8e1b29468bb3801c2982ba84 100644 --- a/alib2algo/src/stringology/exact/ExactMatchingAutomaton.cpp +++ b/alib2algo/src/stringology/exact/ExactMatchingAutomaton.cpp @@ -16,7 +16,7 @@ namespace stringology { namespace exact { automaton::Automaton ExactMatchingAutomaton::construct(const string::String& pattern) { - return getInstance().dispatch(pattern.getData()); + return dispatch(pattern.getData()); } automaton::NFA ExactMatchingAutomaton::construct(const string::LinearString& pattern) { @@ -35,7 +35,7 @@ automaton::NFA ExactMatchingAutomaton::construct(const string::LinearString& pat return res; } -auto ExactMatchingAutomatonLinearString = ExactMatchingAutomaton::RegistratorWrapper<automaton::NFA, string::LinearString>(ExactMatchingAutomaton::getInstance(), ExactMatchingAutomaton::construct); +auto ExactMatchingAutomatonLinearString = ExactMatchingAutomaton::RegistratorWrapper<automaton::NFA, string::LinearString>(ExactMatchingAutomaton::construct); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactMatchingAutomaton.h b/alib2algo/src/stringology/exact/ExactMatchingAutomaton.h index 94a34ce418a6398a63a0bca652b7a3b2ef2120c5..5c8e77e722ea9525c38b2c9e00bf3999252f5b05 100644 --- a/alib2algo/src/stringology/exact/ExactMatchingAutomaton.h +++ b/alib2algo/src/stringology/exact/ExactMatchingAutomaton.h @@ -18,7 +18,7 @@ namespace stringology { namespace exact { -class ExactMatchingAutomaton : public std::SingleDispatch<automaton::Automaton, string::StringBase> { +class ExactMatchingAutomaton : public std::SingleDispatch<ExactMatchingAutomaton, automaton::Automaton, string::StringBase> { public: /** * Performs conversion. @@ -27,11 +27,6 @@ public: static automaton::Automaton construct(const string::String& pattern); static automaton::NFA construct(const string::LinearString& pattern); - - static ExactMatchingAutomaton& getInstance() { - static ExactMatchingAutomaton res; - return res; - } }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.cpp b/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.cpp index 4d378a3efd901d9db4f0393c4a5420e955918c1d..1d84b05cd29e21fcf1d72664e9b3a9a23a32feec 100644 --- a/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.cpp +++ b/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.cpp @@ -16,7 +16,7 @@ namespace stringology { namespace exact { automaton::Automaton ExactNondeterministicSubsequenceAutomaton::construct(const string::String& text) { - return getInstance().dispatch(text.getData()); + return dispatch(text.getData()); } automaton::EpsilonNFA ExactNondeterministicSubsequenceAutomaton::construct(const string::LinearString& text) { @@ -36,7 +36,7 @@ automaton::EpsilonNFA ExactNondeterministicSubsequenceAutomaton::construct(const return res; } -auto ExactNondeterministicSubsequenceAutomatonLinearString = ExactNondeterministicSubsequenceAutomaton::RegistratorWrapper<automaton::EpsilonNFA, string::LinearString>(ExactNondeterministicSubsequenceAutomaton::getInstance(), ExactNondeterministicSubsequenceAutomaton::construct); +auto ExactNondeterministicSubsequenceAutomatonLinearString = ExactNondeterministicSubsequenceAutomaton::RegistratorWrapper<automaton::EpsilonNFA, string::LinearString>( ExactNondeterministicSubsequenceAutomaton::construct ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.h b/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.h index 9bc0f191be826f0f3d84c081abc8cee616395917..13f3b810c90bd41f12b70e51dd32c74e2bfa13be 100644 --- a/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.h +++ b/alib2algo/src/stringology/exact/ExactNondeterministicSubsequenceAutomaton.h @@ -18,7 +18,7 @@ namespace stringology { namespace exact { -class ExactNondeterministicSubsequenceAutomaton : public std::SingleDispatch<automaton::Automaton, string::StringBase> { +class ExactNondeterministicSubsequenceAutomaton : public std::SingleDispatch<ExactNondeterministicSubsequenceAutomaton, automaton::Automaton, string::StringBase> { public: /** * Performs conversion. @@ -27,11 +27,6 @@ public: static automaton::Automaton construct(const string::String& text); static automaton::EpsilonNFA construct(const string::LinearString& text); - - static ExactNondeterministicSubsequenceAutomaton& getInstance() { - static ExactNondeterministicSubsequenceAutomaton res; - return res; - } }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.cpp b/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.cpp index 290c643e5fec28eb43df6f3113c59a428bd48440..2fb91395474f9bfcd25d18639baf388bffff7cb3 100644 --- a/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.cpp +++ b/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.cpp @@ -16,7 +16,7 @@ namespace stringology { namespace exact { automaton::Automaton ExactSubsequenceAutomaton::construct(const string::String& text) { - return getInstance().dispatch(text.getData()); + return dispatch(text.getData()); } automaton::DFA ExactSubsequenceAutomaton::construct(const string::LinearString& text) { @@ -43,7 +43,7 @@ automaton::DFA ExactSubsequenceAutomaton::construct(const string::LinearString& return res; } -auto ExactSubsequenceAutomatonLinearString = ExactSubsequenceAutomaton::RegistratorWrapper<automaton::DFA, string::LinearString>(ExactSubsequenceAutomaton::getInstance(), ExactSubsequenceAutomaton::construct); +auto ExactSubsequenceAutomatonLinearString = ExactSubsequenceAutomaton::RegistratorWrapper<automaton::DFA, string::LinearString>(ExactSubsequenceAutomaton::construct); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.h b/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.h index 5b7533f7744aea337655187455540b68ae013782..2bda8c07999dd059af5da6448bf83b304504eaf7 100644 --- a/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.h +++ b/alib2algo/src/stringology/exact/ExactSubsequenceAutomaton.h @@ -18,7 +18,7 @@ namespace stringology { namespace exact { -class ExactSubsequenceAutomaton : public std::SingleDispatch<automaton::Automaton, string::StringBase> { +class ExactSubsequenceAutomaton : public std::SingleDispatch<ExactSubsequenceAutomaton, automaton::Automaton, string::StringBase> { public: /** * Performs conversion. @@ -27,11 +27,6 @@ public: static automaton::Automaton construct(const string::String& text); static automaton::DFA construct(const string::LinearString& text); - - static ExactSubsequenceAutomaton& getInstance() { - static ExactSubsequenceAutomaton res; - return res; - } }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/FactorOracleAutomaton.cpp b/alib2algo/src/stringology/exact/FactorOracleAutomaton.cpp index 3900e37689392c7040486f638bded4e2dc9b6609..dafa9e1954248c4218f2e78ebd00e2c6d9ceead2 100644 --- a/alib2algo/src/stringology/exact/FactorOracleAutomaton.cpp +++ b/alib2algo/src/stringology/exact/FactorOracleAutomaton.cpp @@ -2,7 +2,7 @@ * Author: Radovan Cerveny */ -#include "FactorOracleAutomaton.hpp" +#include "FactorOracleAutomaton.h" #include <string/LinearString.h> namespace stringology { @@ -10,7 +10,7 @@ namespace stringology { namespace exact { automaton::Automaton FactorOracleAutomaton::construct ( const string::String & pattern ) { - return getInstance ( ).dispatch ( pattern.getData ( ) ); + return dispatch ( pattern.getData ( ) ); } automaton::DFA FactorOracleAutomaton::construct ( const string::LinearString & pattern ) { @@ -51,7 +51,7 @@ void FactorOracleAutomaton::oracleAddLetter ( automaton::DFA & oracle, const alp supplyFunction.insert( { newState, supplyState } ); } -auto FactorOracleAutomatonLinearString = FactorOracleAutomaton::RegistratorWrapper < automaton::DFA, string::LinearString > ( FactorOracleAutomaton::getInstance ( ), FactorOracleAutomaton::construct ); +auto FactorOracleAutomatonLinearString = FactorOracleAutomaton::RegistratorWrapper < automaton::DFA, string::LinearString > ( FactorOracleAutomaton::construct ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/FactorOracleAutomaton.hpp b/alib2algo/src/stringology/exact/FactorOracleAutomaton.h similarity index 69% rename from alib2algo/src/stringology/exact/FactorOracleAutomaton.hpp rename to alib2algo/src/stringology/exact/FactorOracleAutomaton.h index 043eab4a78797ea9d763104dfee0888701cbbe94..72fd167d9c9acce00e2f0d4218840fe358b8db9a 100644 --- a/alib2algo/src/stringology/exact/FactorOracleAutomaton.hpp +++ b/alib2algo/src/stringology/exact/FactorOracleAutomaton.h @@ -2,8 +2,8 @@ * Author: Radovan Cerveny */ -#ifndef FACTOR_ORACLE_AUTOMATON_HPP__ -#define FACTOR_ORACLE_AUTOMATON_HPP__ +#ifndef FACTOR_ORACLE_AUTOMATON_H__ +#define FACTOR_ORACLE_AUTOMATON_H__ #include <automaton/Automaton.h> #include <automaton/FSM/DFA.h> @@ -15,7 +15,7 @@ namespace stringology { namespace exact { -class FactorOracleAutomaton : public std::SingleDispatch < automaton::Automaton, string::StringBase > { +class FactorOracleAutomaton : public std::SingleDispatch < FactorOracleAutomaton, automaton::Automaton, string::StringBase > { private: static void oracleAddLetter ( automaton::DFA & oracle, const alphabet::Symbol & symbol, std::map < automaton::State, automaton::State > & supplyFunction ); @@ -28,16 +28,10 @@ public: static automaton::DFA construct ( const string::LinearString & pattern ); - static FactorOracleAutomaton & getInstance ( ) { - static FactorOracleAutomaton res; - - return res; - } - }; } /* namespace exact */ } /* namespace stringology */ -#endif /* FACTOR_ORACLE_AUTOMATON_HPP__ */ +#endif /* FACTOR_ORACLE_AUTOMATON_H__ */ diff --git a/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.cpp b/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.cpp index cac6f0a6e8d84fe255ef487f72824d997d23813a..5332c673a0405a67a321a60bf1b853c16a9708a0 100644 --- a/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.cpp +++ b/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.cpp @@ -15,7 +15,7 @@ namespace stringology { namespace exact { std::map < alphabet::Symbol, size_t > ReversedBadCharacterShiftTable::bcs ( const string::String & pattern ) { - return getInstance ( ).dispatch ( pattern.getData ( ) ); + return dispatch ( pattern.getData ( ) ); } std::map < alphabet::Symbol, size_t > ReversedBadCharacterShiftTable::bcs ( const string::LinearString & pattern ) { @@ -33,7 +33,7 @@ std::map < alphabet::Symbol, size_t > ReversedBadCharacterShiftTable::bcs ( cons return bcs; } -auto ReversedBadCharacterShiftTableLinearString = ReversedBadCharacterShiftTable::RegistratorWrapper < std::map < alphabet::Symbol, size_t >, string::LinearString > ( ReversedBadCharacterShiftTable::getInstance ( ), ReversedBadCharacterShiftTable::bcs ); +auto ReversedBadCharacterShiftTableLinearString = ReversedBadCharacterShiftTable::RegistratorWrapper < std::map < alphabet::Symbol, size_t >, string::LinearString > ( ReversedBadCharacterShiftTable::bcs ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.h b/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.h index 1a99df388a293943517fc75a02ee321c447862ca..4bdc76cd2f95d115cdc3f5101f0084b9ad6166fa 100644 --- a/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.h +++ b/alib2algo/src/stringology/exact/ReversedBadCharacterShiftTable.h @@ -23,7 +23,7 @@ namespace exact { * Computation of BCS table for BMH from MI(E+\eps)-EVY course 2014 * To get rid of zeros in BCS table we ignore last haystack character */ -class ReversedBadCharacterShiftTable : public std::SingleDispatch < std::map < alphabet::Symbol, size_t >, string::StringBase > { +class ReversedBadCharacterShiftTable : public std::SingleDispatch < ReversedBadCharacterShiftTable, std::map < alphabet::Symbol, size_t >, string::StringBase > { public: /** * Search for pattern in linear string. @@ -33,12 +33,6 @@ public: static std::map < alphabet::Symbol, size_t > bcs ( const string::LinearString & pattern ); - static ReversedBadCharacterShiftTable & getInstance ( ) { - static ReversedBadCharacterShiftTable res; - - return res; - } - }; } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/SuffixAutomaton.cpp b/alib2algo/src/stringology/exact/SuffixAutomaton.cpp index 8cb34d1b5d68954b5dd6cdf9f26acf1f80cd08b9..ecfd5610a1b1a4e4655cca130f148244013332b4 100644 --- a/alib2algo/src/stringology/exact/SuffixAutomaton.cpp +++ b/alib2algo/src/stringology/exact/SuffixAutomaton.cpp @@ -2,7 +2,7 @@ * Author: Radovan Cerveny */ -#include "SuffixAutomaton.hpp" +#include "SuffixAutomaton.h" #include <string/Epsilon.h> #include <label/LabelSetLabel.h> #include "../../automaton/determinize/Determinize.h" @@ -14,7 +14,7 @@ namespace stringology { namespace exact { automaton::Automaton SuffixAutomaton::naiveConstruct ( const string::String & pattern ) { - return getInstance ( ).dispatch ( pattern.getData ( ) ); + return dispatch ( pattern.getData ( ) ); } automaton::DFA SuffixAutomaton::naiveConstruct ( const string::LinearString & pattern ) { @@ -48,7 +48,7 @@ automaton::DFA SuffixAutomaton::naiveConstruct ( const string::LinearString & pa } automaton::Automaton SuffixAutomaton::construct ( const string::String & pattern ) { - return getInstance ( ).dispatch ( pattern.getData ( ) ); + return dispatch ( pattern.getData ( ) ); } automaton::DFA SuffixAutomaton::construct ( const string::LinearString & pattern ) { @@ -122,7 +122,7 @@ void SuffixAutomaton::suffixAutomatonAddSymbol ( automaton::DFA & suffixAutomato lastState = newState; } -auto SuffixAutomatonLinearString = SuffixAutomaton::RegistratorWrapper < automaton::DFA, string::LinearString > ( SuffixAutomaton::getInstance ( ), SuffixAutomaton::construct ); +auto SuffixAutomatonLinearString = SuffixAutomaton::RegistratorWrapper < automaton::DFA, string::LinearString > ( SuffixAutomaton::construct ); } /* namespace exact */ diff --git a/alib2algo/src/stringology/exact/SuffixAutomaton.hpp b/alib2algo/src/stringology/exact/SuffixAutomaton.h similarity index 80% rename from alib2algo/src/stringology/exact/SuffixAutomaton.hpp rename to alib2algo/src/stringology/exact/SuffixAutomaton.h index ca033a5135d0246531186d33cb978701e4caa7b3..9854565abfdbb221a313fa8ddd86f7acc31adfa5 100644 --- a/alib2algo/src/stringology/exact/SuffixAutomaton.hpp +++ b/alib2algo/src/stringology/exact/SuffixAutomaton.h @@ -2,8 +2,8 @@ * Author: Radovan Cerveny */ -#ifndef SUFFIX_AUTOMATON_HPP_ -#define SUFFIX_AUTOMATON_HPP_ +#ifndef SUFFIX_AUTOMATON_H_ +#define SUFFIX_AUTOMATON_H_ #include <automaton/Automaton.h> #include <automaton/FSM/DFA.h> @@ -16,7 +16,7 @@ namespace stringology { namespace exact { -class SuffixAutomaton : public std::SingleDispatch < automaton::Automaton, string::StringBase > { +class SuffixAutomaton : public std::SingleDispatch < SuffixAutomaton, automaton::Automaton, string::StringBase > { private: static void suffixAutomatonAddSymbol ( automaton::DFA & suffixAutomaton, const alphabet::Symbol & symbol, std::map < automaton::State, std::pair<automaton::State, int > > & suffixLinks, automaton::State & lastState ); @@ -37,16 +37,10 @@ public: static automaton::DFA construct ( const string::LinearString & pattern ); - static SuffixAutomaton & getInstance ( ) { - static SuffixAutomaton res; - - return res; - } - }; } /* namespace exact */ } /* namespace stringology */ -#endif /* SUFFIX_AUTOMATON_HPP_ */ +#endif /* SUFFIX_AUTOMATON_H_ */ diff --git a/alib2algo/src/stringology/indexing/SuffixTrie.cpp b/alib2algo/src/stringology/indexing/SuffixTrie.cpp index 03c79ad84ed8dbf4a4d84fee8ceb3aec5f05feb2..dcf497ef2eb1ea1745d835c1ef6a3b238c806189 100644 --- a/alib2algo/src/stringology/indexing/SuffixTrie.cpp +++ b/alib2algo/src/stringology/indexing/SuffixTrie.cpp @@ -17,7 +17,7 @@ namespace stringology { namespace indexing { indexes::SuffixTrieFinalMark SuffixTrie::construct ( const string::String & string ) { - return getInstance ( ).dispatch ( string.getData ( ) ); + return dispatch ( string.getData ( ) ); } indexes::SuffixTrieFinalMark SuffixTrie::construct ( const string::LinearString & w ) { @@ -40,7 +40,7 @@ indexes::SuffixTrieFinalMark SuffixTrie::construct ( const string::LinearString return res; } -auto SuffixTrieLinearString = SuffixTrie::RegistratorWrapper < indexes::SuffixTrieFinalMark, string::LinearString > ( SuffixTrie::getInstance ( ), SuffixTrie::construct ); +auto SuffixTrieLinearString = SuffixTrie::RegistratorWrapper < indexes::SuffixTrieFinalMark, string::LinearString > ( SuffixTrie::construct ); indexes::SuffixTrieTerminatingSymbol SuffixTrie::construct ( const string::LinearStringTerminatingSymbol & w ) { indexes::SuffixTrieTerminatingSymbol res ( w.getAlphabet ( ), w.getTerminatingSymbol ( ) ); @@ -60,7 +60,7 @@ indexes::SuffixTrieTerminatingSymbol SuffixTrie::construct ( const string::Linea return res; } -auto SuffixTrieTerminatingSymbolLinearStringTerminatingSymbol = SuffixTrie::RegistratorWrapper < indexes::SuffixTrieTerminatingSymbol, string::LinearStringTerminatingSymbol > ( SuffixTrie::getInstance ( ), SuffixTrie::construct ); +auto SuffixTrieTerminatingSymbolLinearStringTerminatingSymbol = SuffixTrie::RegistratorWrapper < indexes::SuffixTrieTerminatingSymbol, string::LinearStringTerminatingSymbol > ( SuffixTrie::construct ); } /* namespace indexing */ diff --git a/alib2algo/src/stringology/indexing/SuffixTrie.h b/alib2algo/src/stringology/indexing/SuffixTrie.h index 029fbd59352efb5493072deefda86927756823c2..ca75df33e4d9e2e116ed86a3e5f58782a89feb8d 100644 --- a/alib2algo/src/stringology/indexing/SuffixTrie.h +++ b/alib2algo/src/stringology/indexing/SuffixTrie.h @@ -25,7 +25,7 @@ namespace indexing { * Source: Lectures MI-EVY (CTU in Prague), Year 2014, Lecture 3, slide 4 */ -class SuffixTrie : public std::SingleDispatch < indexes::SuffixTrieFinalMark, string::StringBase > { +class SuffixTrie : public std::SingleDispatch < SuffixTrie, indexes::SuffixTrieFinalMark, string::StringBase > { public: /** * Creates suffix trie @@ -37,13 +37,6 @@ public: static indexes::SuffixTrieFinalMark construct ( const string::LinearString & string ); static indexes::SuffixTrieTerminatingSymbol construct ( const string::LinearStringTerminatingSymbol & string ); -public: - static SuffixTrie & getInstance ( ) { - static SuffixTrie res; - - return res; - } - }; } /* namespace indexing */ diff --git a/alib2algo/test-src/stringology/exact/FactorOracleAutomatonTest.cpp b/alib2algo/test-src/stringology/exact/FactorOracleAutomatonTest.cpp index fa23d8bf8e673dfe736c8470b3cc367778d888fc..b5e3c15668795a486f9083a4dd1537cdee251b4d 100644 --- a/alib2algo/test-src/stringology/exact/FactorOracleAutomatonTest.cpp +++ b/alib2algo/test-src/stringology/exact/FactorOracleAutomatonTest.cpp @@ -1,7 +1,7 @@ #include "FactorOracleAutomatonTest.h" #include "string/LinearString.h" -#include "stringology/exact/FactorOracleAutomaton.hpp" +#include "stringology/exact/FactorOracleAutomaton.h" #include "stringology/exact/BackwardOracleMatching.hpp" #include "string/generate/RandomStringFactory.h" diff --git a/alib2algo/test-src/stringology/exact/SuffixAutomatonTest.cpp b/alib2algo/test-src/stringology/exact/SuffixAutomatonTest.cpp index bee259d485a53c7d043efa24ba968400637df461..a9d54e27db6feb45dab6f80cc5f95468be783115 100644 --- a/alib2algo/test-src/stringology/exact/SuffixAutomatonTest.cpp +++ b/alib2algo/test-src/stringology/exact/SuffixAutomatonTest.cpp @@ -1,7 +1,7 @@ #include "SuffixAutomatonTest.h" #include "string/LinearString.h" -#include "stringology/exact/SuffixAutomaton.hpp" +#include "stringology/exact/SuffixAutomaton.h" #include "stringology/exact/BackwardDAWGMatching.hpp" #include "string/generate/RandomStringFactory.h" diff --git a/alib2common/src/XmlApi.hpp b/alib2common/src/XmlApi.hpp index 32fe137a810767134525c4b1e2ea3bbc41bc2757..d8ac8c96dda92d1cd88d4e60c431ff27f8fc9a69 100644 --- a/alib2common/src/XmlApi.hpp +++ b/alib2common/src/XmlApi.hpp @@ -18,6 +18,7 @@ #include "object/ObjectBase.h" #include "base/CommonWrapperBase.h" +#include "exception/CommonException.h" namespace alib { @@ -123,7 +124,7 @@ public: }; static Group parse ( std::deque < sax::Token >::iterator & data ) { - xmlApiInputContext & input = ( xmlApiInputContext & ) data; + xmlApiInputContext & input = ( xmlApiInputContext & ) data; const std::string & tagName = sax::FromXMLParserHelper::getTokenData ( input, sax::Token::TokenType::START_ELEMENT ); if ( tagName == Group::XML_TAG_NAME_REF ) { @@ -134,13 +135,13 @@ public: sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, Group::XML_TAG_NAME_REF ); std::map < int, void * >::iterator elem = input.idToInstance ( Group::XML_TAG_NAME_REF ).find ( id ); - if ( elem == input.idToInstance ( Group::XML_TAG_NAME_REF ).end ( ) ) throw std::runtime_error ( "XML Inconsistent" ); + if ( elem == input.idToInstance ( Group::XML_TAG_NAME_REF ).end ( ) ) throw exception::CommonException ( "XML Inconsistent" ); return * ( ( Group * ) elem->second ); } else { typename std::map < std::string, ParserRegisterBase * >::iterator callback = parseFunctions ( ).find ( tagName ); - if ( callback == parseFunctions ( ).end ( ) ) throw std::bad_function_call ( ); + if ( callback == parseFunctions ( ).end ( ) ) throw exception::CommonException ( "Parse callback for " + tagName + " tag not registered." ); Group * res = new Group ( callback->second->parse ( input ) ); input.idToInstance ( Group::XML_TAG_NAME_REF ).insert ( std::make_pair ( input.idToInstanceMax ( Group::XML_TAG_NAME_REF )++, ( void * ) res ) ); diff --git a/alib2common/src/core/multipleDispatch.hpp b/alib2common/src/core/multipleDispatch.hpp index 23edf7be7cfbd58f2be91c165861fed841cfacde..8dc6e96153d668b6512936aa5f8a30a35143a301 100644 --- a/alib2common/src/core/multipleDispatch.hpp +++ b/alib2common/src/core/multipleDispatch.hpp @@ -14,10 +14,11 @@ #include <iostream> #include "../cast/CastApi.hpp" +#include "../exception/CommonException.h" namespace std { -template < class ReturnType, class FirstParameterType > +template < class Algorithm, class ReturnType, class FirstParameterType > class SingleDispatch { public: class RegistratorWrapperBase { @@ -26,10 +27,13 @@ public: }; private: - typedef SingleDispatch < ReturnType, FirstParameterType > SelfType; + std::map < std::type_index, RegistratorWrapperBase * > registeredFunctions; - std::map < std::type_index, typename SelfType::RegistratorWrapperBase * > registeredFunctions; + static SingleDispatch<Algorithm, ReturnType, FirstParameterType>& getInstance() { + static SingleDispatch<Algorithm, ReturnType, FirstParameterType> res; + return res; + } public: template < class RealReturnType, class RealFirstParameterType > class RegistratorWrapper : public RegistratorWrapperBase { @@ -40,24 +44,33 @@ public: return ReturnType ( callback ( ( const RealFirstParameterType & ) first ) ); } - RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( const RealFirstParameterType & ) ) : callback ( callback ) { - if ( !pool.registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), this ) ).second ) - throw std::logic_error ( "Callback alreary registered." ); + RegistratorWrapper ( RealReturnType ( * callback ) ( const RealFirstParameterType & ) ) : callback ( callback ) { + if ( !getInstance().registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), this ) ).second ) { + char* firstName = std::type_name<RealFirstParameterType>(); + std::string firstType(firstName); + std::free(firstName); + + char* name = std::type_name<Algorithm>(); + std::string classType(name); + std::free(name); + + throw ::exception::CommonException ( "Callback for " + firstType + " already registered on " + classType + "." ); + } } }; - ReturnType dispatch ( const FirstParameterType & first ) { - typename std::map < std::type_index, RegistratorWrapperBase * >::iterator callback = registeredFunctions.find ( std::type_index ( typeid ( first ) ) ); + static ReturnType dispatch ( const FirstParameterType & first ) { + typename std::map < std::type_index, RegistratorWrapperBase * >::iterator callback = getInstance().registeredFunctions.find ( std::type_index ( typeid ( first ) ) ); - if ( callback == registeredFunctions.end ( ) ) throw std::bad_function_call ( ); + if ( callback == getInstance().registeredFunctions.end ( ) ) throw std::bad_function_call ( ); return callback->second->eval ( first ); } }; -template < class ReturnType, class StaticParamType, class FirstParameterType > +template < class Algorithm, class ReturnType, class StaticParamType, class FirstParameterType > class SingleDispatchFirstStaticParam { public: class RegistratorWrapperBase { @@ -66,9 +79,13 @@ public: }; private: - typedef SingleDispatchFirstStaticParam < ReturnType, StaticParamType, FirstParameterType > SelfType; + std::map < std::type_index, RegistratorWrapperBase * > registeredFunctions; - std::map < std::type_index, typename SelfType::RegistratorWrapperBase * > registeredFunctions; + static SingleDispatchFirstStaticParam < Algorithm, ReturnType, StaticParamType, FirstParameterType > & getInstance() { + static SingleDispatchFirstStaticParam < Algorithm, ReturnType, StaticParamType, FirstParameterType > res; + + return res; + } public: template < class RealReturnType, class RealFirstParameterType > @@ -80,24 +97,33 @@ public: return ReturnType ( callback ( res, ( const RealFirstParameterType & ) first ) ); } - RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( StaticParamType, const RealFirstParameterType & ) ) : callback ( callback ) { - if ( !pool.registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), this ) ).second ) - throw std::logic_error ( "Callback alreary registered." ); + RegistratorWrapper ( RealReturnType ( * callback ) ( StaticParamType, const RealFirstParameterType & ) ) : callback ( callback ) { + if ( !getInstance().registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), this ) ).second ) { + char* firstName = std::type_name<RealFirstParameterType>(); + std::string firstType(firstName); + std::free(firstName); + + char* name = std::type_name<Algorithm>(); + std::string classType(name); + std::free(name); + + throw ::exception::CommonException ( "Callback for " + firstType + " already registered on " + classType + "." ); + } } }; - ReturnType dispatch ( StaticParamType res, const FirstParameterType & first ) { - typename std::map < std::type_index, RegistratorWrapperBase * >::iterator callback = registeredFunctions.find ( std::type_index ( typeid ( first ) ) ); + static ReturnType dispatch ( StaticParamType res, const FirstParameterType & first ) { + typename std::map < std::type_index, RegistratorWrapperBase * >::iterator callback = getInstance().registeredFunctions.find ( std::type_index ( typeid ( first ) ) ); - if ( callback == registeredFunctions.end ( ) ) throw std::bad_function_call ( ); + if ( callback == getInstance().registeredFunctions.end ( ) ) throw std::bad_function_call ( ); return callback->second->eval ( res, first ); } }; -template < class ReturnType, class FirstParameterType, class StaticParamType > +template < class Algorithm, class ReturnType, class FirstParameterType, class StaticParamType > class SingleDispatchLastStaticParam { public: class RegistratorWrapperBase { @@ -106,9 +132,13 @@ public: }; private: - typedef SingleDispatchLastStaticParam < ReturnType, FirstParameterType, StaticParamType > SelfType; + std::map < std::type_index, RegistratorWrapperBase * > registeredFunctions; - std::map < std::type_index, typename SelfType::RegistratorWrapperBase * > registeredFunctions; + static SingleDispatchLastStaticParam < Algorithm, ReturnType, FirstParameterType, StaticParamType > & getInstance() { + static SingleDispatchLastStaticParam < Algorithm, ReturnType, FirstParameterType, StaticParamType > res; + + return res; + } public: template < class RealReturnType, class RealFirstParameterType > @@ -120,17 +150,26 @@ public: return ReturnType ( callback ( ( const RealFirstParameterType & ) first, res ) ); } - RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( const RealFirstParameterType &, StaticParamType ) ) : callback ( callback ) { - if ( !pool.registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), this ) ).second ) - throw std::logic_error ( "Callback alreary registered." ); + RegistratorWrapper ( RealReturnType ( * callback ) ( const RealFirstParameterType &, StaticParamType ) ) : callback ( callback ) { + if ( !getInstance().registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), this ) ).second ) { + char* firstName = std::type_name<RealFirstParameterType>(); + std::string firstType(firstName); + std::free(firstName); + + char* name = std::type_name<Algorithm>(); + std::string classType(name); + std::free(name); + + throw ::exception::CommonException ( "Callback for " + firstType + " already registered on " + classType + "." ); + } } }; - ReturnType dispatch ( const FirstParameterType & first, StaticParamType res ) { - typename std::map < std::type_index, RegistratorWrapperBase * >::iterator callback = registeredFunctions.find ( std::type_index ( typeid ( first ) ) ); + static ReturnType dispatch ( const FirstParameterType & first, StaticParamType res ) { + typename std::map < std::type_index, RegistratorWrapperBase * >::iterator callback = getInstance().registeredFunctions.find ( std::type_index ( typeid ( first ) ) ); - if ( callback == registeredFunctions.end ( ) ) throw std::bad_function_call ( ); + if ( callback == getInstance().registeredFunctions.end ( ) ) throw std::bad_function_call ( ); return callback->second->eval ( first, res ); } @@ -162,7 +201,7 @@ public: RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( const RealFirstParameterType &, FirstStaticParamType, SecondStaticParamType ) ) : callback ( callback ) { if ( !pool.registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), this ) ).second ) - throw std::logic_error ( "Callback alreary registered." ); + throw std::logic_error ( "Callback already registered." ); } }; @@ -223,7 +262,7 @@ public: RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( const RealParametersType &, const RealParametersType & ) ) : callback ( callback ) { if ( !pool.registeredFunctions.insert ( std::make_pair ( std::type_index ( typeid ( RealParametersType ) ), this ) ).second ) - throw std::logic_error ( "Callback alreary registered." ); + throw std::logic_error ( "Callback already registered." ); } }; @@ -269,7 +308,7 @@ public: RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( const RealFirstParameterType &, const RealSecondParameterType & ) ) : callback ( callback ) { if ( !pool.registeredFunctions.insert ( std::make_pair ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), std::type_index ( typeid ( RealSecondParameterType ) ) ), this ) ).second ) - throw std::logic_error ( "Callback alreary registered." ); + throw std::logic_error ( "Callback already registered." ); } }; @@ -309,7 +348,7 @@ public: RegistratorWrapper ( SelfType & pool, RealReturnType ( * callback ) ( StaticParamType, const RealFirstParameterType &, const RealSecondParameterType & ) ) : callback ( callback ) { if ( !pool.registeredFunctions.insert ( std::make_pair ( std::make_pair ( std::type_index ( typeid ( RealFirstParameterType ) ), std::type_index ( typeid ( RealSecondParameterType ) ) ), this ) ).second ) - throw std::logic_error ( "Callback alreary registered." ); + throw std::logic_error ( "Callback already registered." ); } }; diff --git a/alib2common/test-src/core/DispatchTest.cpp b/alib2common/test-src/core/DispatchTest.cpp index 0de0412ca10094474bfc0cf24859e17c56d32341..e66dd8ecf092b1d8750b302f8be7cff8d57225d4 100644 --- a/alib2common/test-src/core/DispatchTest.cpp +++ b/alib2common/test-src/core/DispatchTest.cpp @@ -140,7 +140,7 @@ public: // ------------------------------------------------------------------------------------------------------------------------------------------------------- -class TmpVisitor : public std::SingleDispatch < int, TmpBase > { +class TmpVisitor : public std::SingleDispatch < TmpVisitor, int, TmpBase > { public: static int eval ( const Tmp2 & first ) { std::cout << first << std::endl; @@ -155,13 +155,7 @@ public: } static int eval ( const TmpBase & first ) { - return getInstance ( ).dispatch ( first ); - } - - static TmpVisitor & getInstance ( ) { - static TmpVisitor res; - - return res; + return dispatch ( first ); } }; @@ -172,9 +166,9 @@ int TmpVisitorExtensionTmp1 ( const Tmp1 & first ) { return 1; } -TmpVisitor::RegistratorWrapper < int, Tmp1 > TmpVisitorTmp1 = TmpVisitor::RegistratorWrapper < int, Tmp1 > ( TmpVisitor::getInstance ( ), TmpVisitorExtensionTmp1 ); -TmpVisitor::RegistratorWrapper < int, Tmp2 > TmpVisitorTmp2 = TmpVisitor::RegistratorWrapper < int, Tmp2 > ( TmpVisitor::getInstance ( ), TmpVisitor::eval ); -TmpVisitor::RegistratorWrapper < int, Tmp3 > TmpVisitorTmp3 = TmpVisitor::RegistratorWrapper < int, Tmp3 > ( TmpVisitor::getInstance ( ), TmpVisitor::eval ); +auto TmpVisitorTmp1 = TmpVisitor::RegistratorWrapper < int, Tmp1 > ( TmpVisitorExtensionTmp1 ); +auto TmpVisitorTmp2 = TmpVisitor::RegistratorWrapper < int, Tmp2 > ( TmpVisitor::eval ); +auto TmpVisitorTmp3 = TmpVisitor::RegistratorWrapper < int, Tmp3 > ( TmpVisitor::eval ); } /* namespace dispatch */ @@ -201,7 +195,7 @@ namespace dispatch { // ------------------------------------------------------------------------------------------------------------------------------------------------------- -class TmpVisitor2 : public std::SingleDispatchFirstStaticParam < void, int &, TmpBase > { +class TmpVisitor2 : public std::SingleDispatchFirstStaticParam < TmpVisitor2, void, int &, TmpBase > { public: static void eval ( int & res, const Tmp2 & first ) { std::cout << first << std::endl; @@ -216,13 +210,7 @@ public: } static void eval ( int & res, const TmpBase & first ) { - getInstance ( ).dispatch ( res, first ); - } - - static TmpVisitor2 & getInstance ( ) { - static TmpVisitor2 res; - - return res; + dispatch ( res, first ); } }; @@ -233,9 +221,9 @@ void TmpVisitor2ExtensionTmp1 ( int & res, const Tmp1 & first ) { res = 1; } -TmpVisitor2::RegistratorWrapper < void, Tmp1 > TmpVisitor2Tmp1 = TmpVisitor2::RegistratorWrapper < void, Tmp1 > ( TmpVisitor2::getInstance ( ), TmpVisitor2ExtensionTmp1 ); -TmpVisitor2::RegistratorWrapper < void, Tmp2 > TmpVisitor2Tmp2 = TmpVisitor2::RegistratorWrapper < void, Tmp2 > ( TmpVisitor2::getInstance ( ), TmpVisitor2::eval ); -TmpVisitor2::RegistratorWrapper < void, Tmp3 > TmpVisitor2Tmp3 = TmpVisitor2::RegistratorWrapper < void, Tmp3 > ( TmpVisitor2::getInstance ( ), TmpVisitor2::eval ); +auto TmpVisitor2Tmp1 = TmpVisitor2::RegistratorWrapper < void, Tmp1 > ( TmpVisitor2ExtensionTmp1 ); +auto TmpVisitor2Tmp2 = TmpVisitor2::RegistratorWrapper < void, Tmp2 > ( TmpVisitor2::eval ); +auto TmpVisitor2Tmp3 = TmpVisitor2::RegistratorWrapper < void, Tmp3 > ( TmpVisitor2::eval ); } /* namespace dispatch */ diff --git a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp index b80d3c730817713faea4de61281ff3f3a4d5f47e..edcf29337ca839a19e447ba4aa63372ea9c8db9b 100644 --- a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp +++ b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.cpp @@ -66,7 +66,7 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return res; } -auto AllEpsilonClosureEpsilonNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::EpsilonNFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureEpsilonNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::EpsilonNFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::MultiInitialStateNFA & fsm) { std::map<automaton::State, std::set<automaton::State>> closure; @@ -75,7 +75,7 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return closure; } -auto AllEpsilonClosureMultiInitialStateNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::MultiInitialStateNFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureMultiInitialStateNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::MultiInitialStateNFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::NFA & fsm) { std::map<automaton::State, std::set<automaton::State>> closure; @@ -84,7 +84,7 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return closure; } -auto AllEpsilonClosureNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::NFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::NFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::DFA & fsm) { std::map<automaton::State, std::set<automaton::State>> closure; @@ -93,7 +93,7 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return closure; } -auto AllEpsilonClosureDFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::DFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureDFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::DFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::ExtendedNFA & fsm) { std::map<automaton::State, std::set<automaton::State>> res; @@ -122,7 +122,7 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return res; } -auto AllEpsilonClosureExtendedNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::ExtendedNFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureExtendedNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::ExtendedNFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure( const automaton::CompactNFA & fsm) { std::map<automaton::State, std::set<automaton::State>> res; @@ -151,10 +151,10 @@ std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEps return res; } -auto AllEpsilonClosureCompactNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::CompactNFA>(AllEpsilonClosure::getInstance(), AllEpsilonClosure::allEpsilonClosure); +auto AllEpsilonClosureCompactNFA = AllEpsilonClosure::RegistratorWrapper<std::map<automaton::State, std::set<automaton::State>>, automaton::CompactNFA>(AllEpsilonClosure::allEpsilonClosure); std::map<automaton::State, std::set<automaton::State>> AllEpsilonClosure::allEpsilonClosure(const Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h index 8cd2b5ad4701656b82843d06ab768498d96ecc12..c0fd91d0a9a8261906904f18e0e257216e4a789e 100644 --- a/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h +++ b/alib2elgo/src/automaton/properties/efficient/AllEpsilonClosure.h @@ -21,7 +21,7 @@ namespace properties { namespace efficient { -class AllEpsilonClosure : public std::SingleDispatch<std::map<automaton::State, std::set<automaton::State>>, automaton::AutomatonBase> { +class AllEpsilonClosure : public std::SingleDispatch<AllEpsilonClosure, std::map<automaton::State, std::set<automaton::State>>, automaton::AutomatonBase> { public: static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::Automaton & automaton); @@ -34,11 +34,6 @@ public: static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::DFA & fsm); static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::ExtendedNFA & fsm); static std::map<automaton::State, std::set<automaton::State>> allEpsilonClosure( const automaton::CompactNFA & fsm); - - static AllEpsilonClosure& getInstance() { - static AllEpsilonClosure res; - return res; - } }; } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp b/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp index 583d37f0a80acd965e0276a74cad6e341a0c35b7..368b450f8fa045133b642e3f21c8df15e75f9faa 100644 --- a/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp +++ b/alib2elgo/src/automaton/properties/efficient/ReachableStates.cpp @@ -24,7 +24,7 @@ namespace properties { namespace efficient { std::set<automaton::State> ReachableStates::reachableStates(const Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } template<class T> @@ -49,10 +49,10 @@ std::set<automaton::State> ReachableStates::reachableStates( const T & fsm ) { return visited; } -auto ReachableStatesEpsilonNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); -auto ReachableStatesNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); -auto ReachableStatesCompactNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); -auto ReachableStatesExtendedNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); +auto ReachableStatesEpsilonNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(ReachableStates::reachableStates); +auto ReachableStatesNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(ReachableStates::reachableStates); +auto ReachableStatesCompactNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(ReachableStates::reachableStates); +auto ReachableStatesExtendedNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(ReachableStates::reachableStates); template<> std::set<automaton::State> ReachableStates::reachableStates( const automaton::MultiInitialStateNFA & fsm ) { @@ -76,7 +76,7 @@ std::set<automaton::State> ReachableStates::reachableStates( const automaton::Mu return visited; } -auto ReachableStatesMultiInitialStateNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); +auto ReachableStatesMultiInitialStateNFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(ReachableStates::reachableStates); template<> std::set<automaton::State> ReachableStates::reachableStates( const automaton::DFA & fsm ) { @@ -100,7 +100,7 @@ std::set<automaton::State> ReachableStates::reachableStates( const automaton::DF return visited; } -auto ReachableStatesDFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, automaton::DFA>(ReachableStates::getInstance(), ReachableStates::reachableStates); +auto ReachableStatesDFA = ReachableStates::RegistratorWrapper<std::set<automaton::State>, 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 bbfe54ec66df0fdb510ddbafeb2e96cc362779ef..abd7a932760097f0a2660921da888eab9f55140e 100644 --- a/alib2elgo/src/automaton/properties/efficient/ReachableStates.h +++ b/alib2elgo/src/automaton/properties/efficient/ReachableStates.h @@ -22,7 +22,7 @@ namespace properties { namespace efficient { -class ReachableStates : public std::SingleDispatch<std::set<automaton::State>, automaton::AutomatonBase> { +class ReachableStates : public std::SingleDispatch<ReachableStates, std::set<automaton::State>, automaton::AutomatonBase> { public: static std::set<automaton::State> reachableStates( const automaton::Automaton & automaton ); @@ -31,11 +31,6 @@ public: */ template<class T> static std::set<automaton::State> reachableStates( const T & fsm ); - - static ReachableStates& getInstance() { - static ReachableStates res; - return res; - } }; } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp b/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp index 691c1e42f961c28470b34124b1a88621ac2110de..18128c4b7304ec5612d5b2fbaca8d109dd675b2d 100644 --- a/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp +++ b/alib2elgo/src/automaton/properties/efficient/UsefullStates.cpp @@ -24,7 +24,7 @@ namespace properties { namespace efficient { std::set<automaton::State> UsefullStates::usefullStates(const Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } template<class T> @@ -50,11 +50,11 @@ std::set<automaton::State> UsefullStates::usefullStates( const T & fsm ) { return visited; } -auto UsefullStatesEpsilonNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); -auto UsefullStatesNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); -auto UsefullStatesCompactNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); -auto UsefullStatesExtendedNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); -auto UsefullStatesMultiInitialStateNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); +auto UsefullStatesEpsilonNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::EpsilonNFA>(UsefullStates::usefullStates); +auto UsefullStatesNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::NFA>(UsefullStates::usefullStates); +auto UsefullStatesCompactNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::CompactNFA>(UsefullStates::usefullStates); +auto UsefullStatesExtendedNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::ExtendedNFA>(UsefullStates::usefullStates); +auto UsefullStatesMultiInitialStateNFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::MultiInitialStateNFA>(UsefullStates::usefullStates); template<> std::set<automaton::State> UsefullStates::usefullStates( const automaton::DFA & fsm ) { @@ -78,7 +78,7 @@ std::set<automaton::State> UsefullStates::usefullStates( const automaton::DFA & return visited; } -auto UsefullStatesDFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, automaton::DFA>(UsefullStates::getInstance(), UsefullStates::usefullStates); +auto UsefullStatesDFA = UsefullStates::RegistratorWrapper<std::set<automaton::State>, 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 886f8dfe8f70c695a188cacdf4ba40c173ab91bd..9beaf5c1de22f84912612c8a9cb4b25fe6f892a1 100644 --- a/alib2elgo/src/automaton/properties/efficient/UsefullStates.h +++ b/alib2elgo/src/automaton/properties/efficient/UsefullStates.h @@ -22,7 +22,7 @@ namespace properties { namespace efficient { -class UsefullStates : public std::SingleDispatch<std::set<automaton::State>, automaton::AutomatonBase> { +class UsefullStates : public std::SingleDispatch<UsefullStates, std::set<automaton::State>, automaton::AutomatonBase> { public: static std::set<automaton::State> usefullStates( const automaton::Automaton & automaton ); @@ -31,11 +31,6 @@ public: */ template<class T> static std::set<automaton::State> usefullStates( const T & fsm ); - - static UsefullStates& getInstance() { - static UsefullStates res; - return res; - } }; } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.cpp b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.cpp index be269dd1eff12a21a485312a9497c51defc54dbe..1430423bcd6deeea59fbef2ad0e6e3384a8a36c4 100644 --- a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.cpp +++ b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.cpp @@ -20,21 +20,21 @@ automaton::DFA EpsilonRemoverIncoming::remove(const automaton::DFA& origFSM) return origFSM; } -auto EpsilonRemoverIncomingDFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::DFA, automaton::DFA>(EpsilonRemoverIncoming::getInstance(), EpsilonRemoverIncoming::remove); +auto EpsilonRemoverIncomingDFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::DFA, automaton::DFA>(EpsilonRemoverIncoming::remove); automaton::MultiInitialStateNFA EpsilonRemoverIncoming::remove(const automaton::MultiInitialStateNFA& origFSM) { return origFSM; } -auto EpsilonRemoverIncomingMultiInitialStateNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(EpsilonRemoverIncoming::getInstance(), EpsilonRemoverIncoming::remove); +auto EpsilonRemoverIncomingMultiInitialStateNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(EpsilonRemoverIncoming::remove); automaton::NFA EpsilonRemoverIncoming::remove(const automaton::NFA& origFSM) { return origFSM; } -auto EpsilonRemoverIncomingNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::NFA, automaton::NFA>(EpsilonRemoverIncoming::getInstance(), EpsilonRemoverIncoming::remove); +auto EpsilonRemoverIncomingNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::NFA, automaton::NFA>(EpsilonRemoverIncoming::remove); automaton::NFA EpsilonRemoverIncoming::remove( const automaton::EpsilonNFA & origFSM ) { automaton::NFA fsm(origFSM.getInitialState()); @@ -76,10 +76,10 @@ automaton::NFA EpsilonRemoverIncoming::remove( const automaton::EpsilonNFA & ori return fsm; } -auto EpsilonRemoverIncomingEpsilonNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::NFA, automaton::EpsilonNFA>(EpsilonRemoverIncoming::getInstance(), EpsilonRemoverIncoming::remove); +auto EpsilonRemoverIncomingEpsilonNFA = EpsilonRemoverIncoming::RegistratorWrapper<automaton::NFA, automaton::EpsilonNFA>(EpsilonRemoverIncoming::remove); automaton::Automaton EpsilonRemoverIncoming::remove(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.h b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.h index ce26cc60cad2395f1abd1daf937b46dcc18313a5..310740786779a52807d306140dfcb207e70f1d84 100644 --- a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.h +++ b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverIncoming.h @@ -25,7 +25,7 @@ namespace simplify { namespace efficient { -class EpsilonRemoverIncoming : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class EpsilonRemoverIncoming : public std::SingleDispatch<EpsilonRemoverIncoming, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton remove( const automaton::Automaton & automaton ); @@ -36,11 +36,6 @@ public: static automaton::MultiInitialStateNFA remove( const automaton::MultiInitialStateNFA & fsm ); static automaton::NFA remove( const automaton::NFA & fsm ); static automaton::DFA remove( const automaton::DFA & fsm ); - - static EpsilonRemoverIncoming& getInstance() { - static EpsilonRemoverIncoming res; - return res; - } }; } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.cpp b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.cpp index c5f4ca59636a95576bb527d2995ef8d19799815e..424bd41a7f467aa1c59f833216fc349a1ad87090 100644 --- a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.cpp +++ b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.cpp @@ -20,21 +20,21 @@ automaton::DFA EpsilonRemoverOutgoing::remove(const automaton::DFA& origFSM) return origFSM; } -auto EpsilonRemoverOutgoingDFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::DFA, automaton::DFA>(EpsilonRemoverOutgoing::getInstance(), EpsilonRemoverOutgoing::remove); +auto EpsilonRemoverOutgoingDFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::DFA, automaton::DFA>(EpsilonRemoverOutgoing::remove); automaton::MultiInitialStateNFA EpsilonRemoverOutgoing::remove(const automaton::MultiInitialStateNFA& origFSM) { return origFSM; } -auto EpsilonRemoverOutgoingMultiInitialStateNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(EpsilonRemoverOutgoing::getInstance(), EpsilonRemoverOutgoing::remove); +auto EpsilonRemoverOutgoingMultiInitialStateNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(EpsilonRemoverOutgoing::remove); automaton::NFA EpsilonRemoverOutgoing::remove(const automaton::NFA& origFSM) { return origFSM; } -auto EpsilonRemoverOutgoingNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::NFA, automaton::NFA>(EpsilonRemoverOutgoing::getInstance(), EpsilonRemoverOutgoing::remove); +auto EpsilonRemoverOutgoingNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::NFA, automaton::NFA>(EpsilonRemoverOutgoing::remove); automaton::MultiInitialStateNFA EpsilonRemoverOutgoing::remove( const automaton::EpsilonNFA & origFSM ) { automaton::MultiInitialStateNFA fsm; @@ -60,10 +60,10 @@ automaton::MultiInitialStateNFA EpsilonRemoverOutgoing::remove( const automaton: return fsm; } -auto EpsilonRemoverOutgoingEpsilonNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::EpsilonNFA>(EpsilonRemoverOutgoing::getInstance(), EpsilonRemoverOutgoing::remove); +auto EpsilonRemoverOutgoingEpsilonNFA = EpsilonRemoverOutgoing::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::EpsilonNFA>(EpsilonRemoverOutgoing::remove); automaton::Automaton EpsilonRemoverOutgoing::remove(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /*namespace efficient */ diff --git a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.h b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.h index fe5c662adb7a9362184f7ec05e3f9f00c8e38fe2..c2449e1fa03a88e7b8fa0aa5338039d8e2e79d7e 100644 --- a/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.h +++ b/alib2elgo/src/automaton/simplify/efficient/EpsilonRemoverOutgoing.h @@ -25,7 +25,7 @@ namespace simplify { namespace efficient { -class EpsilonRemoverOutgoing : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class EpsilonRemoverOutgoing : public std::SingleDispatch<EpsilonRemoverOutgoing, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton remove( const automaton::Automaton & automaton ); @@ -36,11 +36,6 @@ public: static automaton::MultiInitialStateNFA remove( const automaton::MultiInitialStateNFA & fsm ); static automaton::NFA remove( const automaton::NFA & fsm ); static automaton::DFA remove( const automaton::DFA & fsm ); - - static EpsilonRemoverOutgoing& getInstance() { - static EpsilonRemoverOutgoing res; - return res; - } }; } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/simplify/efficient/Trim.cpp b/alib2elgo/src/automaton/simplify/efficient/Trim.cpp index fa523a97bcc94c40b4ce7ed2936c03d26b95473d..35ebb813c88bd909dc52be9fa165cfbd26b95739 100644 --- a/alib2elgo/src/automaton/simplify/efficient/Trim.cpp +++ b/alib2elgo/src/automaton/simplify/efficient/Trim.cpp @@ -29,15 +29,15 @@ T Trim::trim( const T & fsm ) { return UnreachableStatesRemover::remove(UselessStatesRemover::remove(fsm)); } -auto TrimDFA = Trim::RegistratorWrapper<automaton::DFA, automaton::DFA>(Trim::getInstance(), Trim::trim); -auto TrimNFA = Trim::RegistratorWrapper<automaton::NFA, automaton::NFA>(Trim::getInstance(), Trim::trim); -auto TrimMultiInitialStateNFA = Trim::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(Trim::getInstance(), Trim::trim); -auto TrimEpsilonNFA = Trim::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(Trim::getInstance(), Trim::trim); -auto TrimCompactNFA = Trim::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(Trim::getInstance(), Trim::trim); -auto TrimExtendedNFA = Trim::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(Trim::getInstance(), Trim::trim); +auto TrimDFA = Trim::RegistratorWrapper<automaton::DFA, automaton::DFA>(Trim::trim); +auto TrimNFA = Trim::RegistratorWrapper<automaton::NFA, automaton::NFA>(Trim::trim); +auto TrimMultiInitialStateNFA = Trim::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(Trim::trim); +auto TrimEpsilonNFA = Trim::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(Trim::trim); +auto TrimCompactNFA = Trim::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(Trim::trim); +auto TrimExtendedNFA = Trim::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(Trim::trim); automaton::Automaton Trim::trim(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/simplify/efficient/Trim.h b/alib2elgo/src/automaton/simplify/efficient/Trim.h index 496e0c81b5a99c736588cd56d12b632ccfd81f7e..5a30a346397b811bdb0b182336c993d56786e6d6 100644 --- a/alib2elgo/src/automaton/simplify/efficient/Trim.h +++ b/alib2elgo/src/automaton/simplify/efficient/Trim.h @@ -20,7 +20,7 @@ namespace simplify { namespace efficient { -class Trim : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class Trim : public std::SingleDispatch<Trim, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton trim( const automaton::Automaton & automaton ); @@ -29,11 +29,6 @@ public: */ template<class T> static T trim( const T & fsm ); - - static Trim& getInstance() { - static Trim res; - return res; - } }; } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.cpp b/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.cpp index d791112078d7335bb8070742cc34372c01d2b1d0..99bba43a2ad0b7f971f34f55ce955592b26e938b 100644 --- a/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.cpp +++ b/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.cpp @@ -52,10 +52,10 @@ T UnreachableStatesRemover::remove( const T & fsm ) { return M; } -auto UnreachableStatesRemoverEpsilonNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); -auto UnreachableStatesRemoverNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::NFA, automaton::NFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); -auto UnreachableStatesRemoverCompactNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); -auto UnreachableStatesRemoverExtendedNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverEpsilonNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::NFA, automaton::NFA>(UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverCompactNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverExtendedNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(UnreachableStatesRemover::remove); template<> automaton::DFA UnreachableStatesRemover::remove( const automaton::DFA & fsm ) { @@ -83,7 +83,7 @@ automaton::DFA UnreachableStatesRemover::remove( const automaton::DFA & fsm ) { return M; } -auto UnreachableStatesRemoverDFA = UnreachableStatesRemover::RegistratorWrapper<automaton::DFA, automaton::DFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverDFA = UnreachableStatesRemover::RegistratorWrapper<automaton::DFA, automaton::DFA>(UnreachableStatesRemover::remove); template<> automaton::MultiInitialStateNFA UnreachableStatesRemover::remove( const automaton::MultiInitialStateNFA & fsm ) { @@ -114,10 +114,10 @@ automaton::MultiInitialStateNFA UnreachableStatesRemover::remove( const automato return M; } -auto UnreachableStatesRemoverMultiInitialStateNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(UnreachableStatesRemover::getInstance(), UnreachableStatesRemover::remove); +auto UnreachableStatesRemoverMultiInitialStateNFA = UnreachableStatesRemover::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(UnreachableStatesRemover::remove); automaton::Automaton UnreachableStatesRemover::remove(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.h b/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.h index 2f45965591ce8100c889d8f00f105f13a6ef0702..1c2f5542ccc845cd44a408b3eea4e46ab81dccff 100644 --- a/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.h +++ b/alib2elgo/src/automaton/simplify/efficient/UnreachableStatesRemover.h @@ -20,7 +20,7 @@ namespace simplify { namespace efficient { -class UnreachableStatesRemover : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class UnreachableStatesRemover : public std::SingleDispatch<UnreachableStatesRemover, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton remove( const automaton::Automaton & automaton ); @@ -29,11 +29,6 @@ public: */ template<class T> static T remove( const T & automaton ); - - static UnreachableStatesRemover& getInstance() { - static UnreachableStatesRemover res; - return res; - } }; } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.cpp b/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.cpp index 78208411ad05d5fad9cb487ae6529e416c12f8dc..0b334e12de5615990d64f857a12316ea29f8331e 100644 --- a/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.cpp +++ b/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.cpp @@ -54,10 +54,10 @@ T UselessStatesRemover::remove( const T & fsm ) { return M; } -auto UselessStatesRemoverEpsilonNFA = UselessStatesRemover::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); -auto UselessStatesRemoverNFA = UselessStatesRemover::RegistratorWrapper<automaton::NFA, automaton::NFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); -auto UselessStatesRemoverCompactNFA = UselessStatesRemover::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); -auto UselessStatesRemoverExtendedNFA = UselessStatesRemover::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); +auto UselessStatesRemoverEpsilonNFA = UselessStatesRemover::RegistratorWrapper<automaton::EpsilonNFA, automaton::EpsilonNFA>(UselessStatesRemover::remove); +auto UselessStatesRemoverNFA = UselessStatesRemover::RegistratorWrapper<automaton::NFA, automaton::NFA>(UselessStatesRemover::remove); +auto UselessStatesRemoverCompactNFA = UselessStatesRemover::RegistratorWrapper<automaton::CompactNFA, automaton::CompactNFA>(UselessStatesRemover::remove); +auto UselessStatesRemoverExtendedNFA = UselessStatesRemover::RegistratorWrapper<automaton::ExtendedNFA, automaton::ExtendedNFA>(UselessStatesRemover::remove); template<> automaton::DFA UselessStatesRemover::remove( const automaton::DFA & fsm ) { @@ -87,7 +87,7 @@ automaton::DFA UselessStatesRemover::remove( const automaton::DFA & fsm ) { return M; } -auto UselessStatesRemoverDFA = UselessStatesRemover::RegistratorWrapper<automaton::DFA, automaton::DFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); +auto UselessStatesRemoverDFA = UselessStatesRemover::RegistratorWrapper<automaton::DFA, automaton::DFA>(UselessStatesRemover::remove); template<> automaton::MultiInitialStateNFA UselessStatesRemover::remove( const automaton::MultiInitialStateNFA & fsm ) { @@ -123,10 +123,10 @@ automaton::MultiInitialStateNFA UselessStatesRemover::remove( const automaton::M return M; } -auto UselessStatesRemoverMultiInitialStateNFA = UselessStatesRemover::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(UselessStatesRemover::getInstance(), UselessStatesRemover::remove); +auto UselessStatesRemoverMultiInitialStateNFA = UselessStatesRemover::RegistratorWrapper<automaton::MultiInitialStateNFA, automaton::MultiInitialStateNFA>(UselessStatesRemover::remove); automaton::Automaton UselessStatesRemover::remove(const automaton::Automaton& automaton) { - return getInstance().dispatch(automaton.getData()); + return dispatch(automaton.getData()); } } /* namespace efficient */ diff --git a/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.h b/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.h index 18168f8e9e26bfca3ea20d9c9ce00432fea0c393..d0c267ad21cd83c8a072eaa12c8f61c6fef0bfe6 100644 --- a/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.h +++ b/alib2elgo/src/automaton/simplify/efficient/UselessStatesRemover.h @@ -20,7 +20,7 @@ namespace simplify { namespace efficient { -class UselessStatesRemover : public std::SingleDispatch<automaton::Automaton, automaton::AutomatonBase> { +class UselessStatesRemover : public std::SingleDispatch<UselessStatesRemover, automaton::Automaton, automaton::AutomatonBase> { public: static automaton::Automaton remove( const automaton::Automaton & automaton ); @@ -29,11 +29,6 @@ public: */ template<class T> static T remove( const T & automaton ); - - static UselessStatesRemover& getInstance() { - static UselessStatesRemover res; - return res; - } }; } /* namespace efficient */ diff --git a/alib2raw/src/string/StringToRawComposer.cpp b/alib2raw/src/string/StringToRawComposer.cpp index 9e69c463c49c5ac86ce5f3bfd43bdd9a027dc195..2e4df53d5500c9837fce24e7512d52c5fbf839cf 100644 --- a/alib2raw/src/string/StringToRawComposer.cpp +++ b/alib2raw/src/string/StringToRawComposer.cpp @@ -11,7 +11,7 @@ namespace string { void StringToRawComposer::compose(std::ostream& out, const String& string) { - getInstance().dispatch(out, string.getData()); + dispatch(out, string.getData()); } void StringToRawComposer::compose(std::ostream& out, const LinearString& string) { @@ -20,7 +20,7 @@ void StringToRawComposer::compose(std::ostream& out, const LinearString& string) } } -StringToRawComposer::RegistratorWrapper<void, LinearString> StringToRawComposerLinearString = StringToRawComposer::RegistratorWrapper<void, LinearString>(StringToRawComposer::getInstance(), StringToRawComposer::compose); +StringToRawComposer::RegistratorWrapper<void, LinearString> StringToRawComposerLinearString = StringToRawComposer::RegistratorWrapper<void, LinearString>(StringToRawComposer::compose); } /* namespace automaton */ diff --git a/alib2raw/src/string/StringToRawComposer.h b/alib2raw/src/string/StringToRawComposer.h index b47cec5cc54c383bd45ce9bfde84dea9338615e6..5c27786f514eb2641b7a448d5914df960547cd63 100644 --- a/alib2raw/src/string/StringToRawComposer.h +++ b/alib2raw/src/string/StringToRawComposer.h @@ -20,17 +20,12 @@ namespace string { /** * This class contains methods to print XML representation of string to the output stream. */ -class StringToRawComposer : public std::SingleDispatchFirstStaticParam<void, std::ostream&, StringBase> { +class StringToRawComposer : public std::SingleDispatchFirstStaticParam<StringToRawComposer, void, std::ostream&, StringBase> { public: static void compose(std::ostream& out, const String& string); static void compose(std::ostream& out, const LinearString& string); -public: - static StringToRawComposer& getInstance() { - static StringToRawComposer res; - return res; - } }; } /* namespace string */ diff --git a/alib2raw/src/tree/TreeToRawComposer.cpp b/alib2raw/src/tree/TreeToRawComposer.cpp index ca85740c3a20ec7c1a0b9d4ca12d4f5b260b5994..9baeb82b3753d27a4e2d5b086e7f88d71d761ef1 100644 --- a/alib2raw/src/tree/TreeToRawComposer.cpp +++ b/alib2raw/src/tree/TreeToRawComposer.cpp @@ -12,34 +12,34 @@ namespace tree { void TreeToRawComposer::compose(std::deque<sax::Token>& out, const Tree& tree) { - getInstance().dispatch(out, tree.getData()); + dispatch(out, tree.getData()); } void TreeToRawComposer::compose(std::deque<sax::Token>& out, const RankedTree& tree) { composeNode(out, tree.getRoot()); } -TreeToRawComposer::RegistratorWrapper<void, RankedTree> TreeToRawComposerRankedTree = TreeToRawComposer::RegistratorWrapper<void, RankedTree>(TreeToRawComposer::getInstance(), TreeToRawComposer::compose); +TreeToRawComposer::RegistratorWrapper<void, RankedTree> TreeToRawComposerRankedTree = TreeToRawComposer::RegistratorWrapper<void, RankedTree>(TreeToRawComposer::compose); void TreeToRawComposer::compose(std::deque<sax::Token>& out, const PrefixRankedTree& tree) { unsigned i = 0; composePrefixRankedNotation(out, i, tree.getContent()); } -TreeToRawComposer::RegistratorWrapper<void, PrefixRankedTree> TreeToRawComposerPrefixRankedTree = TreeToRawComposer::RegistratorWrapper<void, PrefixRankedTree>(TreeToRawComposer::getInstance(), TreeToRawComposer::compose); +TreeToRawComposer::RegistratorWrapper<void, PrefixRankedTree> TreeToRawComposerPrefixRankedTree = TreeToRawComposer::RegistratorWrapper<void, PrefixRankedTree>(TreeToRawComposer::compose); void TreeToRawComposer::compose(std::deque<sax::Token>& out, const PrefixRankedBarTree& tree) { unsigned i = 0; composePrefixRankedBarNotation(out, i, tree.getContent()); } -TreeToRawComposer::RegistratorWrapper<void, PrefixRankedBarTree> TreeToRawComposerPrefixRankedBarTree = TreeToRawComposer::RegistratorWrapper<void, PrefixRankedBarTree>(TreeToRawComposer::getInstance(), TreeToRawComposer::compose); +TreeToRawComposer::RegistratorWrapper<void, PrefixRankedBarTree> TreeToRawComposerPrefixRankedBarTree = TreeToRawComposer::RegistratorWrapper<void, PrefixRankedBarTree>(TreeToRawComposer::compose); void TreeToRawComposer::compose(std::deque<sax::Token>& out, const UnrankedTree& tree) { composeNode(out, tree.getRoot()); } -TreeToRawComposer::RegistratorWrapper<void, UnrankedTree> TreeToRawComposerUnrankedTree = TreeToRawComposer::RegistratorWrapper<void, UnrankedTree>(TreeToRawComposer::getInstance(), TreeToRawComposer::compose); +TreeToRawComposer::RegistratorWrapper<void, UnrankedTree> TreeToRawComposerUnrankedTree = TreeToRawComposer::RegistratorWrapper<void, UnrankedTree>(TreeToRawComposer::compose); void TreeToRawComposer::composeNode(std::deque<sax::Token>& out, const RankedNode& node) { if(node.getChildren().size() == 0) { diff --git a/alib2raw/src/tree/TreeToRawComposer.h b/alib2raw/src/tree/TreeToRawComposer.h index faef0e79f9c702ec6a0e5257912c6624d4f74298..d77ba7d8ecb4090c8615dac555fd215c2a51faba 100644 --- a/alib2raw/src/tree/TreeToRawComposer.h +++ b/alib2raw/src/tree/TreeToRawComposer.h @@ -21,7 +21,7 @@ namespace tree { /** * This class contains methods to print XML representation of tree to the output stream. */ -class TreeToRawComposer : public std::SingleDispatchFirstStaticParam<void, std::deque<sax::Token>&, TreeBase> { +class TreeToRawComposer : public std::SingleDispatchFirstStaticParam<TreeToRawComposer, void, std::deque<sax::Token>&, TreeBase> { public: static void compose(std::deque<sax::Token>& out, const Tree& tree); @@ -35,12 +35,6 @@ private: static void composePrefixRankedNotation(std::deque<sax::Token>& out, unsigned& index, const std::vector<alphabet::RankedSymbol>& notation); static void composePrefixRankedBarNotation(std::deque<sax::Token>& out, unsigned& index, const std::vector<alphabet::RankedSymbol>& notation); static void composeNode(std::deque<sax::Token>& out, const UnrankedNode& node); - -public: - static TreeToRawComposer& getInstance() { - static TreeToRawComposer res; - return res; - } }; } /* namespace tree */ diff --git a/alib2str/src/alphabet/SymbolToStringComposer.cpp b/alib2str/src/alphabet/SymbolToStringComposer.cpp index eb7b6bfcf486b289974d6738f3f4e7a62c8455ad..50d224a1b0696c021966730049af0b6491009219 100644 --- a/alib2str/src/alphabet/SymbolToStringComposer.cpp +++ b/alib2str/src/alphabet/SymbolToStringComposer.cpp @@ -27,56 +27,56 @@ void SymbolToStringComposer::compose(std::ostream& out, const LabeledSymbol& sym alib::stringApi<label::Label>::compose(out, symbol.getLabel()); } -SymbolToStringComposer::RegistratorWrapper<void, LabeledSymbol> SymbolToStringComposerLabeledSymbol = SymbolToStringComposer::RegistratorWrapper<void, LabeledSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, LabeledSymbol> SymbolToStringComposerLabeledSymbol = SymbolToStringComposer::RegistratorWrapper<void, LabeledSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const BlankSymbol&) { out << "#B"; } -SymbolToStringComposer::RegistratorWrapper<void, BlankSymbol> SymbolToStringComposerBlankSymbol = SymbolToStringComposer::RegistratorWrapper<void, BlankSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, BlankSymbol> SymbolToStringComposerBlankSymbol = SymbolToStringComposer::RegistratorWrapper<void, BlankSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const BottomOfTheStackSymbol&) { out << "#T"; } -SymbolToStringComposer::RegistratorWrapper<void, BottomOfTheStackSymbol> SymbolToStringComposerBottomOfTheStackSymbol = SymbolToStringComposer::RegistratorWrapper<void, BottomOfTheStackSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, BottomOfTheStackSymbol> SymbolToStringComposerBottomOfTheStackSymbol = SymbolToStringComposer::RegistratorWrapper<void, BottomOfTheStackSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const EndSymbol&) { out << "#$"; } -SymbolToStringComposer::RegistratorWrapper<void, EndSymbol> SymbolToStringComposerEndSymbol = SymbolToStringComposer::RegistratorWrapper<void, EndSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, EndSymbol> SymbolToStringComposerEndSymbol = SymbolToStringComposer::RegistratorWrapper<void, EndSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const StartSymbol&) { out << "#^"; } -SymbolToStringComposer::RegistratorWrapper<void, StartSymbol> SymbolToStringComposerStartSymbol = SymbolToStringComposer::RegistratorWrapper<void, StartSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, StartSymbol> SymbolToStringComposerStartSymbol = SymbolToStringComposer::RegistratorWrapper<void, StartSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const RankedSymbol& symbol) { alib::stringApi<alphabet::Symbol>::compose(out, symbol.getSymbol()); alib::stringApi<primitive::Primitive>::compose(out, primitive::Primitive(symbol.getRank())); } -SymbolToStringComposer::RegistratorWrapper<void, RankedSymbol> SymbolToStringComposerRankedSymbol = SymbolToStringComposer::RegistratorWrapper<void, RankedSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, RankedSymbol> SymbolToStringComposerRankedSymbol = SymbolToStringComposer::RegistratorWrapper<void, RankedSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const BarSymbol&) { out << "#|"; } -SymbolToStringComposer::RegistratorWrapper<void, BarSymbol> SymbolToStringComposerBarSymbol = SymbolToStringComposer::RegistratorWrapper<void, BarSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, BarSymbol> SymbolToStringComposerBarSymbol = SymbolToStringComposer::RegistratorWrapper<void, BarSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const VariablesBarSymbol&) { out << "#/"; } -SymbolToStringComposer::RegistratorWrapper<void, VariablesBarSymbol> SymbolToStringComposerVariablesBarSymbol = SymbolToStringComposer::RegistratorWrapper<void, VariablesBarSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, VariablesBarSymbol> SymbolToStringComposerVariablesBarSymbol = SymbolToStringComposer::RegistratorWrapper<void, VariablesBarSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const SubtreeWildcardSymbol&) { out << "#S"; } -SymbolToStringComposer::RegistratorWrapper<void, SubtreeWildcardSymbol> SymbolToStringComposerSubtreeWildcardSymbol = SymbolToStringComposer::RegistratorWrapper<void, SubtreeWildcardSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, SubtreeWildcardSymbol> SymbolToStringComposerSubtreeWildcardSymbol = SymbolToStringComposer::RegistratorWrapper<void, SubtreeWildcardSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const SymbolSetSymbol& symbol) { out << '['; @@ -86,35 +86,35 @@ void SymbolToStringComposer::compose(std::ostream& out, const SymbolSetSymbol& s out << ", "; else first = false; - getInstance().dispatch(out, innerSymbol.getData()); + dispatch(out, innerSymbol.getData()); } out << ']'; } -SymbolToStringComposer::RegistratorWrapper<void, SymbolSetSymbol> SymbolToStringComposerSymbolSetSymbol = SymbolToStringComposer::RegistratorWrapper<void, SymbolSetSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, SymbolSetSymbol> SymbolToStringComposerSymbolSetSymbol = SymbolToStringComposer::RegistratorWrapper<void, SymbolSetSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const SymbolPairSymbol& symbol) { out << '<'; - getInstance().dispatch(out, symbol.getData().first.getData()); + dispatch(out, symbol.getData().first.getData()); out << ", "; - getInstance().dispatch(out, symbol.getData().second.getData()); + dispatch(out, symbol.getData().second.getData()); out << '>'; } -SymbolToStringComposer::RegistratorWrapper<void, SymbolPairSymbol> SymbolToStringComposerSymbolPairSymbol = SymbolToStringComposer::RegistratorWrapper<void, SymbolPairSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, SymbolPairSymbol> SymbolToStringComposerSymbolPairSymbol = SymbolToStringComposer::RegistratorWrapper<void, SymbolPairSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const UniqueSymbol& symbol) { out << '<'; - getInstance().dispatch(out, symbol.getSymbol().getData()); + dispatch(out, symbol.getSymbol().getData()); out << ", "; alib::stringApi<primitive::Primitive>::compose(out, primitive::Primitive(symbol.getId())); out << '>'; } -SymbolToStringComposer::RegistratorWrapper<void, UniqueSymbol> SymbolToStringComposerUniqueSymbol = SymbolToStringComposer::RegistratorWrapper<void, UniqueSymbol>(SymbolToStringComposer::getInstance(), SymbolToStringComposer::compose); +SymbolToStringComposer::RegistratorWrapper<void, UniqueSymbol> SymbolToStringComposerUniqueSymbol = SymbolToStringComposer::RegistratorWrapper<void, UniqueSymbol>(SymbolToStringComposer::compose); void SymbolToStringComposer::compose(std::ostream& out, const Symbol& symbol) { - getInstance().dispatch(out, symbol.getData()); + dispatch(out, symbol.getData()); } } /* namespace alphabet */ diff --git a/alib2str/src/alphabet/SymbolToStringComposer.h b/alib2str/src/alphabet/SymbolToStringComposer.h index be8e06da3a4f918c3fac14ff61072d86c10acd86..5ebda382d520e8f4618074a5ecf3f314e11fbca0 100644 --- a/alib2str/src/alphabet/SymbolToStringComposer.h +++ b/alib2str/src/alphabet/SymbolToStringComposer.h @@ -18,7 +18,7 @@ namespace alphabet { /** * This class contains methods to print XML representation of string to the output stream. */ -class SymbolToStringComposer : public std::SingleDispatchFirstStaticParam<void, std::ostream&, SymbolBase> { +class SymbolToStringComposer : public std::SingleDispatchFirstStaticParam<SymbolToStringComposer, void, std::ostream&, SymbolBase> { public: static void compose(std::ostream& output, const LabeledSymbol& symbol); static void compose(std::ostream& output, const BlankSymbol& symbol); @@ -39,11 +39,6 @@ public: * @param out output stream to which print the String */ static void compose(std::ostream& output, const Symbol& string); - - static SymbolToStringComposer& getInstance() { - static SymbolToStringComposer res; - return res; - } }; } /* namespace alphabet */ diff --git a/alib2str/src/automaton/AutomatonToStringComposer.cpp b/alib2str/src/automaton/AutomatonToStringComposer.cpp index 396cc0fbab4c01852e2e58f7490fdcc976374a80..08cd566287665a6e810d76ff69f48ca0bff350d7 100644 --- a/alib2str/src/automaton/AutomatonToStringComposer.cpp +++ b/alib2str/src/automaton/AutomatonToStringComposer.cpp @@ -120,7 +120,7 @@ void AutomatonToStringComposer::compose(std::ostream& out, const DFA& automaton) } } -AutomatonToStringComposer::RegistratorWrapper<void, DFA> AutomatonToStringComposerDFA = AutomatonToStringComposer::RegistratorWrapper<void, DFA>(AutomatonToStringComposer::getInstance(), AutomatonToStringComposer::compose); +AutomatonToStringComposer::RegistratorWrapper<void, DFA> AutomatonToStringComposerDFA = AutomatonToStringComposer::RegistratorWrapper<void, DFA>(AutomatonToStringComposer::compose); void AutomatonToStringComposer::compose(std::ostream& out, const NFA& automaton) { out << "NFA"; @@ -146,7 +146,7 @@ void AutomatonToStringComposer::compose(std::ostream& out, const NFA& automaton) } } -AutomatonToStringComposer::RegistratorWrapper<void, NFA> AutomatonToStringComposerNFA = AutomatonToStringComposer::RegistratorWrapper<void, NFA>(AutomatonToStringComposer::getInstance(), AutomatonToStringComposer::compose); +AutomatonToStringComposer::RegistratorWrapper<void, NFA> AutomatonToStringComposerNFA = AutomatonToStringComposer::RegistratorWrapper<void, NFA>(AutomatonToStringComposer::compose); void AutomatonToStringComposer::compose(std::ostream& out, const MultiInitialStateNFA& automaton) { out << "MISNFA"; @@ -172,7 +172,7 @@ void AutomatonToStringComposer::compose(std::ostream& out, const MultiInitialSta } } -AutomatonToStringComposer::RegistratorWrapper<void, MultiInitialStateNFA> AutomatonToStringComposerMultiInitialStateNFA = AutomatonToStringComposer::RegistratorWrapper<void, MultiInitialStateNFA>(AutomatonToStringComposer::getInstance(), AutomatonToStringComposer::compose); +AutomatonToStringComposer::RegistratorWrapper<void, MultiInitialStateNFA> AutomatonToStringComposerMultiInitialStateNFA = AutomatonToStringComposer::RegistratorWrapper<void, MultiInitialStateNFA>(AutomatonToStringComposer::compose); void AutomatonToStringComposer::compose(std::ostream& out, const EpsilonNFA& automaton) { out << "ENFA"; @@ -199,10 +199,10 @@ void AutomatonToStringComposer::compose(std::ostream& out, const EpsilonNFA& aut } } -AutomatonToStringComposer::RegistratorWrapper<void, EpsilonNFA> AutomatonToStringComposerEpsilonNFA = AutomatonToStringComposer::RegistratorWrapper<void, EpsilonNFA>(AutomatonToStringComposer::getInstance(), AutomatonToStringComposer::compose); +AutomatonToStringComposer::RegistratorWrapper<void, EpsilonNFA> AutomatonToStringComposerEpsilonNFA = AutomatonToStringComposer::RegistratorWrapper<void, EpsilonNFA>(AutomatonToStringComposer::compose); void AutomatonToStringComposer::compose(std::ostream& output, const Automaton& automaton) { - getInstance().dispatch(output, automaton.getData()); + dispatch(output, automaton.getData()); } } /* namespace automaton */ diff --git a/alib2str/src/automaton/AutomatonToStringComposer.h b/alib2str/src/automaton/AutomatonToStringComposer.h index f107291de46a740711055411ce5c9eaa5d667d35..48154813c84aa1665a43f74582d76569883a8468 100644 --- a/alib2str/src/automaton/AutomatonToStringComposer.h +++ b/alib2str/src/automaton/AutomatonToStringComposer.h @@ -15,7 +15,7 @@ namespace automaton { -class AutomatonToStringComposer : public std::SingleDispatchFirstStaticParam<void, std::ostream&, AutomatonBase> { +class AutomatonToStringComposer : public std::SingleDispatchFirstStaticParam<AutomatonToStringComposer, void, std::ostream&, AutomatonBase> { static void composeTransitionsFromState(std::ostream& out, const DFA& automaton, const State& from); static void composeTransitionsFromState(std::ostream& out, const NFA& automaton, const State& from); static void composeTransitionsFromState(std::ostream& out, const MultiInitialStateNFA& automaton, const State& from); @@ -33,11 +33,6 @@ public: static void compose(std::ostream& output, const NFA& automaton); static void compose(std::ostream& output, const MultiInitialStateNFA& automaton); static void compose(std::ostream& output, const EpsilonNFA& automaton); - - static AutomatonToStringComposer& getInstance() { - static AutomatonToStringComposer res; - return res; - } }; } /* namespace automaton */ diff --git a/alib2str/src/grammar/GrammarToStringComposer.cpp b/alib2str/src/grammar/GrammarToStringComposer.cpp index 23d6f2ae1bba475f91fb389cf9a8f003daea66be..75051adfe9d82eee0046691eb400873ef12a674a 100644 --- a/alib2str/src/grammar/GrammarToStringComposer.cpp +++ b/alib2str/src/grammar/GrammarToStringComposer.cpp @@ -181,7 +181,7 @@ void GrammarToStringComposer::composePreservingCSLikeGrammar(std::ostream& outpu } void GrammarToStringComposer::compose(std::ostream& output, const Grammar& grammar) { - getInstance().dispatch(output, grammar.getData()); + dispatch(output, grammar.getData()); } void GrammarToStringComposer::compose(std::ostream& output, const LeftLG& grammar) { @@ -189,90 +189,90 @@ void GrammarToStringComposer::compose(std::ostream& output, const LeftLG& gramma composeCFLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, LeftLG> GrammarToStringComposerLeftLG = GrammarToStringComposer::RegistratorWrapper<void, LeftLG>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, LeftLG> GrammarToStringComposerLeftLG = GrammarToStringComposer::RegistratorWrapper<void, LeftLG>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const LeftRG& grammar) { output << "LEFT_RG"; composeCFLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, LeftRG> GrammarToStringComposerLeftRG = GrammarToStringComposer::RegistratorWrapper<void, LeftRG>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, LeftRG> GrammarToStringComposerLeftRG = GrammarToStringComposer::RegistratorWrapper<void, LeftRG>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const RightLG& grammar) { output << "RIGHT_LG"; composeCFLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, RightLG> GrammarToStringComposerRightLG = GrammarToStringComposer::RegistratorWrapper<void, RightLG>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, RightLG> GrammarToStringComposerRightLG = GrammarToStringComposer::RegistratorWrapper<void, RightLG>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const RightRG& grammar) { output << "RIGHT_RG"; composeCFLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, RightRG> GrammarToStringComposerRightRG = GrammarToStringComposer::RegistratorWrapper<void, RightRG>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, RightRG> GrammarToStringComposerRightRG = GrammarToStringComposer::RegistratorWrapper<void, RightRG>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const LG& grammar) { output << "LG"; composeCFLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, LG> GrammarToStringComposerLG = GrammarToStringComposer::RegistratorWrapper<void, LG>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, LG> GrammarToStringComposerLG = GrammarToStringComposer::RegistratorWrapper<void, LG>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const CFG& grammar) { output << "CFG"; composeCFLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, CFG> GrammarToStringComposerCFG = GrammarToStringComposer::RegistratorWrapper<void, CFG>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, CFG> GrammarToStringComposerCFG = GrammarToStringComposer::RegistratorWrapper<void, CFG>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const EpsilonFreeCFG& grammar) { output << "EPSILON_FREE_CFG"; composeCFLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, EpsilonFreeCFG> GrammarToStringComposerEpsilonFreeCFG = GrammarToStringComposer::RegistratorWrapper<void, EpsilonFreeCFG>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, EpsilonFreeCFG> GrammarToStringComposerEpsilonFreeCFG = GrammarToStringComposer::RegistratorWrapper<void, EpsilonFreeCFG>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const CNF& grammar) { output << "CNF"; composeCFLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, CNF> GrammarToStringComposerCNF = GrammarToStringComposer::RegistratorWrapper<void, CNF>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, CNF> GrammarToStringComposerCNF = GrammarToStringComposer::RegistratorWrapper<void, CNF>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const GNF& grammar) { output << "GNF"; composeCFLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, GNF> GrammarToStringComposerGNF = GrammarToStringComposer::RegistratorWrapper<void, GNF>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, GNF> GrammarToStringComposerGNF = GrammarToStringComposer::RegistratorWrapper<void, GNF>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const CSG& grammar) { output << "CSG"; composePreservingCSLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, CSG> GrammarToStringComposerCSG = GrammarToStringComposer::RegistratorWrapper<void, CSG>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, CSG> GrammarToStringComposerCSG = GrammarToStringComposer::RegistratorWrapper<void, CSG>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const NonContractingGrammar& grammar) { output << "NON_CONTRACTING_GRAMMAR"; composeCSLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, NonContractingGrammar> GrammarToStringComposerNonContractingGrammar = GrammarToStringComposer::RegistratorWrapper<void, NonContractingGrammar>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, NonContractingGrammar> GrammarToStringComposerNonContractingGrammar = GrammarToStringComposer::RegistratorWrapper<void, NonContractingGrammar>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const ContextPreservingUnrestrictedGrammar& grammar) { output << "CONTEXT_PRESERVING_UNRESTRICTED_GRAMMAR"; composePreservingCSLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, ContextPreservingUnrestrictedGrammar> GrammarToStringComposerContextPreservingUnrestructedGrammar = GrammarToStringComposer::RegistratorWrapper<void, ContextPreservingUnrestrictedGrammar>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, ContextPreservingUnrestrictedGrammar> GrammarToStringComposerContextPreservingUnrestructedGrammar = GrammarToStringComposer::RegistratorWrapper<void, ContextPreservingUnrestrictedGrammar>(GrammarToStringComposer::compose); void GrammarToStringComposer::compose(std::ostream& output, const UnrestrictedGrammar& grammar) { output << "UNRESTRICTED_GRAMMAR"; composeCSLikeGrammar(output, grammar); } -GrammarToStringComposer::RegistratorWrapper<void, UnrestrictedGrammar> GrammarToStringComposerUnrestructedGrammar = GrammarToStringComposer::RegistratorWrapper<void, UnrestrictedGrammar>(GrammarToStringComposer::getInstance(), GrammarToStringComposer::compose); +GrammarToStringComposer::RegistratorWrapper<void, UnrestrictedGrammar> GrammarToStringComposerUnrestructedGrammar = GrammarToStringComposer::RegistratorWrapper<void, UnrestrictedGrammar>(GrammarToStringComposer::compose); } diff --git a/alib2str/src/grammar/GrammarToStringComposer.h b/alib2str/src/grammar/GrammarToStringComposer.h index b05d567b667810e085a56ad3777e5f80cc2847e8..0b3d33b00bfe290edae7d0bd26d4597ca9673543 100644 --- a/alib2str/src/grammar/GrammarToStringComposer.h +++ b/alib2str/src/grammar/GrammarToStringComposer.h @@ -8,7 +8,7 @@ namespace grammar { -class GrammarToStringComposer: public std::SingleDispatchFirstStaticParam<void, std::ostream&, GrammarBase> { +class GrammarToStringComposer: public std::SingleDispatchFirstStaticParam<GrammarToStringComposer, void, std::ostream&, GrammarBase> { public: template<class T> static void composeCFLikeGrammar(std::ostream& output, const T& grammar); @@ -37,11 +37,6 @@ public: static void compose(std::ostream& output, const NonContractingGrammar& grammar); static void compose(std::ostream& output, const ContextPreservingUnrestrictedGrammar& grammar); static void compose(std::ostream& output, const UnrestrictedGrammar& grammar); - - static GrammarToStringComposer& getInstance() { - static GrammarToStringComposer res; - return res; - } }; } diff --git a/alib2str/src/graph/GraphToStringComposer.cpp b/alib2str/src/graph/GraphToStringComposer.cpp index 6ceec6a28cf64d1aacec08ed7e51b8eb280aa0f0..ec1ee4a41e441c700064d73ac73bc47413ba48e7 100644 --- a/alib2str/src/graph/GraphToStringComposer.cpp +++ b/alib2str/src/graph/GraphToStringComposer.cpp @@ -14,7 +14,7 @@ namespace graph { void GraphToStringComposer::compose(std::ostream &out, const Graph &graph) { out << "("; - getInstance().dispatch(out, graph.getData()); + dispatch(out, graph.getData()); out << ")"; } @@ -31,7 +31,7 @@ void GraphToStringComposer::compose(std::ostream& out, const DirectedGraph &grap composeEdgeValues(out, graph); } -GraphToStringComposer::RegistratorWrapper<void, DirectedGraph> GraphToStringComposerDirectedGraph = GraphToStringComposer::RegistratorWrapper<void, DirectedGraph>(GraphToStringComposer::getInstance(), GraphToStringComposer::compose); +GraphToStringComposer::RegistratorWrapper<void, DirectedGraph> GraphToStringComposerDirectedGraph = GraphToStringComposer::RegistratorWrapper<void, DirectedGraph>(GraphToStringComposer::compose); void GraphToStringComposer::compose(std::ostream& out, const UndirectedGraph &graph) { out << "UndirectedGraph:"; @@ -46,7 +46,7 @@ void GraphToStringComposer::compose(std::ostream& out, const UndirectedGraph &gr composeEdgeValues(out, graph); } -GraphToStringComposer::RegistratorWrapper<void, UndirectedGraph> GraphToStringComposerUndirectedGraph = GraphToStringComposer::RegistratorWrapper<void, UndirectedGraph>(GraphToStringComposer::getInstance(), GraphToStringComposer::compose); +GraphToStringComposer::RegistratorWrapper<void, UndirectedGraph> GraphToStringComposerUndirectedGraph = GraphToStringComposer::RegistratorWrapper<void, UndirectedGraph>(GraphToStringComposer::compose); void GraphToStringComposer::composeNode(std::ostream& out, const Node &node) { alib::stringApi<label::Label>::compose(out, node.getName()); diff --git a/alib2str/src/graph/GraphToStringComposer.h b/alib2str/src/graph/GraphToStringComposer.h index 8dd365f5d60787bc5027b8525cdd882b5438dac4..b3882e811d9baa0fe7f206f3d9365e02b64f62a6 100644 --- a/alib2str/src/graph/GraphToStringComposer.h +++ b/alib2str/src/graph/GraphToStringComposer.h @@ -19,7 +19,7 @@ namespace graph { -class GraphToStringComposer : public std::SingleDispatchFirstStaticParam<void, std::ostream&, GraphBase> { +class GraphToStringComposer : public std::SingleDispatchFirstStaticParam<GraphToStringComposer, void, std::ostream&, GraphBase> { private: static void composeNode(std::ostream& out, const Node &node); static void composeEdge(std::ostream& out, const DirectedEdge &edge); @@ -40,11 +40,6 @@ public: static void compose(std::ostream& out, const DirectedGraph& graph); static void compose(std::ostream& out, const UndirectedGraph& graph); - - static GraphToStringComposer& getInstance() { - static GraphToStringComposer res; - return res; - } }; } // namespace graph diff --git a/alib2str/src/label/LabelToStringComposer.cpp b/alib2str/src/label/LabelToStringComposer.cpp index 434e4c7280fc9056359ffd41f8b615f7b14d370e..f5cac269f3de8c3d2719bdc7a513bb2f42897b79 100644 --- a/alib2str/src/label/LabelToStringComposer.cpp +++ b/alib2str/src/label/LabelToStringComposer.cpp @@ -21,19 +21,19 @@ void LabelToStringComposer::compose(std::ostream& out, const PrimitiveLabel& lab alib::stringApi<primitive::Primitive>::compose(out, label.getData()); } -LabelToStringComposer::RegistratorWrapper<void, PrimitiveLabel> LabelToStringComposerPrimitiveLabel = LabelToStringComposer::RegistratorWrapper<void, PrimitiveLabel>(LabelToStringComposer::getInstance(), LabelToStringComposer::compose); +LabelToStringComposer::RegistratorWrapper<void, PrimitiveLabel> LabelToStringComposerPrimitiveLabel = LabelToStringComposer::RegistratorWrapper<void, PrimitiveLabel>(LabelToStringComposer::compose); void LabelToStringComposer::compose(std::ostream& out, const HexavigesimalLabel& label) { out << (std::string) label; } -LabelToStringComposer::RegistratorWrapper<void, HexavigesimalLabel> LabelToStringComposerHexavigesimalLabel = LabelToStringComposer::RegistratorWrapper<void, HexavigesimalLabel>(LabelToStringComposer::getInstance(), LabelToStringComposer::compose); +LabelToStringComposer::RegistratorWrapper<void, HexavigesimalLabel> LabelToStringComposerHexavigesimalLabel = LabelToStringComposer::RegistratorWrapper<void, HexavigesimalLabel>(LabelToStringComposer::compose); void LabelToStringComposer::compose(std::ostream& out, const ObjectLabel& label) { out << (std::string) label; } -LabelToStringComposer::RegistratorWrapper<void, ObjectLabel> LabelToStringComposerObjectLabel = LabelToStringComposer::RegistratorWrapper<void, ObjectLabel>(LabelToStringComposer::getInstance(), LabelToStringComposer::compose); +LabelToStringComposer::RegistratorWrapper<void, ObjectLabel> LabelToStringComposerObjectLabel = LabelToStringComposer::RegistratorWrapper<void, ObjectLabel>(LabelToStringComposer::compose); void LabelToStringComposer::compose(std::ostream& out, const LabelSetLabel& label) { out << '['; @@ -43,35 +43,35 @@ void LabelToStringComposer::compose(std::ostream& out, const LabelSetLabel& labe out << ", "; else first = false; - getInstance().dispatch(out, innerLabel.getData()); + dispatch(out, innerLabel.getData()); } out << ']'; } -LabelToStringComposer::RegistratorWrapper<void, LabelSetLabel> LabelToStringComposerLabelSetLabel = LabelToStringComposer::RegistratorWrapper<void, LabelSetLabel>(LabelToStringComposer::getInstance(), LabelToStringComposer::compose); +LabelToStringComposer::RegistratorWrapper<void, LabelSetLabel> LabelToStringComposerLabelSetLabel = LabelToStringComposer::RegistratorWrapper<void, LabelSetLabel>(LabelToStringComposer::compose); void LabelToStringComposer::compose(std::ostream& out, const LabelPairLabel& label) { out << '<'; - getInstance().dispatch(out, label.getData().first.getData()); + dispatch(out, label.getData().first.getData()); out << ", "; - getInstance().dispatch(out, label.getData().second.getData()); + dispatch(out, label.getData().second.getData()); out << '>'; } -LabelToStringComposer::RegistratorWrapper<void, LabelPairLabel> LabelToStringComposerLabelPairLabel = LabelToStringComposer::RegistratorWrapper<void, LabelPairLabel>(LabelToStringComposer::getInstance(), LabelToStringComposer::compose); +LabelToStringComposer::RegistratorWrapper<void, LabelPairLabel> LabelToStringComposerLabelPairLabel = LabelToStringComposer::RegistratorWrapper<void, LabelPairLabel>(LabelToStringComposer::compose); void LabelToStringComposer::compose(std::ostream& out, const UniqueLabel& label) { out << '<'; - getInstance().dispatch(out, label.getLabel().getData()); + dispatch(out, label.getLabel().getData()); out << ", "; alib::stringApi<primitive::Primitive>::compose(out, primitive::Primitive(label.getId())); out << '>'; } -LabelToStringComposer::RegistratorWrapper<void, UniqueLabel> LabelToStringComposerUniqueLabel = LabelToStringComposer::RegistratorWrapper<void, UniqueLabel>(LabelToStringComposer::getInstance(), LabelToStringComposer::compose); +LabelToStringComposer::RegistratorWrapper<void, UniqueLabel> LabelToStringComposerUniqueLabel = LabelToStringComposer::RegistratorWrapper<void, UniqueLabel>(LabelToStringComposer::compose); void LabelToStringComposer::compose(std::ostream& output, const Label& label) { - getInstance().dispatch(output, label.getData()); + dispatch(output, label.getData()); } } /* namespace label */ diff --git a/alib2str/src/label/LabelToStringComposer.h b/alib2str/src/label/LabelToStringComposer.h index 9c14903121c5bab5c2b1bf1c839da7164a499600..18675303023ccf05459dd08e0cc3550292b10f43 100644 --- a/alib2str/src/label/LabelToStringComposer.h +++ b/alib2str/src/label/LabelToStringComposer.h @@ -18,7 +18,7 @@ namespace label { /** * This class contains methods to print XML representation of string to the output stream. */ -class LabelToStringComposer : public std::SingleDispatchFirstStaticParam<void, std::ostream&, LabelBase> { +class LabelToStringComposer : public std::SingleDispatchFirstStaticParam<LabelToStringComposer, void, std::ostream&, LabelBase> { public: static void compose(std::ostream&, const PrimitiveLabel& label); static void compose(std::ostream&, const HexavigesimalLabel& label); @@ -33,11 +33,6 @@ public: * @param out output stream to which print the String */ static void compose(std::ostream& output, const Label& string); - - static LabelToStringComposer& getInstance() { - static LabelToStringComposer res; - return res; - } }; } /* namespace label */ diff --git a/alib2str/src/primitive/PrimitiveToStringComposer.cpp b/alib2str/src/primitive/PrimitiveToStringComposer.cpp index c588f93ffcfe5c1a3e5bb9a605a7106645cf4a68..94b1507861a3bd96783d7568cb46a456640a2632 100644 --- a/alib2str/src/primitive/PrimitiveToStringComposer.cpp +++ b/alib2str/src/primitive/PrimitiveToStringComposer.cpp @@ -28,34 +28,34 @@ void PrimitiveToStringComposer::compose(std::ostream& out, const String& primiti out << '\'' << tmp << '\''; } -PrimitiveToStringComposer::RegistratorWrapper<void, String> PrimitiveToStringComposerString = PrimitiveToStringComposer::RegistratorWrapper<void, String>(PrimitiveToStringComposer::getInstance(), PrimitiveToStringComposer::compose); +PrimitiveToStringComposer::RegistratorWrapper<void, String> PrimitiveToStringComposerString = PrimitiveToStringComposer::RegistratorWrapper<void, String>(PrimitiveToStringComposer::compose); void PrimitiveToStringComposer::compose(std::ostream& out, const Character& primitive) { out << primitive.getData(); } -PrimitiveToStringComposer::RegistratorWrapper<void, Character> PrimitiveToStringComposerCharacter = PrimitiveToStringComposer::RegistratorWrapper<void, Character>(PrimitiveToStringComposer::getInstance(), PrimitiveToStringComposer::compose); +PrimitiveToStringComposer::RegistratorWrapper<void, Character> PrimitiveToStringComposerCharacter = PrimitiveToStringComposer::RegistratorWrapper<void, Character>(PrimitiveToStringComposer::compose); void PrimitiveToStringComposer::compose(std::ostream& out, const Integer& primitive) { out << primitive.getData(); } -PrimitiveToStringComposer::RegistratorWrapper<void, Integer> PrimitiveToStringComposerInteger = PrimitiveToStringComposer::RegistratorWrapper<void, Integer>(PrimitiveToStringComposer::getInstance(), PrimitiveToStringComposer::compose); +PrimitiveToStringComposer::RegistratorWrapper<void, Integer> PrimitiveToStringComposerInteger = PrimitiveToStringComposer::RegistratorWrapper<void, Integer>(PrimitiveToStringComposer::compose); void PrimitiveToStringComposer::compose(std::ostream& out, const Unsigned& primitive) { out << primitive.getData(); } -PrimitiveToStringComposer::RegistratorWrapper<void, Unsigned> PrimitiveToStringComposerUnsigned = PrimitiveToStringComposer::RegistratorWrapper<void, Unsigned>(PrimitiveToStringComposer::getInstance(), PrimitiveToStringComposer::compose); +PrimitiveToStringComposer::RegistratorWrapper<void, Unsigned> PrimitiveToStringComposerUnsigned = PrimitiveToStringComposer::RegistratorWrapper<void, Unsigned>(PrimitiveToStringComposer::compose); void PrimitiveToStringComposer::compose(std::ostream& out, const Bool& primitive) { out << (primitive.getData() ? "true" : "false"); } -PrimitiveToStringComposer::RegistratorWrapper<void, Bool> PrimitiveToStringComposerBool = PrimitiveToStringComposer::RegistratorWrapper<void, Bool>(PrimitiveToStringComposer::getInstance(), PrimitiveToStringComposer::compose); +PrimitiveToStringComposer::RegistratorWrapper<void, Bool> PrimitiveToStringComposerBool = PrimitiveToStringComposer::RegistratorWrapper<void, Bool>(PrimitiveToStringComposer::compose); void PrimitiveToStringComposer::compose(std::ostream& out, const Primitive& primitive) { - getInstance().dispatch(out, primitive.getData()); + dispatch(out, primitive.getData()); } } /* namespace primitive */ diff --git a/alib2str/src/primitive/PrimitiveToStringComposer.h b/alib2str/src/primitive/PrimitiveToStringComposer.h index 97f6f46a884d3e9a5fb6e923d4eab1fd889485fc..7b204c11f0a88711a72d7d3a5c5fe353770eaf22 100644 --- a/alib2str/src/primitive/PrimitiveToStringComposer.h +++ b/alib2str/src/primitive/PrimitiveToStringComposer.h @@ -18,7 +18,7 @@ namespace primitive { /** * This class contains methods to print XML representation of string to the output stream. */ -class PrimitiveToStringComposer : public std::SingleDispatchFirstStaticParam<void, std::ostream&, PrimitiveBase> { +class PrimitiveToStringComposer : public std::SingleDispatchFirstStaticParam<PrimitiveToStringComposer, void, std::ostream&, PrimitiveBase> { public: static void compose(std::ostream&, const Integer& primitive); static void compose(std::ostream&, const String& primitive); @@ -32,11 +32,6 @@ public: * @param out output stream to which print the String */ static void compose(std::ostream& out, const Primitive& string); - - static PrimitiveToStringComposer& getInstance() { - static PrimitiveToStringComposer res; - return res; - } }; } /* namespace primitive */ diff --git a/alib2str/src/regexp/RegExpToStringComposer.cpp b/alib2str/src/regexp/RegExpToStringComposer.cpp index 048338354ab55e2c8873016cc00401b5fbfc49ad..2b8021a0b198cf4663f7d6e7943b787e048d356e 100644 --- a/alib2str/src/regexp/RegExpToStringComposer.cpp +++ b/alib2str/src/regexp/RegExpToStringComposer.cpp @@ -22,7 +22,7 @@ void RegExpToStringComposer::compose(std::ostream& output, const UnboundedRegExp regexp.getRegExp().Accept((void*) &out, composer); } -RegExpToStringComposer::RegistratorWrapper<void, UnboundedRegExp> RegExpToStringComposerUnboundedRegExp = RegExpToStringComposer::RegistratorWrapper<void, UnboundedRegExp>(RegExpToStringComposer::getInstance(), RegExpToStringComposer::compose); +RegExpToStringComposer::RegistratorWrapper<void, UnboundedRegExp> RegExpToStringComposerUnboundedRegExp = RegExpToStringComposer::RegistratorWrapper<void, UnboundedRegExp>(RegExpToStringComposer::compose); void RegExpToStringComposer::compose(std::ostream& output, const FormalRegExp& regexp) { Priority tmp = Priority::ALTERNATION; @@ -31,7 +31,7 @@ void RegExpToStringComposer::compose(std::ostream& output, const FormalRegExp& r regexp.getRegExp().Accept((void*) &out, composer); } -RegExpToStringComposer::RegistratorWrapper<void, FormalRegExp> RegExpToStringComposerFormalRegExp = RegExpToStringComposer::RegistratorWrapper<void, FormalRegExp>(RegExpToStringComposer::getInstance(), RegExpToStringComposer::compose); +RegExpToStringComposer::RegistratorWrapper<void, FormalRegExp> RegExpToStringComposerFormalRegExp = RegExpToStringComposer::RegistratorWrapper<void, FormalRegExp>(RegExpToStringComposer::compose); void RegExpToStringComposer::Visit(void* userData, const UnboundedRegExpAlternation& alternation) const { std::tuple<Priority&, std::ostream&> &out = *((std::tuple<Priority&, std::ostream&>*) userData); @@ -158,7 +158,7 @@ void RegExpToStringComposer::Visit(void* userData, const FormalRegExpEmpty&) con } void RegExpToStringComposer::compose(std::ostream& output, const RegExp& regexp) { - getInstance().dispatch(output, regexp.getData()); + dispatch(output, regexp.getData()); } } /* namespace regexp */ diff --git a/alib2str/src/regexp/RegExpToStringComposer.h b/alib2str/src/regexp/RegExpToStringComposer.h index 2fa525e37c17e1bd71045366aec7441e06806d22..868a53e72d40ccf76e903ca70d6b70c2e24d817c 100644 --- a/alib2str/src/regexp/RegExpToStringComposer.h +++ b/alib2str/src/regexp/RegExpToStringComposer.h @@ -16,7 +16,7 @@ namespace regexp { -class RegExpToStringComposer : public std::SingleDispatchFirstStaticParam<void, std::ostream&, RegExpBase>, UnboundedRegExpElementVisitor, FormalRegExpElementVisitor { +class RegExpToStringComposer : public std::SingleDispatchFirstStaticParam<RegExpToStringComposer, void, std::ostream&, RegExpBase>, UnboundedRegExpElementVisitor, FormalRegExpElementVisitor { private: void Visit(void*, const UnboundedRegExpAlternation& alternation) const; void Visit(void*, const UnboundedRegExpConcatenation& concatenation) const; @@ -48,11 +48,6 @@ public: static void compose(std::ostream& out, const UnboundedRegExp& regexp); static void compose(std::ostream& out, const FormalRegExp& regexp); - - static RegExpToStringComposer& getInstance() { - static RegExpToStringComposer res; - return res; - } }; } /* namespace regexp */ diff --git a/alib2str/src/string/StringToStringComposer.cpp b/alib2str/src/string/StringToStringComposer.cpp index eabd25672fbf52be0c52e72fa5c4a6b3d159d616..66164521ccac6ec8c15ad90e3ca89884c43b96f6 100644 --- a/alib2str/src/string/StringToStringComposer.cpp +++ b/alib2str/src/string/StringToStringComposer.cpp @@ -23,7 +23,7 @@ void StringToStringComposer::compose ( std::ostream & out, const CyclicString & out << ">"; } -StringToStringComposer::RegistratorWrapper < void, CyclicString > StringToStringComposerCyclicString = StringToStringComposer::RegistratorWrapper < void, CyclicString > ( StringToStringComposer::getInstance ( ), StringToStringComposer::compose ); +StringToStringComposer::RegistratorWrapper < void, CyclicString > StringToStringComposerCyclicString = StringToStringComposer::RegistratorWrapper < void, CyclicString > ( StringToStringComposer::compose ); void StringToStringComposer::compose ( std::ostream & out, const LinearString & string ) { out << "\""; @@ -34,16 +34,16 @@ void StringToStringComposer::compose ( std::ostream & out, const LinearString & out << "\""; } -StringToStringComposer::RegistratorWrapper < void, LinearString > StringToStringComposerLinearString = StringToStringComposer::RegistratorWrapper < void, LinearString > ( StringToStringComposer::getInstance ( ), StringToStringComposer::compose ); +StringToStringComposer::RegistratorWrapper < void, LinearString > StringToStringComposerLinearString = StringToStringComposer::RegistratorWrapper < void, LinearString > ( StringToStringComposer::compose ); void StringToStringComposer::compose ( std::ostream & out, const Epsilon & ) { out << "#E"; } -StringToStringComposer::RegistratorWrapper < void, Epsilon > StringToStringComposerEpsilon = StringToStringComposer::RegistratorWrapper < void, Epsilon > ( StringToStringComposer::getInstance ( ), StringToStringComposer::compose ); +StringToStringComposer::RegistratorWrapper < void, Epsilon > StringToStringComposerEpsilon = StringToStringComposer::RegistratorWrapper < void, Epsilon > ( StringToStringComposer::compose ); void StringToStringComposer::compose ( std::ostream & out, const String & string ) { - getInstance ( ).dispatch ( out, string.getData ( ) ); + dispatch ( out, string.getData ( ) ); } } /* namespace string */ diff --git a/alib2str/src/string/StringToStringComposer.h b/alib2str/src/string/StringToStringComposer.h index 9a7ec190706e45a1f00b74de04ed3e34e6380a97..34197585f7fb37760f9a1fa9f3cc57429d75f260 100644 --- a/alib2str/src/string/StringToStringComposer.h +++ b/alib2str/src/string/StringToStringComposer.h @@ -18,7 +18,7 @@ namespace string { /** * This class contains methods to print XML representation of string to the output stream. */ -class StringToStringComposer: public std::SingleDispatchFirstStaticParam<void, std::ostream&, StringBase> { +class StringToStringComposer: public std::SingleDispatchFirstStaticParam<StringToStringComposer, void, std::ostream&, StringBase> { public: static void compose(std::ostream&, const LinearString& string); static void compose(std::ostream&, const CyclicString& string); @@ -30,11 +30,6 @@ public: * @param out output stream to which print the String */ static void compose(std::ostream& output, const String& string); - - static StringToStringComposer& getInstance() { - static StringToStringComposer res; - return res; - } }; } /* namespace string */ diff --git a/alib2str/src/tree/TreeToStringComposer.cpp b/alib2str/src/tree/TreeToStringComposer.cpp index ce4e2d5a43c0c87cd4b3d5a26c5f1617047b0e94..72604aec263001a9f2203dbd8ecab866a4b3a34d 100644 --- a/alib2str/src/tree/TreeToStringComposer.cpp +++ b/alib2str/src/tree/TreeToStringComposer.cpp @@ -19,7 +19,7 @@ void TreeToStringComposer::compose ( std::ostream & out, const RankedTree & tree compose ( out, tree.getRoot ( ) ); } -TreeToStringComposer::RegistratorWrapper < void, RankedTree > StringToStringComposerRankedTree = TreeToStringComposer::RegistratorWrapper < void, RankedTree > ( TreeToStringComposer::getInstance ( ), TreeToStringComposer::compose ); +TreeToStringComposer::RegistratorWrapper < void, RankedTree > StringToStringComposerRankedTree = TreeToStringComposer::RegistratorWrapper < void, RankedTree > ( TreeToStringComposer::compose ); void TreeToStringComposer::compose ( std::ostream & out, const RankedNode & node ) { alib::stringApi < alphabet::Symbol >::compose ( out, node.getSymbol ( ).getSymbol ( ) ); @@ -36,7 +36,7 @@ void TreeToStringComposer::compose ( std::ostream & out, const RankedPattern & t compose ( out, tree.getSubtreeWildcard ( ), tree.getRoot ( ) ); } -TreeToStringComposer::RegistratorWrapper < void, RankedPattern > StringToStringComposerRankedPattern = TreeToStringComposer::RegistratorWrapper < void, RankedPattern > ( TreeToStringComposer::getInstance ( ), TreeToStringComposer::compose ); +TreeToStringComposer::RegistratorWrapper < void, RankedPattern > StringToStringComposerRankedPattern = TreeToStringComposer::RegistratorWrapper < void, RankedPattern > ( TreeToStringComposer::compose ); void TreeToStringComposer::compose ( std::ostream & out, const alphabet::RankedSymbol & subtreeWildcard, const RankedNode & node ) { if ( node.getSymbol ( ) == subtreeWildcard ) { @@ -57,7 +57,7 @@ void TreeToStringComposer::compose ( std::ostream & out, const UnrankedTree & tr compose ( out, tree.getRoot ( ) ); } -TreeToStringComposer::RegistratorWrapper < void, UnrankedTree > StringToStringComposerUnrankedTree = TreeToStringComposer::RegistratorWrapper < void, UnrankedTree > ( TreeToStringComposer::getInstance ( ), TreeToStringComposer::compose ); +TreeToStringComposer::RegistratorWrapper < void, UnrankedTree > StringToStringComposerUnrankedTree = TreeToStringComposer::RegistratorWrapper < void, UnrankedTree > ( TreeToStringComposer::compose ); void TreeToStringComposer::compose ( std::ostream & out, const UnrankedNode & node ) { alib::stringApi < alphabet::Symbol >::compose ( out, node.getSymbol ( ) ); @@ -74,7 +74,7 @@ void TreeToStringComposer::compose ( std::ostream & out, const UnrankedPattern & compose ( out, tree.getSubtreeWildcard ( ), tree.getRoot ( ) ); } -TreeToStringComposer::RegistratorWrapper < void, UnrankedPattern > StringToStringComposerUnrankedPattern = TreeToStringComposer::RegistratorWrapper < void, UnrankedPattern > ( TreeToStringComposer::getInstance ( ), TreeToStringComposer::compose ); +TreeToStringComposer::RegistratorWrapper < void, UnrankedPattern > StringToStringComposerUnrankedPattern = TreeToStringComposer::RegistratorWrapper < void, UnrankedPattern > ( TreeToStringComposer::compose ); void TreeToStringComposer::compose ( std::ostream & out, const alphabet::Symbol & subtreeWildcard, const UnrankedNode & node ) { if ( node.getSymbol ( ) == subtreeWildcard ) { @@ -92,7 +92,7 @@ void TreeToStringComposer::compose ( std::ostream & out, const alphabet::Symbol } void TreeToStringComposer::compose ( std::ostream & out, const Tree & tree ) { - getInstance ( ).dispatch ( out, tree.getData ( ) ); + dispatch ( out, tree.getData ( ) ); } } /* namespace tree */ diff --git a/alib2str/src/tree/TreeToStringComposer.h b/alib2str/src/tree/TreeToStringComposer.h index 80d771846cd07ee69aec30c8e570a9ab17dea756..d3168b5862e0f93ddb2d1a9ff64176f1a22b0a48 100644 --- a/alib2str/src/tree/TreeToStringComposer.h +++ b/alib2str/src/tree/TreeToStringComposer.h @@ -20,7 +20,7 @@ namespace tree { /** * This class contains methods to print XML representation of tree to the output stream. */ -class TreeToStringComposer : public std::SingleDispatchFirstStaticParam < void, std::ostream &, TreeBase > { +class TreeToStringComposer : public std::SingleDispatchFirstStaticParam < TreeToStringComposer, void, std::ostream &, TreeBase > { static void compose ( std::ostream &, const RankedNode & tree ); static void compose ( std::ostream &, const alphabet::RankedSymbol & subtreeWildcard, const RankedNode & tree ); static void compose ( std::ostream &, const UnrankedNode & tree ); @@ -39,12 +39,6 @@ public: */ static void compose ( std::ostream & output, const Tree & tree ); - static TreeToStringComposer & getInstance ( ) { - static TreeToStringComposer res; - - return res; - } - }; } /* namespace tree */ diff --git a/astat2/src/AutomataStat.cpp b/astat2/src/AutomataStat.cpp index 631f14d8263e5d3b4b9d45705e146e63546251e8..1fa60d09f71e6a5d8cacd98c055f1dcad12f9d6b 100644 --- a/astat2/src/AutomataStat.cpp +++ b/astat2/src/AutomataStat.cpp @@ -19,7 +19,7 @@ #include <iostream> void AutomataStat::stat ( const automaton::Automaton & automaton, const AutomataSettings & settings ) { - getInstance ( ).dispatch ( automaton.getData ( ), settings ); + dispatch ( automaton.getData ( ), settings ); } void AutomataStat::stat ( const automaton::NFA & automaton, const AutomataSettings & settings ) { @@ -114,7 +114,7 @@ void AutomataStat::stat ( const automaton::NFA & automaton, const AutomataSettin } } -auto AutomataStatNFA = AutomataStat::RegistratorWrapper < void, automaton::NFA > ( AutomataStat::getInstance ( ), AutomataStat::stat ); +auto AutomataStatNFA = AutomataStat::RegistratorWrapper < void, automaton::NFA > ( AutomataStat::stat ); void AutomataStat::stat ( const automaton::DFA & automaton, const AutomataSettings & settings ) { switch ( settings.states ) { @@ -208,7 +208,7 @@ void AutomataStat::stat ( const automaton::DFA & automaton, const AutomataSettin } } -auto AutomataStatDFA = AutomataStat::RegistratorWrapper < void, automaton::DFA > ( AutomataStat::getInstance ( ), AutomataStat::stat ); +auto AutomataStatDFA = AutomataStat::RegistratorWrapper < void, automaton::DFA > ( AutomataStat::stat ); void AutomataStat::stat ( const automaton::InputDrivenNPDA & automaton, const AutomataSettings & settings ) { switch ( settings.states ) { @@ -302,7 +302,7 @@ void AutomataStat::stat ( const automaton::InputDrivenNPDA & automaton, const Au } } -auto AutomataStatInputDrivenNPDA = AutomataStat::RegistratorWrapper < void, automaton::InputDrivenNPDA > ( AutomataStat::getInstance ( ), AutomataStat::stat ); +auto AutomataStatInputDrivenNPDA = AutomataStat::RegistratorWrapper < void, automaton::InputDrivenNPDA > ( AutomataStat::stat ); void AutomataStat::stat ( const automaton::InputDrivenDPDA & automaton, const AutomataSettings & settings ) { switch ( settings.states ) { @@ -396,4 +396,4 @@ void AutomataStat::stat ( const automaton::InputDrivenDPDA & automaton, const Au } } -auto AutomataStatInputDrivenDPDA = AutomataStat::RegistratorWrapper < void, automaton::InputDrivenDPDA > ( AutomataStat::getInstance ( ), AutomataStat::stat ); +auto AutomataStatInputDrivenDPDA = AutomataStat::RegistratorWrapper < void, automaton::InputDrivenDPDA > ( AutomataStat::stat ); diff --git a/astat2/src/AutomataStat.h b/astat2/src/AutomataStat.h index 3f058ab5bf732450039eba01f4a7442ec74d1dbf..ac2cdf54be57a27bd7ab1f89e41f5c6a04321991 100644 --- a/astat2/src/AutomataStat.h +++ b/astat2/src/AutomataStat.h @@ -15,7 +15,7 @@ #include "AutomataSettings.h" -class AutomataStat : public std::SingleDispatchLastStaticParam < void, automaton::AutomatonBase, const AutomataSettings & > { +class AutomataStat : public std::SingleDispatchLastStaticParam < AutomataStat, void, automaton::AutomatonBase, const AutomataSettings & > { public: static void stat ( const automaton::Automaton & automaton, const AutomataSettings & settings ); @@ -25,12 +25,6 @@ public: static void stat ( const automaton::InputDrivenNPDA & automaton, const AutomataSettings & settings ); static void stat ( const automaton::InputDrivenDPDA & automaton, const AutomataSettings & settings ); - static AutomataStat & getInstance ( ) { - static AutomataStat res; - - return res; - } - }; #endif /* AUTOMATA_STAT_H_ */ diff --git a/astat2/src/GrammarStat.cpp b/astat2/src/GrammarStat.cpp index 51f7f227b538b379653b0046d06291b06702bffc..1d681f913551a6e5103e2d603bbaddc0568e9231 100644 --- a/astat2/src/GrammarStat.cpp +++ b/astat2/src/GrammarStat.cpp @@ -18,7 +18,7 @@ #include <iostream> void GrammarStat::stat ( const grammar::Grammar & grammar, const GrammarSettings & settings ) { - getInstance ( ).dispatch ( grammar.getData ( ), settings ); + dispatch ( grammar.getData ( ), settings ); } void GrammarStat::stat ( const grammar::RightRG & grammar, const GrammarSettings & settings ) { @@ -95,7 +95,7 @@ void GrammarStat::stat ( const grammar::RightRG & grammar, const GrammarSettings } } -auto GrammarStatRightRG = GrammarStat::RegistratorWrapper < void, grammar::RightRG > ( GrammarStat::getInstance ( ), GrammarStat::stat ); +auto GrammarStatRightRG = GrammarStat::RegistratorWrapper < void, grammar::RightRG > ( GrammarStat::stat ); void GrammarStat::stat ( const grammar::RightLG & grammar, const GrammarSettings & settings ) { switch ( settings.nonterminals ) { @@ -171,4 +171,4 @@ void GrammarStat::stat ( const grammar::RightLG & grammar, const GrammarSettings } } -auto GrammarStatRightLG = GrammarStat::RegistratorWrapper < void, grammar::RightLG > ( GrammarStat::getInstance ( ), GrammarStat::stat ); +auto GrammarStatRightLG = GrammarStat::RegistratorWrapper < void, grammar::RightLG > ( GrammarStat::stat ); diff --git a/astat2/src/GrammarStat.h b/astat2/src/GrammarStat.h index 7bcb32f9b8ec442dff9108e343c8dad2cb681534..6e8ed43e31a6e7ed3444e398f9820a6ee966b794 100644 --- a/astat2/src/GrammarStat.h +++ b/astat2/src/GrammarStat.h @@ -15,19 +15,13 @@ #include "GrammarSettings.h" -class GrammarStat : public std::SingleDispatchLastStaticParam < void, grammar::GrammarBase, const GrammarSettings & > { +class GrammarStat : public std::SingleDispatchLastStaticParam < GrammarStat, void, grammar::GrammarBase, const GrammarSettings & > { public: static void stat ( const grammar::Grammar & grammar, const GrammarSettings & settings ); static void stat ( const grammar::RightRG & grammar, const GrammarSettings & settings ); static void stat ( const grammar::RightLG & grammar, const GrammarSettings & settings ); - static GrammarStat & getInstance ( ) { - static GrammarStat res; - - return res; - } - }; #endif /* GRAMMAR_STAT_H_ */ diff --git a/astat2/src/RegExpStat.cpp b/astat2/src/RegExpStat.cpp index f438ba0be68e9642893ece3d05c59142ace14450..614b3b71a187be5b23bc613105b218c8af1305dd 100644 --- a/astat2/src/RegExpStat.cpp +++ b/astat2/src/RegExpStat.cpp @@ -19,7 +19,7 @@ #include <container/ObjectsSet.h> void RegExpStat::stat ( const regexp::RegExp & regexp, const RegExpSettings & settings ) { - getInstance ( ).dispatch ( regexp.getData ( ), settings ); + dispatch ( regexp.getData ( ), settings ); } unsigned RegExpStat::countNodes ( const regexp::FormalRegExpElement & ) { @@ -64,7 +64,7 @@ void RegExpStat::stat ( const regexp::FormalRegExp & regexp, const RegExpSetting } } -auto RegExpStatFormalRegExp = RegExpStat::RegistratorWrapper < void, regexp::FormalRegExp > ( RegExpStat::getInstance ( ), RegExpStat::stat ); +auto RegExpStatFormalRegExp = RegExpStat::RegistratorWrapper < void, regexp::FormalRegExp > ( RegExpStat::stat ); unsigned RegExpStat::countNodes ( const regexp::UnboundedRegExpElement & ) { throw exception::CommonException ( "unimplemented" ); @@ -108,4 +108,4 @@ void RegExpStat::stat ( const regexp::UnboundedRegExp & regexp, const RegExpSett } } -auto RegExpStatUnboundedRegExp = RegExpStat::RegistratorWrapper < void, regexp::UnboundedRegExp > ( RegExpStat::getInstance ( ), RegExpStat::stat ); +auto RegExpStatUnboundedRegExp = RegExpStat::RegistratorWrapper < void, regexp::UnboundedRegExp > ( RegExpStat::stat ); diff --git a/astat2/src/RegExpStat.h b/astat2/src/RegExpStat.h index 4178770df0cf24a19bea7ef0eca185274dbb0db1..875a58dee2a2e415a0f00e70f07abfa4a3628f28 100644 --- a/astat2/src/RegExpStat.h +++ b/astat2/src/RegExpStat.h @@ -15,7 +15,7 @@ #include "RegExpSettings.h" -class RegExpStat : public std::SingleDispatchLastStaticParam < void, regexp::RegExpBase, const RegExpSettings & > { +class RegExpStat : public std::SingleDispatchLastStaticParam < RegExpStat, void, regexp::RegExpBase, const RegExpSettings & > { static unsigned countNodes ( const regexp::FormalRegExpElement & node ); static unsigned countNodes ( const regexp::UnboundedRegExpElement & node ); @@ -26,12 +26,6 @@ public: static void stat ( const regexp::UnboundedRegExp & regexp, const RegExpSettings & settings ); static void stat ( const regexp::FormalRegExp & regexp, const RegExpSettings & settings ); - static RegExpStat & getInstance ( ) { - static RegExpStat res; - - return res; - } - }; #endif /* REG_EXP_STAT_H_ */ diff --git a/astat2/src/StringStat.cpp b/astat2/src/StringStat.cpp index 84bc91686c7f04f0fbd11613dd596bafa501bcfd..a1bf5e8e6c78e1ce53e634ad2a6c1da4c651b6da 100644 --- a/astat2/src/StringStat.cpp +++ b/astat2/src/StringStat.cpp @@ -16,7 +16,7 @@ #include <container/ObjectsVector.h> void StringStat::stat ( const string::String & string, const StringSettings & settings ) { - getInstance ( ).dispatch ( string.getData ( ), settings ); + dispatch ( string.getData ( ), settings ); } void StringStat::stat ( const string::LinearString & string, const StringSettings & settings ) { @@ -57,7 +57,7 @@ void StringStat::stat ( const string::LinearString & string, const StringSetting } } -auto StringStatFormalString = StringStat::RegistratorWrapper < void, string::LinearString > ( StringStat::getInstance ( ), StringStat::stat ); +auto StringStatFormalString = StringStat::RegistratorWrapper < void, string::LinearString > ( StringStat::stat ); void StringStat::stat ( const string::CyclicString & string, const StringSettings & settings ) { switch ( settings.alphabet ) { @@ -97,4 +97,4 @@ void StringStat::stat ( const string::CyclicString & string, const StringSetting } } -auto StringStatUnboundedString = StringStat::RegistratorWrapper < void, string::CyclicString > ( StringStat::getInstance ( ), StringStat::stat ); +auto StringStatUnboundedString = StringStat::RegistratorWrapper < void, string::CyclicString > ( StringStat::stat ); diff --git a/astat2/src/StringStat.h b/astat2/src/StringStat.h index 66430025b5bf85b82068830eeaf9d7d9513ce65d..33a6e40d1b4abbc3226c82a3c6c72e267b090cf9 100644 --- a/astat2/src/StringStat.h +++ b/astat2/src/StringStat.h @@ -15,19 +15,13 @@ #include "StringSettings.h" -class StringStat : public std::SingleDispatchLastStaticParam < void, string::StringBase, const StringSettings & > { +class StringStat : public std::SingleDispatchLastStaticParam < StringStat, void, string::StringBase, const StringSettings & > { public: static void stat ( const string::String & string, const StringSettings & settings ); static void stat ( const string::LinearString & string, const StringSettings & settings ); static void stat ( const string::CyclicString & string, const StringSettings & settings ); - static StringStat & getInstance ( ) { - static StringStat res; - - return res; - } - }; #endif /* STRING_STAT_H_ */ diff --git a/astat2/src/TreeStat.cpp b/astat2/src/TreeStat.cpp index 7e0b33740bc9f0e1e7d7a86a75525105fe6780a1..4cd70eb9ed281dba162bdac4bc405ea63bac3e4e 100644 --- a/astat2/src/TreeStat.cpp +++ b/astat2/src/TreeStat.cpp @@ -15,7 +15,7 @@ #include <container/ObjectsSet.h> void TreeStat::stat ( const tree::Tree & tree, const TreeSettings & settings ) { - getInstance ( ).dispatch ( tree.getData ( ), settings ); + dispatch ( tree.getData ( ), settings ); } unsigned TreeStat::countNodes ( const tree::RankedNode & node ) { @@ -65,7 +65,7 @@ void TreeStat::stat ( const tree::RankedTree & tree, const TreeSettings & settin } } -auto TreeStatFormalTree = TreeStat::RegistratorWrapper < void, tree::RankedTree > ( TreeStat::getInstance ( ), TreeStat::stat ); +auto TreeStatFormalTree = TreeStat::RegistratorWrapper < void, tree::RankedTree > ( TreeStat::stat ); unsigned TreeStat::countNodes ( const tree::UnrankedNode & node ) { unsigned res = 1; @@ -114,4 +114,4 @@ void TreeStat::stat ( const tree::UnrankedTree & tree, const TreeSettings & sett } } -auto TreeStatUnboundedTree = TreeStat::RegistratorWrapper < void, tree::UnrankedTree > ( TreeStat::getInstance ( ), TreeStat::stat ); +auto TreeStatUnboundedTree = TreeStat::RegistratorWrapper < void, tree::UnrankedTree > ( TreeStat::stat ); diff --git a/astat2/src/TreeStat.h b/astat2/src/TreeStat.h index b8d892ae8acc88f180d07ff733d5e116620779ad..d8a81d81277fa193c5647aaf2b7e00ffd7106fc0 100644 --- a/astat2/src/TreeStat.h +++ b/astat2/src/TreeStat.h @@ -15,7 +15,7 @@ #include "TreeSettings.h" -class TreeStat : public std::SingleDispatchLastStaticParam < void, tree::TreeBase, const TreeSettings & > { +class TreeStat : public std::SingleDispatchLastStaticParam < TreeStat, void, tree::TreeBase, const TreeSettings & > { static unsigned countNodes ( const tree::RankedNode & node ); static unsigned countNodes ( const tree::UnrankedNode & node ); @@ -26,12 +26,6 @@ public: static void stat ( const tree::RankedTree & tree, const TreeSettings & settings ); static void stat ( const tree::UnrankedTree & tree, const TreeSettings & settings ); - static TreeStat & getInstance ( ) { - static TreeStat res; - - return res; - } - }; #endif /* TREE_STAT_H_ */ diff --git a/astringology2/src/astringology.cpp b/astringology2/src/astringology.cpp index 5b69fb38de7741800ef59ebd9c49f8d9e0d63e52..663502705c0b978ee0de7f850c9945c81509aa90 100644 --- a/astringology2/src/astringology.cpp +++ b/astringology2/src/astringology.cpp @@ -31,8 +31,8 @@ #include <stringology/exact/ExactSubsequenceAutomaton.h> #include <stringology/exact/ExactNondeterministicSubsequenceAutomaton.h> #include <stringology/exact/ExactMultiNondeterministicSubsequenceAutomaton.h> -#include <stringology/exact/FactorOracleAutomaton.hpp> -#include <stringology/exact/SuffixAutomaton.hpp> +#include <stringology/exact/FactorOracleAutomaton.h> +#include <stringology/exact/SuffixAutomaton.h> #include <stringology/exact/BorderArray.h> #include <stringology/indexing/SuffixTrie.h>