diff --git a/aaccess2/src/AutomatonAccess.cpp b/aaccess2/src/AutomatonAccess.cpp index 4f9c41152a6213d6a3f37dfae42c545dbb5aa562..2acc5285c6715b2b86fceaa20f62537ab2922b0a 100644 --- a/aaccess2/src/AutomatonAccess.cpp +++ b/aaccess2/src/AutomatonAccess.cpp @@ -24,90 +24,134 @@ #include <container/ObjectsVariant.h> #include <container/ObjectsPair.h> -void AutomatonAccess::access ( const automaton::Automaton & automaton, const std::set < AutomatonSettings::Settings > & settings ) { - dispatch ( automaton.getData ( ), settings ); +#include "common/AccessHelpers.hpp" + +void AutomatonAccess::access ( automaton::Automaton & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + dispatch ( automaton.getData ( ), settings, operation, argument ); } -void AutomatonAccess::access ( const automaton::NFA < > & automaton, const std::set < AutomatonSettings::Settings > & settings ) { - if ( settings.count ( AutomatonSettings::Settings::STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getStates ( ) ); +void AutomatonAccess::access ( automaton::NFA < > & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == AutomatonSettings::Settings::STATES ) + return handleComponent < automaton::States > ( automaton, operation, argument ); + + if ( settings == AutomatonSettings::Settings::FINAL_STATES ) + return handleComponent < automaton::FinalStates > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::FINAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getFinalStates ( ) ); + if ( settings == AutomatonSettings::Settings::INITIAL_STATES ) + return handleElement < automaton::InitialState > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INITIAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getInitialState ( ) ); + if ( settings == AutomatonSettings::Settings::INPUT_ALPHABET ) + return handleComponent < automaton::InputAlphabet > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INPUT_ALPHABET ) ) alib::XmlDataFactory::toStdout ( automaton.getInputAlphabet ( ) ); + if ( settings == AutomatonSettings::Settings::TRANSITIONS && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); - if ( settings.count ( AutomatonSettings::Settings::TRANSITIONS ) ) alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); + throw exception::CommonException ( "Component not available" ); } auto AutomatonAccessNFA = AutomatonAccess::RegistratorWrapper < void, automaton::NFA < > > ( AutomatonAccess::access ); -void AutomatonAccess::access ( const automaton::DFA<> & automaton, const std::set < AutomatonSettings::Settings > & settings ) { - if ( settings.count ( AutomatonSettings::Settings::STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getStates ( ) ); +void AutomatonAccess::access ( automaton::DFA<> & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == AutomatonSettings::Settings::STATES ) + return handleComponent < automaton::States > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::FINAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getFinalStates ( ) ); + if ( settings == AutomatonSettings::Settings::FINAL_STATES ) + return handleComponent < automaton::FinalStates > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INITIAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getInitialState ( ) ); + if ( settings == AutomatonSettings::Settings::INITIAL_STATES ) + return handleElement < automaton::InitialState > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INPUT_ALPHABET ) ) alib::XmlDataFactory::toStdout ( automaton.getInputAlphabet ( ) ); + if ( settings == AutomatonSettings::Settings::INPUT_ALPHABET ) + return handleComponent < automaton::InputAlphabet > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::TRANSITIONS ) ) alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); + if ( settings == AutomatonSettings::Settings::TRANSITIONS && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); + + throw exception::CommonException ( "Component not available" ); } auto AutomatonAccessDFA = AutomatonAccess::RegistratorWrapper < void, automaton::DFA<> > ( AutomatonAccess::access ); -void AutomatonAccess::access ( const automaton::InputDrivenNPDA & automaton, const std::set < AutomatonSettings::Settings > & settings ) { - if ( settings.count ( AutomatonSettings::Settings::STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getStates ( ) ); +void AutomatonAccess::access ( automaton::InputDrivenNPDA & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == AutomatonSettings::Settings::STATES ) + return handleComponent < automaton::States > ( automaton, operation, argument ); + + if ( settings == AutomatonSettings::Settings::FINAL_STATES ) + return handleComponent < automaton::FinalStates > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::FINAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getFinalStates ( ) ); + if ( settings == AutomatonSettings::Settings::INITIAL_STATES ) + return handleElement < automaton::InitialState > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INITIAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getInitialState ( ) ); + if ( settings == AutomatonSettings::Settings::INPUT_ALPHABET ) + return handleComponent < automaton::InputAlphabet > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INPUT_ALPHABET ) ) alib::XmlDataFactory::toStdout ( automaton.getInputAlphabet ( ) ); + if ( settings == AutomatonSettings::Settings::TRANSITIONS && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); - if ( settings.count ( AutomatonSettings::Settings::TRANSITIONS ) ) alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); + throw exception::CommonException ( "Component not available" ); } auto AutomatonAccessInputDrivenNPDA = AutomatonAccess::RegistratorWrapper < void, automaton::InputDrivenNPDA > ( AutomatonAccess::access ); -void AutomatonAccess::access ( const automaton::InputDrivenDPDA & automaton, const std::set < AutomatonSettings::Settings > & settings ) { - if ( settings.count ( AutomatonSettings::Settings::STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getStates ( ) ); +void AutomatonAccess::access ( automaton::InputDrivenDPDA & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == AutomatonSettings::Settings::STATES ) + return handleComponent < automaton::States > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::FINAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getFinalStates ( ) ); + if ( settings == AutomatonSettings::Settings::FINAL_STATES ) + return handleComponent < automaton::FinalStates > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INITIAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getInitialState ( ) ); + if ( settings == AutomatonSettings::Settings::INITIAL_STATES ) + return handleElement < automaton::InitialState > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INPUT_ALPHABET ) ) alib::XmlDataFactory::toStdout ( automaton.getInputAlphabet ( ) ); + if ( settings == AutomatonSettings::Settings::INPUT_ALPHABET ) + return handleComponent < automaton::InputAlphabet > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::TRANSITIONS ) ) alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); + if ( settings == AutomatonSettings::Settings::TRANSITIONS && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); + + throw exception::CommonException ( "Component not available" ); } auto AutomatonAccessInputDrivenDPDA = AutomatonAccess::RegistratorWrapper < void, automaton::InputDrivenDPDA > ( AutomatonAccess::access ); -void AutomatonAccess::access ( const automaton::NPDA & automaton, const std::set < AutomatonSettings::Settings > & settings ) { - if ( settings.count ( AutomatonSettings::Settings::STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getStates ( ) ); +void AutomatonAccess::access ( automaton::NPDA & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == AutomatonSettings::Settings::STATES ) + return handleComponent < automaton::States > ( automaton, operation, argument ); + + if ( settings == AutomatonSettings::Settings::FINAL_STATES ) + return handleComponent < automaton::FinalStates > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::FINAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getFinalStates ( ) ); + if ( settings == AutomatonSettings::Settings::INITIAL_STATES ) + return handleElement < automaton::InitialState > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INITIAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getInitialState ( ) ); + if ( settings == AutomatonSettings::Settings::INPUT_ALPHABET ) + return handleComponent < automaton::InputAlphabet > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INPUT_ALPHABET ) ) alib::XmlDataFactory::toStdout ( automaton.getInputAlphabet ( ) ); + if ( settings == AutomatonSettings::Settings::TRANSITIONS && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); - if ( settings.count ( AutomatonSettings::Settings::TRANSITIONS ) ) alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); + throw exception::CommonException ( "Component not available" ); } auto AutomatonAccessNPDA = AutomatonAccess::RegistratorWrapper < void, automaton::NPDA > ( AutomatonAccess::access ); -void AutomatonAccess::access ( const automaton::DPDA & automaton, const std::set < AutomatonSettings::Settings > & settings ) { - if ( settings.count ( AutomatonSettings::Settings::STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getStates ( ) ); +void AutomatonAccess::access ( automaton::DPDA & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == AutomatonSettings::Settings::STATES ) + return handleComponent < automaton::States > ( automaton, operation, argument ); + + if ( settings == AutomatonSettings::Settings::FINAL_STATES ) + return handleComponent < automaton::FinalStates > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::FINAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getFinalStates ( ) ); + if ( settings == AutomatonSettings::Settings::INITIAL_STATES ) + return handleElement < automaton::InitialState > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INITIAL_STATES ) ) alib::XmlDataFactory::toStdout ( automaton.getInitialState ( ) ); + if ( settings == AutomatonSettings::Settings::INPUT_ALPHABET ) + return handleComponent < automaton::InputAlphabet > ( automaton, operation, argument ); - if ( settings.count ( AutomatonSettings::Settings::INPUT_ALPHABET ) ) alib::XmlDataFactory::toStdout ( automaton.getInputAlphabet ( ) ); + if ( settings == AutomatonSettings::Settings::TRANSITIONS && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); - if ( settings.count ( AutomatonSettings::Settings::TRANSITIONS ) ) alib::XmlDataFactory::toStdout ( automaton.getTransitions ( ) ); + throw exception::CommonException ( "Component not available" ); } auto AutomatonAccessDPDA = AutomatonAccess::RegistratorWrapper < void, automaton::DPDA > ( AutomatonAccess::access ); diff --git a/aaccess2/src/AutomatonAccess.h b/aaccess2/src/AutomatonAccess.h index 216c2eb879f2596d64543df11aa7f6b5d0266837..8a739da7a371a0ac118ba0e98eeb391b333ec10b 100644 --- a/aaccess2/src/AutomatonAccess.h +++ b/aaccess2/src/AutomatonAccess.h @@ -14,20 +14,21 @@ #include "automaton/AutomatonFeatures.h" #include "settings/AutomatonSettings.h" +#include "settings/OperationSettings.h" #include <set> -class AutomatonAccess : public std::SingleDispatch < AutomatonAccess, void, const automaton::AutomatonBase &, const std::set < AutomatonSettings::Settings > & > { +class AutomatonAccess : public std::SingleDispatch < AutomatonAccess, void, automaton::AutomatonBase &, const AutomatonSettings::Settings &, const OperationSettings::Settings &, std::deque < sax::Token > & > { public: - static void access ( const automaton::Automaton & automaton, const std::set < AutomatonSettings::Settings > & settings ); + static void access ( automaton::Automaton & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); - static void access ( const automaton::NFA < > & automaton, const std::set < AutomatonSettings::Settings > & settings ); - static void access ( const automaton::DFA<> & automaton, const std::set < AutomatonSettings::Settings > & settings ); + static void access ( automaton::NFA < > & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); + static void access ( automaton::DFA < > & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); - static void access ( const automaton::InputDrivenNPDA & automaton, const std::set < AutomatonSettings::Settings > & settings ); - static void access ( const automaton::InputDrivenDPDA & automaton, const std::set < AutomatonSettings::Settings > & settings ); + static void access ( automaton::InputDrivenNPDA & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); + static void access ( automaton::InputDrivenDPDA & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); - static void access ( const automaton::DPDA & automaton, const std::set < AutomatonSettings::Settings > & settings ); - static void access ( const automaton::NPDA & automaton, const std::set < AutomatonSettings::Settings > & settings ); + static void access ( automaton::DPDA & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); + static void access ( automaton::NPDA & automaton, const AutomatonSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); }; #endif /* AUTOMATA_ACCESS_H_ */ diff --git a/aaccess2/src/ExceptionAccess.cpp b/aaccess2/src/ExceptionAccess.cpp index 66c8ac92892f6527c192e3334299f6253f753183..c9f7088b4978bb8bb3766c64609d09809312c67e 100644 --- a/aaccess2/src/ExceptionAccess.cpp +++ b/aaccess2/src/ExceptionAccess.cpp @@ -15,10 +15,21 @@ #include <container/ObjectsVariant.h> #include <container/ObjectsPair.h> -void ExceptionAccess::access ( const exception::CommonException & exception, const std::set < ExceptionSettings::Settings > & settings ) { - if ( settings.count ( ExceptionSettings::Settings::CAUSE ) ) std::cout << exception.getCause ( ); +void ExceptionAccess::access ( const exception::CommonException & exception, const ExceptionSettings::Settings & settings, const OperationSettings::Settings & operation ) { + if ( settings == ExceptionSettings::Settings::CAUSE && operation == OperationSettings::Settings::GET ) { + std::cout << exception.getCause ( ); + return; + } - if ( settings.count ( ExceptionSettings::Settings::BACKTRACE ) ) std::cout << exception.getBacktrace ( ); + if ( settings == ExceptionSettings::Settings::BACKTRACE && operation == OperationSettings::Settings::GET ) { + std::cout << exception.getBacktrace ( ); + return; + } - if ( settings.count ( ExceptionSettings::Settings::COMMAND ) ) std::cout << exception.getCommand ( ); + if ( settings == ExceptionSettings::Settings::COMMAND && operation == OperationSettings::Settings::GET ) { + std::cout << exception.getCommand ( ); + return; + } + + throw exception::CommonException ( "Component not available" ); } diff --git a/aaccess2/src/ExceptionAccess.h b/aaccess2/src/ExceptionAccess.h index c317018a33e589cff9c973820b0d3bc78895aba5..f1321fa9c89ab671f502070ea54ededd672fce74 100644 --- a/aaccess2/src/ExceptionAccess.h +++ b/aaccess2/src/ExceptionAccess.h @@ -11,11 +11,12 @@ #include <exception/CommonException.h> #include "settings/ExceptionSettings.h" +#include "settings/OperationSettings.h" #include <set> class ExceptionAccess { public: - static void access ( const exception::CommonException & exception, const std::set < ExceptionSettings::Settings > & settings ); + static void access ( const exception::CommonException & exception, const ExceptionSettings::Settings & settings, const OperationSettings::Settings & operation ); }; #endif /* EXCEPTION_ACCESS_H_ */ diff --git a/aaccess2/src/GrammarAccess.cpp b/aaccess2/src/GrammarAccess.cpp index b82110488c4b1cbf765609110b635676c4e19dc0..cf544be944a11c46a031098eee542f37a417a5db 100644 --- a/aaccess2/src/GrammarAccess.cpp +++ b/aaccess2/src/GrammarAccess.cpp @@ -18,30 +18,44 @@ #include <container/ObjectsVariant.h> #include <container/ObjectsPair.h> -void GrammarAccess::access ( const grammar::Grammar & grammar, const std::set < GrammarSettings::Settings > & settings ) { - dispatch ( grammar.getData ( ), settings ); +#include "common/AccessHelpers.hpp" + +void GrammarAccess::access ( grammar::Grammar & grammar, const GrammarSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + dispatch ( grammar.getData ( ), settings, operation, argument ); } -void GrammarAccess::access ( const grammar::RightRG & grammar, const std::set < GrammarSettings::Settings > & settings ) { - if ( settings.count ( GrammarSettings::Settings::NONTERMINALS ) ) alib::XmlDataFactory::toStdout ( grammar.getNonterminalAlphabet ( ) ); +void GrammarAccess::access ( grammar::RightRG & grammar, const GrammarSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == GrammarSettings::Settings::NONTERMINALS ) + return handleComponent < grammar::NonterminalAlphabet > ( grammar, operation, argument ); + + if ( settings == GrammarSettings::Settings::TERMINALS ) + return handleComponent < grammar::TerminalAlphabet > ( grammar, operation, argument ); - if ( settings.count ( GrammarSettings::Settings::TERMINALS ) ) alib::XmlDataFactory::toStdout ( grammar.getTerminalAlphabet ( ) ); + if ( settings == GrammarSettings::Settings::INITIAL_SYMBOLS ) + return handleElement < grammar::InitialSymbol > ( grammar, operation, argument ); - if ( settings.count ( GrammarSettings::Settings::INITIAL_SYMBOLS ) ) alib::XmlDataFactory::toStdout ( grammar.getInitialSymbol ( ) ); + if ( settings == GrammarSettings::Settings::RULES && operation == OperationSettings::Settings::GET ) + alib::XmlDataFactory::toStdout ( grammar.getRules ( ) ); - if ( settings.count ( GrammarSettings::Settings::RULES ) ) alib::XmlDataFactory::toStdout ( grammar.getRules ( ) ); + throw exception::CommonException ( "Component not available" ); } auto GrammarAccessRightRG = GrammarAccess::RegistratorWrapper < void, grammar::RightRG > ( GrammarAccess::access ); -void GrammarAccess::access ( const grammar::RightLG & grammar, const std::set < GrammarSettings::Settings > & settings ) { - if ( settings.count ( GrammarSettings::Settings::NONTERMINALS ) ) alib::XmlDataFactory::toStdout ( grammar.getNonterminalAlphabet ( ) ); +void GrammarAccess::access ( grammar::RightLG & grammar, const GrammarSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == GrammarSettings::Settings::NONTERMINALS ) + return handleComponent < grammar::NonterminalAlphabet > ( grammar, operation, argument ); + + if ( settings == GrammarSettings::Settings::TERMINALS ) + return handleComponent < grammar::TerminalAlphabet > ( grammar, operation, argument ); - if ( settings.count ( GrammarSettings::Settings::TERMINALS ) ) alib::XmlDataFactory::toStdout ( grammar.getTerminalAlphabet ( ) ); + if ( settings == GrammarSettings::Settings::INITIAL_SYMBOLS ) + return handleElement < grammar::InitialSymbol > ( grammar, operation, argument ); - if ( settings.count ( GrammarSettings::Settings::INITIAL_SYMBOLS ) ) alib::XmlDataFactory::toStdout ( grammar.getInitialSymbol ( ) ); + if ( settings == GrammarSettings::Settings::RULES && operation == OperationSettings::Settings::GET ) + alib::XmlDataFactory::toStdout ( grammar.getRules ( ) ); - if ( settings.count ( GrammarSettings::Settings::RULES ) ) alib::XmlDataFactory::toStdout ( grammar.getRules ( ) ); + throw exception::CommonException ( "Component not available" ); } auto GrammarAccessRightLG = GrammarAccess::RegistratorWrapper < void, grammar::RightLG > ( GrammarAccess::access ); diff --git a/aaccess2/src/GrammarAccess.h b/aaccess2/src/GrammarAccess.h index 157713398b409c700d17ebea94f5fd5ce145b967..0f479a704b78a50e55e820796de231e0c23f83c0 100644 --- a/aaccess2/src/GrammarAccess.h +++ b/aaccess2/src/GrammarAccess.h @@ -14,14 +14,15 @@ #include "grammar/GrammarFeatures.h" #include "settings/GrammarSettings.h" +#include "settings/OperationSettings.h" #include <set> -class GrammarAccess : public std::SingleDispatch < GrammarAccess, void, const grammar::GrammarBase &, const std::set < GrammarSettings::Settings > & > { +class GrammarAccess : public std::SingleDispatch < GrammarAccess, void, grammar::GrammarBase &, const GrammarSettings::Settings &, const OperationSettings::Settings &, std::deque < sax::Token > & > { public: - static void access ( const grammar::Grammar & grammar, const std::set < GrammarSettings::Settings > & settings ); + static void access ( grammar::Grammar & grammar, const GrammarSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); - static void access ( const grammar::RightRG & grammar, const std::set < GrammarSettings::Settings > & settings ); - static void access ( const grammar::RightLG & grammar, const std::set < GrammarSettings::Settings > & settings ); + static void access ( grammar::RightRG & grammar, const GrammarSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); + static void access ( grammar::RightLG & grammar, const GrammarSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); }; #endif /* GRAMMAR_ACCESS_H_ */ diff --git a/aaccess2/src/PairSetAccess.cpp b/aaccess2/src/PairSetAccess.cpp index f441b2e22c2f4d70c4a541fc4a288f21fe5c46c6..e353da8ee98b08bcac251bda5fbd70eba29f129c 100644 --- a/aaccess2/src/PairSetAccess.cpp +++ b/aaccess2/src/PairSetAccess.cpp @@ -15,20 +15,22 @@ #include <container/ObjectsVariant.h> #include <container/ObjectsPair.h> -void PairSetAccess::access ( const std::set < std::pair < alib::Object, alib::Object > > & pairSet, const std::set < PairSetSettings::Settings > & settings ) { - if ( settings.count ( PairSetSettings::Settings::FIRST ) ) { +void PairSetAccess::access ( const std::set < std::pair < alib::Object, alib::Object > > & pairSet, const PairSetSettings::Settings & settings, const OperationSettings::Settings & operation ) { + if ( settings == PairSetSettings::Settings::FIRST && operation == OperationSettings::Settings::GET ) { std::set < alib::Object > res; for ( const std::pair < alib::Object, alib::Object > & pair : pairSet ) res.insert ( pair.first ); - - alib::XmlDataFactory::toStdout ( res ); + + return alib::XmlDataFactory::toStdout ( res ); } - if ( settings.count ( PairSetSettings::Settings::SECOND ) ) { + if ( settings == PairSetSettings::Settings::SECOND && operation == OperationSettings::Settings::GET ) { std::set < alib::Object > res; for ( const std::pair < alib::Object, alib::Object > & pair : pairSet ) res.insert ( pair.second ); - - alib::XmlDataFactory::toStdout ( res ); + + return alib::XmlDataFactory::toStdout ( res ); } + + throw exception::CommonException ( "Component not available" ); } diff --git a/aaccess2/src/PairSetAccess.h b/aaccess2/src/PairSetAccess.h index 0c8c2c10d8c649327ebd2a0fd80d2fe89f7ba5bc..4a48ae6f4e2a8ce493ecb2615ada85533f48b9c7 100644 --- a/aaccess2/src/PairSetAccess.h +++ b/aaccess2/src/PairSetAccess.h @@ -13,12 +13,13 @@ #include <object/Object.h> #include "settings/PairSetSettings.h" +#include "settings/OperationSettings.h" #include <set> #include <pair> class PairSetAccess { public: - static void access ( const std::set < std::pair < alib::Object, alib::Object > > & pairSet, const std::set < PairSetSettings::Settings > & settings ); + static void access ( const std::set < std::pair < alib::Object, alib::Object > > & pairSet, const PairSetSettings::Settings & settings, const OperationSettings::Settings & operation ); }; diff --git a/aaccess2/src/RegExpAccess.cpp b/aaccess2/src/RegExpAccess.cpp index a54ab80f3a97e725b1cb1fedbdd6fa8aa1bb4855..0fb2b0e8ba5f96a08e4e2446ee10b69d608f0b15 100644 --- a/aaccess2/src/RegExpAccess.cpp +++ b/aaccess2/src/RegExpAccess.cpp @@ -22,22 +22,30 @@ #include <container/ObjectsVariant.h> #include <container/ObjectsPair.h> -void RegExpAccess::access ( const regexp::RegExp & regexp, const std::set < RegExpSettings::Settings > & settings ) { - dispatch ( regexp.getData ( ), settings ); +#include "common/AccessHelpers.hpp" + +void RegExpAccess::access ( regexp::RegExp & regexp, const RegExpSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + dispatch ( regexp.getData ( ), settings, operation, argument ); } -void RegExpAccess::access ( const regexp::FormalRegExp & regexp, const std::set < RegExpSettings::Settings > & settings ) { - if ( settings.count ( RegExpSettings::Settings::ALPHABET ) ) alib::XmlDataFactory::toStdout ( regexp.getAlphabet ( ) ); +void RegExpAccess::access ( regexp::FormalRegExp & regexp, const RegExpSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == RegExpSettings::Settings::ALPHABET ) + return handleComponent < regexp::GeneralAlphabet > ( regexp, operation, argument ); + + if ( settings == RegExpSettings::Settings::CONTENT && operation == OperationSettings::Settings::GET ) alib::XmlDataFactory::toStdout ( regexp.getRegExp ( ) ); - if ( settings.count ( RegExpSettings::Settings::CONTENT ) ) alib::XmlDataFactory::toStdout ( regexp.getRegExp ( ) ); + throw exception::CommonException ( "Component not available" ); } auto RegExpAccessFormalRegExp = RegExpAccess::RegistratorWrapper < void, regexp::FormalRegExp > ( RegExpAccess::access ); -void RegExpAccess::access ( const regexp::UnboundedRegExp & regexp, const std::set < RegExpSettings::Settings > & settings ) { - if ( settings.count ( RegExpSettings::Settings::ALPHABET ) ) alib::XmlDataFactory::toStdout ( regexp.getAlphabet ( ) ); +void RegExpAccess::access ( regexp::UnboundedRegExp & regexp, const RegExpSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == RegExpSettings::Settings::ALPHABET ) + return handleComponent < regexp::GeneralAlphabet > ( regexp, operation, argument ); + + if ( settings == RegExpSettings::Settings::CONTENT && operation == OperationSettings::Settings::GET ) alib::XmlDataFactory::toStdout ( regexp.getRegExp ( ) ); - if ( settings.count ( RegExpSettings::Settings::CONTENT ) ) alib::XmlDataFactory::toStdout ( regexp.getRegExp ( ) ); + throw exception::CommonException ( "Component not available" ); } auto RegExpAccessUnboundedRegExp = RegExpAccess::RegistratorWrapper < void, regexp::UnboundedRegExp > ( RegExpAccess::access ); diff --git a/aaccess2/src/RegExpAccess.h b/aaccess2/src/RegExpAccess.h index 4561acd7ac3814765a485d8e75300f1ae703bd29..ad0a268cc966bf4a38e568e7c60efba1db3d29d7 100644 --- a/aaccess2/src/RegExpAccess.h +++ b/aaccess2/src/RegExpAccess.h @@ -14,14 +14,15 @@ #include "regexp/RegExpFeatures.h" #include "settings/RegExpSettings.h" +#include "settings/OperationSettings.h" #include <set> -class RegExpAccess : public std::SingleDispatch < RegExpAccess, void, const regexp::RegExpBase &, const std::set < RegExpSettings::Settings > & > { +class RegExpAccess : public std::SingleDispatch < RegExpAccess, void, regexp::RegExpBase &, const RegExpSettings::Settings &, const OperationSettings::Settings &, std::deque < sax::Token > & > { public: - static void access ( const regexp::RegExp & regexp, const std::set < RegExpSettings::Settings > & settings ); + static void access ( regexp::RegExp & regexp, const RegExpSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); - static void access ( const regexp::UnboundedRegExp & regexp, const std::set < RegExpSettings::Settings > & settings ); - static void access ( const regexp::FormalRegExp & regexp, const std::set < RegExpSettings::Settings > & settings ); + static void access ( regexp::UnboundedRegExp & regexp, const RegExpSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); + static void access ( regexp::FormalRegExp & regexp, const RegExpSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); }; #endif /* REG_EXP_ACCESS_H_ */ diff --git a/aaccess2/src/StringAccess.cpp b/aaccess2/src/StringAccess.cpp index 88b670a2d400954a2a2ba662555302112003ccbe..79a13a7fff67c5fea9090cce1107105567377128 100644 --- a/aaccess2/src/StringAccess.cpp +++ b/aaccess2/src/StringAccess.cpp @@ -18,22 +18,32 @@ #include <container/ObjectsVariant.h> #include <container/ObjectsPair.h> -void StringAccess::access ( const string::String & string, const std::set < StringSettings::Settings > & settings ) { - dispatch ( string.getData ( ), settings ); +#include "common/AccessHelpers.hpp" + +void StringAccess::access ( string::String & string, const StringSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + dispatch ( string.getData ( ), settings, operation, argument ); } -void StringAccess::access ( const string::LinearString < > & string, const std::set < StringSettings::Settings > & settings ) { - if ( settings.count ( StringSettings::Settings::ALPHABET ) ) alib::XmlDataFactory::toStdout ( string.getAlphabet ( ) ); +void StringAccess::access ( string::LinearString < > & string, const StringSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == StringSettings::Settings::ALPHABET ) + return handleComponent < string::GeneralAlphabet > ( string, operation, argument ); + + if ( settings == StringSettings::Settings::CONTENT && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( string.getContent ( ) ); - if ( settings.count ( StringSettings::Settings::CONTENT ) ) alib::XmlDataFactory::toStdout ( string.getContent ( ) ); + throw exception::CommonException ( "Component not available" ); } auto StringAccessFormalString = StringAccess::RegistratorWrapper < void, string::LinearString < > > ( StringAccess::access ); -void StringAccess::access ( const string::CyclicString < > & string, const std::set < StringSettings::Settings > & settings ) { - if ( settings.count ( StringSettings::Settings::ALPHABET ) ) alib::XmlDataFactory::toStdout ( string.getAlphabet ( ) ); +void StringAccess::access ( string::CyclicString < > & string, const StringSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == StringSettings::Settings::ALPHABET ) + return handleComponent < string::GeneralAlphabet > ( string, operation, argument ); + + if ( settings == StringSettings::Settings::CONTENT && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( string.getContent ( ) ); - if ( settings.count ( StringSettings::Settings::CONTENT ) ) alib::XmlDataFactory::toStdout ( string.getContent ( ) ); + throw exception::CommonException ( "Component not available" ); } auto StringAccessUnboundedString = StringAccess::RegistratorWrapper < void, string::CyclicString < > > ( StringAccess::access ); diff --git a/aaccess2/src/StringAccess.h b/aaccess2/src/StringAccess.h index 9574bcb247dac0237f1cb183f7e7a2257f32780c..d62642bce4b21028673bc22e34f467a49fa60c3d 100644 --- a/aaccess2/src/StringAccess.h +++ b/aaccess2/src/StringAccess.h @@ -14,14 +14,15 @@ #include "string/StringFeatures.h" #include "settings/StringSettings.h" +#include "settings/OperationSettings.h" #include <set> -class StringAccess : public std::SingleDispatch < StringAccess, void, const string::StringBase &, const std::set < StringSettings::Settings > & > { +class StringAccess : public std::SingleDispatch < StringAccess, void, string::StringBase &, const StringSettings::Settings &, const OperationSettings::Settings &, std::deque < sax::Token > & > { public: - static void access ( const string::String & string, const std::set < StringSettings::Settings > & settings ); + static void access ( string::String & string, const StringSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); - static void access ( const string::LinearString < > & string, const std::set < StringSettings::Settings > & settings ); - static void access ( const string::CyclicString < > & string, const std::set < StringSettings::Settings > & settings ); + static void access ( string::LinearString < > & string, const StringSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); + static void access ( string::CyclicString < > & string, const StringSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); }; #endif /* STRING_ACCESS_H_ */ diff --git a/aaccess2/src/TreeAccess.cpp b/aaccess2/src/TreeAccess.cpp index 440d967311cfccdd242061880d873ca810139ea3..71f8739b11ef08d2e5c22b3e56e7906f04eeb6e1 100644 --- a/aaccess2/src/TreeAccess.cpp +++ b/aaccess2/src/TreeAccess.cpp @@ -20,54 +20,65 @@ #include <container/ObjectsVariant.h> #include <container/ObjectsPair.h> -void TreeAccess::access ( const tree::Tree & tree, const std::set < TreeSettings::Settings > & settings ) { - dispatch ( tree.getData ( ), settings ); -} +#include "common/AccessHelpers.hpp" -void TreeAccess::access ( const tree::RankedTree & tree, const std::set < TreeSettings::Settings > & settings ) { - if ( settings.count ( TreeSettings::Settings::ALPHABET ) ) alib::XmlDataFactory::toStdout ( tree.getAlphabet ( ) ); +void TreeAccess::access ( tree::Tree & tree, const TreeSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + dispatch ( tree.getData ( ), settings, operation, argument ); +} - if ( settings.count ( TreeSettings::Settings::CONTENT ) ) alib::XmlDataFactory::toStdout ( tree.getRoot ( ) ); +void TreeAccess::access ( tree::RankedTree & tree, const TreeSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == TreeSettings::Settings::ALPHABET ) + return handleComponent < tree::GeneralAlphabet > ( tree, operation, argument ); - if ( settings.count ( TreeSettings::Settings::SUBTREE_WILDCARD ) ) throw exception::CommonException ( "Not available" ); + if ( settings == TreeSettings::Settings::CONTENT && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( tree.getRoot ( ) ); - if ( settings.count ( TreeSettings::Settings::NONLINEAR_VARIABLES ) ) throw exception::CommonException ( "Not available" ); + throw exception::CommonException ( "Component not available" ); } auto TreeAccessRankedTree = TreeAccess::RegistratorWrapper < void, tree::RankedTree > ( TreeAccess::access ); -void TreeAccess::access ( const tree::RankedPattern & tree, const std::set < TreeSettings::Settings > & settings ) { - if ( settings.count ( TreeSettings::Settings::ALPHABET ) ) alib::XmlDataFactory::toStdout ( tree.getAlphabet ( ) ); +void TreeAccess::access ( tree::RankedPattern & tree, const TreeSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == TreeSettings::Settings::ALPHABET ) + return handleComponent < tree::GeneralAlphabet > ( tree, operation, argument ); - if ( settings.count ( TreeSettings::Settings::CONTENT ) ) alib::XmlDataFactory::toStdout ( tree.getRoot ( ) ); + if ( settings == TreeSettings::Settings::CONTENT && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( tree.getRoot ( ) ); - if ( settings.count ( TreeSettings::Settings::SUBTREE_WILDCARD ) ) alib::XmlDataFactory::toStdout ( tree.getSubtreeWildcard ( ) ); + if ( settings == TreeSettings::Settings::SUBTREE_WILDCARD && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( tree.getSubtreeWildcard ( ) ); - if ( settings.count ( TreeSettings::Settings::NONLINEAR_VARIABLES ) ) throw exception::CommonException ( "Not available" ); + throw exception::CommonException ( "Component not available" ); } auto TreeAccessRankedPattern = TreeAccess::RegistratorWrapper < void, tree::RankedPattern > ( TreeAccess::access ); -void TreeAccess::access ( const tree::RankedNonlinearPattern & tree, const std::set < TreeSettings::Settings > & settings ) { - if ( settings.count ( TreeSettings::Settings::ALPHABET ) ) alib::XmlDataFactory::toStdout ( tree.getAlphabet ( ) ); +void TreeAccess::access ( tree::RankedNonlinearPattern & tree, const TreeSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == TreeSettings::Settings::ALPHABET ) + return handleComponent < tree::GeneralAlphabet > ( tree, operation, argument ); - if ( settings.count ( TreeSettings::Settings::CONTENT ) ) alib::XmlDataFactory::toStdout ( tree.getRoot ( ) ); + if ( settings == TreeSettings::Settings::CONTENT ) + return alib::XmlDataFactory::toStdout ( tree.getRoot ( ) ); - if ( settings.count ( TreeSettings::Settings::SUBTREE_WILDCARD ) ) alib::XmlDataFactory::toStdout ( tree.getSubtreeWildcard ( ) ); + if ( settings == TreeSettings::Settings::SUBTREE_WILDCARD && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( tree.getSubtreeWildcard ( ) ); - if ( settings.count ( TreeSettings::Settings::NONLINEAR_VARIABLES ) ) alib::XmlDataFactory::toStdout ( tree.getNonlinearVariables ( ) ); + if ( settings == TreeSettings::Settings::NONLINEAR_VARIABLES && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( tree.getNonlinearVariables ( ) ); + + throw exception::CommonException ( "Component not available" ); } auto TreeAccessRankedNonlinearPattern = TreeAccess::RegistratorWrapper < void, tree::RankedNonlinearPattern > ( TreeAccess::access ); -void TreeAccess::access ( const tree::UnrankedTree & tree, const std::set < TreeSettings::Settings > & settings ) { - if ( settings.count ( TreeSettings::Settings::ALPHABET ) ) alib::XmlDataFactory::toStdout ( tree.getAlphabet ( ) ); - - if ( settings.count ( TreeSettings::Settings::CONTENT ) ) alib::XmlDataFactory::toStdout ( tree.getRoot ( ) ); +void TreeAccess::access ( tree::UnrankedTree & tree, const TreeSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + if ( settings == TreeSettings::Settings::ALPHABET ) + return handleComponent < tree::GeneralAlphabet > ( tree, operation, argument ); - if ( settings.count ( TreeSettings::Settings::SUBTREE_WILDCARD ) ) throw exception::CommonException ( "Not available" ); + if ( settings == TreeSettings::Settings::CONTENT && operation == OperationSettings::Settings::GET ) + return alib::XmlDataFactory::toStdout ( tree.getRoot ( ) ); - if ( settings.count ( TreeSettings::Settings::NONLINEAR_VARIABLES ) ) throw exception::CommonException ( "Not available" ); + throw exception::CommonException ( "Component not available" ); } auto TreeAccessUnrankedTree = TreeAccess::RegistratorWrapper < void, tree::UnrankedTree > ( TreeAccess::access ); diff --git a/aaccess2/src/TreeAccess.h b/aaccess2/src/TreeAccess.h index 8a6cdbde6acfa17245319a1d51f163243286a4b5..b430c5cadb1e96333b3821df7fb39f37fbd1aca3 100644 --- a/aaccess2/src/TreeAccess.h +++ b/aaccess2/src/TreeAccess.h @@ -14,16 +14,17 @@ #include "tree/TreeFeatures.h" #include "settings/TreeSettings.h" +#include "settings/OperationSettings.h" #include <set> -class TreeAccess : public std::SingleDispatch < TreeAccess, void, const tree::TreeBase &, const std::set < TreeSettings::Settings > & > { +class TreeAccess : public std::SingleDispatch < TreeAccess, void, tree::TreeBase &, const TreeSettings::Settings &, const OperationSettings::Settings &, std::deque < sax::Token > & > { public: - static void access ( const tree::Tree & tree, const std::set < TreeSettings::Settings > & settings ); + static void access ( tree::Tree & tree, const TreeSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); - static void access ( const tree::RankedTree & tree, const std::set < TreeSettings::Settings > & settings ); - static void access ( const tree::RankedPattern & tree, const std::set < TreeSettings::Settings > & settings ); - static void access ( const tree::RankedNonlinearPattern & tree, const std::set < TreeSettings::Settings > & settings ); - static void access ( const tree::UnrankedTree & tree, const std::set < TreeSettings::Settings > & settings ); + static void access ( tree::RankedTree & tree, const TreeSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); + static void access ( tree::RankedPattern & tree, const TreeSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); + static void access ( tree::RankedNonlinearPattern & tree, const TreeSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); + static void access ( tree::UnrankedTree & tree, const TreeSettings::Settings & settings, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ); }; #endif /* TREE_ACCESS_H_ */ diff --git a/aaccess2/src/aaccess.cpp b/aaccess2/src/aaccess.cpp index 096b50ab8691e7fa3c258372ce1c71a7d22740fe..f7ec46a8dfa5ed817722c6ff9d9dd3ef71895137 100644 --- a/aaccess2/src/aaccess.cpp +++ b/aaccess2/src/aaccess.cpp @@ -22,6 +22,8 @@ #include "TreeAccess.h" #include "PairSetAccess.h" +#include "settings/OperationSettings.h" + #include <container/ObjectsSet.h> #include <container/ObjectsPair.h> @@ -33,16 +35,16 @@ int main ( int argc, char * argv[] ) { common::GlobalData::argc = argc; common::GlobalData::argv = argv; - TCLAP::CmdLine cmd ( "Prints internals of automata, grammars, regexps, ...", ' ', "0.01" ); + TCLAP::CmdLine cmd ( "Access internals of automata, grammars, regexps, ...", ' ', "0.01" ); - // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- + // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- std::vector < std::string > automatonSettings { AutomatonSettings::stringsVector ( ) }; TCLAP::ValuesConstraint < std::string > automatonPrintingOptionsVals ( automatonSettings ); - TCLAP::MultiArg < std::string > automaton ( "", "automaton", "Access components of automata", false, & automatonPrintingOptionsVals ); + TCLAP::ValueArg < std::string > automatonInput ( "", "automaton", "Access components of automata", false, "", & automatonPrintingOptionsVals ); // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -52,7 +54,7 @@ int main ( int argc, char * argv[] ) { TCLAP::ValuesConstraint < std::string > grammarPrintingOptionsVals ( grammarSettings ); - TCLAP::MultiArg < std::string > grammar ( "", "grammar", "Access components of grammars", false, & grammarPrintingOptionsVals ); + TCLAP::ValueArg < std::string > grammarInput ( "", "grammar", "Access components of grammars", false, "", & grammarPrintingOptionsVals ); // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -62,7 +64,7 @@ int main ( int argc, char * argv[] ) { TCLAP::ValuesConstraint < std::string > regexpPrintingOptionsVals ( regexpSettings ); - TCLAP::MultiArg < std::string > regexp ( "", "regexp", "Access components of regexps", false, & regexpPrintingOptionsVals ); + TCLAP::ValueArg < std::string > regexpInput ( "", "regexp", "Access components of regexps", false, "", & regexpPrintingOptionsVals ); // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -72,7 +74,7 @@ int main ( int argc, char * argv[] ) { TCLAP::ValuesConstraint < std::string > exceptionPrintingOptionsVals ( exceptionSettings ); - TCLAP::MultiArg < std::string > exception ( "", "exception", "Access components of exceptions", false, & exceptionPrintingOptionsVals ); + TCLAP::ValueArg < std::string > exceptionInput ( "", "exception", "Access components of exceptions", false, "", & exceptionPrintingOptionsVals ); // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -82,7 +84,7 @@ int main ( int argc, char * argv[] ) { TCLAP::ValuesConstraint < std::string > stringPrintingOptionsVals ( stringSettings ); - TCLAP::MultiArg < std::string > string ( "", "string", "Access components of strings", false, & stringPrintingOptionsVals ); + TCLAP::ValueArg < std::string > stringInput ( "", "string", "Access components of strings", false, "", & stringPrintingOptionsVals ); // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -92,7 +94,7 @@ int main ( int argc, char * argv[] ) { TCLAP::ValuesConstraint < std::string > treePrintingOptionsVals ( treeSettings ); - TCLAP::MultiArg < std::string > tree ( "", "tree", "Access components of trees", false, & treePrintingOptionsVals ); + TCLAP::ValueArg < std::string > treeInput ( "", "tree", "Access components of trees", false, "", & treePrintingOptionsVals ); // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -102,23 +104,34 @@ int main ( int argc, char * argv[] ) { TCLAP::ValuesConstraint < std::string > pairSetPrintingOptionsVals ( pairSetSettings ); - TCLAP::MultiArg < std::string > pairSet ( "", "pairSet", "Access components of set of pairs", false, & pairSetPrintingOptionsVals ); + TCLAP::ValueArg < std::string > pairSetInput ( "", "pairSet", "Access components of set of pairs", false, "", & pairSetPrintingOptionsVals ); // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- std::vector < TCLAP::Arg * > xorlist; - xorlist.push_back ( & automaton ); - xorlist.push_back ( & grammar ); - xorlist.push_back ( & regexp ); - xorlist.push_back ( & exception ); - xorlist.push_back ( & string ); - xorlist.push_back ( & tree ); - xorlist.push_back ( & pairSet ); + xorlist.push_back ( & automatonInput ); + xorlist.push_back ( & grammarInput ); + xorlist.push_back ( & regexpInput ); + xorlist.push_back ( & exceptionInput ); + xorlist.push_back ( & stringInput ); + xorlist.push_back ( & treeInput ); + xorlist.push_back ( & pairSetInput ); cmd.xorAdd ( xorlist ); + std::vector < std::string > operationSettings { + OperationSettings::stringsVector ( ) + }; + TCLAP::ValuesConstraint < std::string > allowedVals ( operationSettings ); + + TCLAP::ValueArg < std::string > operation ( "o", "operation", "Operation type", false, "", & allowedVals ); + cmd.add ( operation ); + TCLAP::ValueArg < std::string > file ( "i", "input", "Read from file", false, "-", "file" ); cmd.add ( file ); + TCLAP::ValueArg < std::string > argument ( "a", "argument", "Operation argument", false, "", "file" ); + cmd.add ( argument ); + TCLAP::SwitchArg measure ( "m", "measure", "Measure times", false ); cmd.add ( measure ); @@ -138,96 +151,60 @@ int main ( int argc, char * argv[] ) { std::deque < sax::Token > tokens = sax::FromXMLParserHelper::parseInput ( file ); - if ( alib::XmlDataFactory::first < automaton::Automaton > ( tokens ) && automaton.isSet ( ) ) { - std::set < AutomatonSettings::Settings > settings; - - for ( const std::string & param : automaton.getValue ( ) ) - settings.insert ( AutomatonSettings::fromString ( param ) ); + std::deque < sax::Token > argumentTokens; + if ( argument.isSet ( ) ) + argumentTokens = sax::FromXMLParserHelper::parseInput( argument ); + if ( alib::XmlDataFactory::first < automaton::Automaton > ( tokens ) && automatonInput.isSet ( ) ) { automaton::Automaton automaton = alib::XmlDataFactory::fromTokens < automaton::Automaton > ( std::move ( tokens ) ); measurements::end ( ); measurements::start ( "Accesss print", measurements::Type::MAIN ); - AutomatonAccess::access ( automaton, settings ); - } else if ( alib::XmlDataFactory::first < grammar::Grammar > ( tokens ) && grammar.isSet ( ) ) { - std::set < GrammarSettings::Settings > settings; - - for ( const std::string & param : grammar.getValue ( ) ) - settings.insert ( GrammarSettings::fromString ( param ) ); - + AutomatonAccess::access ( automaton, AutomatonSettings::fromString ( automatonInput.getValue ( ) ), OperationSettings::fromString ( operation.getValue ( ) ), argumentTokens ); + } else if ( alib::XmlDataFactory::first < grammar::Grammar > ( tokens ) && grammarInput.isSet ( ) ) { grammar::Grammar grammar = alib::XmlDataFactory::fromTokens < grammar::Grammar > ( std::move ( tokens ) ); measurements::end ( ); measurements::start ( "Accesss print", measurements::Type::MAIN ); - GrammarAccess::access ( grammar, settings ); - } else if ( alib::XmlDataFactory::first < regexp::RegExp > ( tokens ) && regexp.isSet ( ) ) { - std::set < RegExpSettings::Settings > settings; - - for ( const std::string & param : regexp.getValue ( ) ) - settings.insert ( RegExpSettings::fromString ( param ) ); - + GrammarAccess::access ( grammar, GrammarSettings::fromString ( grammarInput.getValue ( ) ), OperationSettings::fromString ( operation.getValue ( ) ), argumentTokens ); + } else if ( alib::XmlDataFactory::first < regexp::RegExp > ( tokens ) && regexpInput.isSet ( ) ) { regexp::RegExp regexp = alib::XmlDataFactory::fromTokens < regexp::RegExp > ( std::move ( tokens ) ); measurements::end ( ); measurements::start ( "Accesss print", measurements::Type::MAIN ); - RegExpAccess::access ( regexp, settings ); - } else if ( alib::XmlDataFactory::first < exception::CommonException > ( tokens ) && exception.isSet ( ) ) { - std::set < ExceptionSettings::Settings > settings; - - for ( const std::string & param : exception.getValue ( ) ) - settings.insert ( ExceptionSettings::fromString ( param ) ); - + RegExpAccess::access ( regexp, RegExpSettings::fromString ( regexpInput.getValue ( ) ), OperationSettings::fromString ( operation.getValue ( ) ), argumentTokens ); + } else if ( alib::XmlDataFactory::first < exception::CommonException > ( tokens ) && exceptionInput.isSet ( ) ) { exception::CommonException exception = alib::XmlDataFactory::fromTokens < exception::CommonException > ( std::move ( tokens ) ); measurements::end ( ); measurements::start ( "Accesss print", measurements::Type::MAIN ); - ExceptionAccess::access ( exception, settings ); - } else if ( alib::XmlDataFactory::first < string::String > ( tokens ) && string.isSet ( ) ) { - std::set < StringSettings::Settings > settings; - - for ( const std::string & param : string.getValue ( ) ) - settings.insert ( StringSettings::fromString ( param ) ); - + ExceptionAccess::access ( exception, ExceptionSettings::fromString ( exceptionInput.getValue ( ) ), OperationSettings::fromString ( operation.getValue ( ) ) ); + } else if ( alib::XmlDataFactory::first < string::String > ( tokens ) && stringInput.isSet ( ) ) { string::String string = alib::XmlDataFactory::fromTokens < string::String > ( std::move ( tokens ) ); measurements::end ( ); measurements::start ( "Accesss print", measurements::Type::MAIN ); - StringAccess::access ( string, settings ); - } else if ( alib::XmlDataFactory::first < tree::Tree > ( tokens ) && tree.isSet ( ) ) { - std::set < TreeSettings::Settings > settings; - - for ( const std::string & param : tree.getValue ( ) ) - settings.insert ( TreeSettings::fromString ( param ) ); - + StringAccess::access ( string, StringSettings::fromString ( stringInput.getValue ( ) ), OperationSettings::fromString ( operation.getValue ( ) ), argumentTokens ); + } else if ( alib::XmlDataFactory::first < tree::Tree > ( tokens ) && treeInput.isSet ( ) ) { tree::Tree tree = alib::XmlDataFactory::fromTokens < tree::Tree > ( std::move ( tokens ) ); measurements::end ( ); measurements::start ( "Accesss print", measurements::Type::MAIN ); - TreeAccess::access ( tree, settings ); - } else if ( alib::XmlDataFactory::first < std::set < std::pair < alib::Object, alib::Object > > > ( tokens ) && pairSet.isSet ( ) ) { - std::set < PairSetSettings::Settings > settings; - - for ( const std::string & param : pairSet.getValue ( ) ) - settings.insert ( PairSetSettings::fromString ( param ) ); - + TreeAccess::access ( tree, TreeSettings::fromString ( treeInput.getValue ( ) ), OperationSettings::fromString ( operation.getValue ( ) ), argumentTokens ); + } else if ( alib::XmlDataFactory::first < std::set < std::pair < alib::Object, alib::Object > > > ( tokens ) && pairSetInput.isSet ( ) ) { std::set < std::pair < alib::Object, alib::Object > > pairSet = alib::XmlDataFactory::fromTokens < std::set < std::pair < alib::Object, alib::Object > > > ( std::move ( tokens ) ); measurements::end ( ); measurements::start ( "Accesss print", measurements::Type::MAIN ); - PairSetAccess::access ( pairSet, settings ); - } else if ( alib::XmlDataFactory::first < label::LabelSetLabel > ( tokens ) && pairSet.isSet ( ) ) { - std::set < PairSetSettings::Settings > settings; - - for ( const std::string & param : pairSet.getValue ( ) ) - settings.insert ( PairSetSettings::fromString ( param ) ); - + PairSetAccess::access ( pairSet, PairSetSettings::fromString ( pairSetInput.getValue ( ) ), OperationSettings::fromString ( operation.getValue ( ) ) ); + } else if ( alib::XmlDataFactory::first < label::LabelSetLabel > ( tokens ) && pairSetInput.isSet ( ) ) { std::set < label::Label > labelSet = alib::XmlDataFactory::fromTokens < label::LabelSetLabel > ( std::move ( tokens ) ).getData ( ); std::set < std::pair < alib::Object, alib::Object > > pairSet; for ( const label::Label & label : labelSet ) { @@ -238,7 +215,7 @@ int main ( int argc, char * argv[] ) { measurements::end ( ); measurements::start ( "Accesss print", measurements::Type::MAIN ); - PairSetAccess::access ( pairSet, settings ); + PairSetAccess::access ( pairSet, PairSetSettings::fromString ( pairSetInput.getValue ( ) ), OperationSettings::fromString ( operation.getValue ( ) ) ); } else { throw exception::CommonException ( "Input not recognized." ); } diff --git a/aaccess2/src/common/AccessHelpers.hpp b/aaccess2/src/common/AccessHelpers.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c3abd699e2cc2045baa98aea76af79e1b219a62f --- /dev/null +++ b/aaccess2/src/common/AccessHelpers.hpp @@ -0,0 +1,64 @@ +/* + * AccessHelpers.h + * + * Created on: 5. 8. 2016 + * Author: Jan Travnicek + */ + +#ifndef ACCESS_HELPERS_HPP_ +#define ACCESS_HELPERS_HPP_ + +template < class Element, class DataType > +void handleElement ( DataType & data, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + typedef typename std::remove_const < typename std::remove_reference < decltype ( data.template accessElement < Element > ( ).get ( ) ) >::type >::type ElementDataType; + + if ( operation == OperationSettings::Settings::GET ) { + alib::XmlDataFactory::toStdout ( data.template accessElement < Element > ( ).get ( ) ); + } + + if ( operation == OperationSettings::Settings::SET ) { + ElementDataType symbols = alib::XmlDataFactory::fromTokens < ElementDataType > ( std::move ( argument ) ); + + data.template accessElement < Element > ( ).set ( std::move ( symbols ) ); + + alib::XmlDataFactory::toStdout ( data ); + } + + if ( operation == OperationSettings::Settings::ADD || operation == OperationSettings::Settings::REMOVE ) + throw exception::CommonException ( "Invalid access operation" ); +} + +template < class Component, class DataType > +void handleComponent ( DataType & data, const OperationSettings::Settings & operation, std::deque < sax::Token > & argument ) { + typedef typename std::remove_const < typename std::remove_reference < decltype ( data.template accessComponent < Component > ( ).get ( ) ) >::type >::type ComponentDataType; + + if ( operation == OperationSettings::Settings::GET ) { + alib::XmlDataFactory::toStdout ( data.template accessComponent < Component > ( ).get ( ) ); + } + + if ( operation == OperationSettings::Settings::ADD ) { + ComponentDataType symbols = alib::XmlDataFactory::fromTokens < ComponentDataType > ( std::move ( argument ) ); + + data.template accessComponent < Component > ( ).add ( std::move ( symbols ) ); + + alib::XmlDataFactory::toStdout ( data ); + } + + if ( operation == OperationSettings::Settings::SET ) { + ComponentDataType symbols = alib::XmlDataFactory::fromTokens < ComponentDataType > ( std::move ( argument ) ); + + data.template accessComponent < Component > ( ).set ( std::move ( symbols ) ); + + alib::XmlDataFactory::toStdout ( data ); + } + + if ( operation == OperationSettings::Settings::REMOVE ) { + ComponentDataType symbols = alib::XmlDataFactory::fromTokens < ComponentDataType > ( std::move ( argument ) ); + + data.template accessComponent < Component > ( ).remove ( std::move ( symbols ) ); + + alib::XmlDataFactory::toStdout ( data ); + } +} + +#endif /* ACCESS_HELPERS_HPP_ */ diff --git a/aaccess2/src/settings/OperationSettings.h b/aaccess2/src/settings/OperationSettings.h new file mode 100644 index 0000000000000000000000000000000000000000..efa8056af422ad37e0dae691dddbfcdd9799838a --- /dev/null +++ b/aaccess2/src/settings/OperationSettings.h @@ -0,0 +1,44 @@ +/* + * OperationSettings.h + * + * Created on: 26. 3. 2014 + * Author: Jan Travnicek + */ + +#ifndef __OPERATION_SETTINGS_H__ +#define __OPERATION_SETTINGS_H__ + +#include "SettingsHelper.h" + +class OperationEnum { +public: + enum class Settings { + GET, SET, ADD, REMOVE, __MAX__ + }; + + static std::string toString ( OperationEnum::Settings settings ) { + switch ( settings ) { + case OperationEnum::Settings::GET: + return "get"; + + case OperationEnum::Settings::SET: + return "set"; + + case OperationEnum::Settings::ADD: + return "add"; + + case OperationEnum::Settings::REMOVE: + return "remove"; + + case OperationEnum::Settings::__MAX__: + throw exception::CommonException ( "Invalid enumeration" ); + } + throw exception::CommonException ( "Invalid enumeration" ); + } + +}; + +class OperationSettings : public OperationEnum, public EnumClassHelper < OperationEnum > { +}; + +#endif /* __OPERATION_SETTINGS_H__ */ diff --git a/alib2data/src/string/String.cpp b/alib2data/src/string/String.cpp index 394ca7fc471e88e7c9deab0c99585105ef2d457b..a1e09f2ce3a48c80687a76bee5f5762933c12117 100644 --- a/alib2data/src/string/String.cpp +++ b/alib2data/src/string/String.cpp @@ -13,14 +13,6 @@ namespace string { -const std::set < alphabet::Symbol > & String::getAlphabet ( ) const { - return this->getData ( ).getAlphabet ( ); -} - -void String::extendAlphabet ( const std::set < alphabet::Symbol > & symbols ) { - this->getData ( ).extendAlphabet ( symbols ); -} - string::String stringFrom ( const alphabet::Symbol & symbol ) { return string::String { string::LinearString < > { std::vector < alphabet::Symbol > { symbol } } }; } diff --git a/alib2data/src/string/String.h b/alib2data/src/string/String.h index 20b759d625f92b90c1c6ad58258d80eed02ff541..6bdd9bc1f7759d05d17575e9cfbcb1f5ed9ffc9c 100644 --- a/alib2data/src/string/String.h +++ b/alib2data/src/string/String.h @@ -23,9 +23,6 @@ class String : public alib::WrapperBase < StringBase > { using alib::WrapperBase < StringBase >::WrapperBase; public: - const std::set < alphabet::Symbol > & getAlphabet ( ) const; - void extendAlphabet ( const std::set < alphabet::Symbol > & symbols ); - static const std::string & getXmlTagRefName() { static std::string xmlTagName = "StringRef"; diff --git a/alib2data/src/string/StringBase.h b/alib2data/src/string/StringBase.h index 2d64f928f7aa5f7deaf305d81c9ed96bf3f49415..fe7c47a54f84f9d7a90b3975253a9d608bbe24e6 100644 --- a/alib2data/src/string/StringBase.h +++ b/alib2data/src/string/StringBase.h @@ -20,10 +20,7 @@ namespace string { class StringBase : public alib::ObjectBase { public: virtual StringBase * clone ( ) const = 0; - virtual StringBase * plunder ( ) && = 0; - - virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const = 0; - virtual void extendAlphabet ( const std::set < alphabet::Symbol > & symbols ) = 0; + virtual StringBase * plunder ( ) && = 0; }; } /* namespace string */ diff --git a/alib2data/src/tree/RankedTreeBase.h b/alib2data/src/tree/RankedTreeBase.h index a3a12129929c40c555765e5a338f2d8b9276ccdd..e5183ee48008ffa8d178b28241b4702495d3a153 100644 --- a/alib2data/src/tree/RankedTreeBase.h +++ b/alib2data/src/tree/RankedTreeBase.h @@ -21,9 +21,6 @@ class RankedTreeBase : public TreeBase { public: virtual RankedTreeBase * clone ( ) const = 0; virtual RankedTreeBase * plunder ( ) && = 0; - - virtual const std::set < alphabet::RankedSymbol > & getAlphabet ( ) const = 0; - virtual void extendAlphabet ( const std::set < alphabet::RankedSymbol > & symbols ) = 0; }; } /* namespace tree */ diff --git a/alib2data/src/tree/RankedTreeWrapper.cpp b/alib2data/src/tree/RankedTreeWrapper.cpp index 1f6be4e6d253530c7ce51ce79b9b9a5667e350e6..0ca773c0cef8afc584df7cd4b07c410f5a28b4f4 100644 --- a/alib2data/src/tree/RankedTreeWrapper.cpp +++ b/alib2data/src/tree/RankedTreeWrapper.cpp @@ -8,18 +8,6 @@ #include "RankedTreeWrapper.h" #include <XmlApi.hpp> -namespace tree { - -const std::set < alphabet::RankedSymbol > & RankedTreeWrapper::getAlphabet ( ) const { - return this->getData ( ).getAlphabet ( ); -} - -void RankedTreeWrapper::extendAlphabet ( const std::set < alphabet::RankedSymbol > & symbols ) { - this->getData ( ).extendAlphabet ( symbols ); -} - -} /* namespace tree */ - namespace alib { auto RankedTreeWrapperDeleter = xmlApi < ::tree::RankedTreeWrapper >::InputContextDeleter ( ); diff --git a/alib2data/src/tree/RankedTreeWrapper.h b/alib2data/src/tree/RankedTreeWrapper.h index cd4a9e2e971ffbadf34009dc833a863ea950e67d..aece2718e462bde95e08e65b0fde84bb2cab5026 100644 --- a/alib2data/src/tree/RankedTreeWrapper.h +++ b/alib2data/src/tree/RankedTreeWrapper.h @@ -20,9 +20,6 @@ class RankedTreeWrapper : public alib::WrapperBase < RankedTreeBase > { using alib::WrapperBase < RankedTreeBase >::WrapperBase; public: - const std::set < alphabet::RankedSymbol > & getAlphabet ( ) const; - void extendAlphabet ( const std::set < alphabet::RankedSymbol > & symbols ); - static const std::string & getXmlTagRefName() { static std::string xmlTagName = "RankedTreeWrapperRef"; diff --git a/alib2data/src/tree/UnrankedTreeBase.h b/alib2data/src/tree/UnrankedTreeBase.h index 813a718a02c7bdb45aa020c95233d7a744083dd1..b106d4a3406c665353a00656e719a8d8292dc681 100644 --- a/alib2data/src/tree/UnrankedTreeBase.h +++ b/alib2data/src/tree/UnrankedTreeBase.h @@ -21,9 +21,6 @@ class UnrankedTreeBase : public TreeBase { public: virtual UnrankedTreeBase * clone ( ) const = 0; virtual UnrankedTreeBase * plunder ( ) && = 0; - - virtual const std::set < alphabet::Symbol > & getAlphabet ( ) const = 0; - virtual void extendAlphabet ( const std::set < alphabet::Symbol > & symbols ) = 0; }; } /* namespace tree */ diff --git a/alib2data/src/tree/UnrankedTreeWrapper.cpp b/alib2data/src/tree/UnrankedTreeWrapper.cpp index 1ec21ad52902b88f01248d3a54900465d2539112..a3e77429a0520505868ae8840b95e46cf00a626b 100644 --- a/alib2data/src/tree/UnrankedTreeWrapper.cpp +++ b/alib2data/src/tree/UnrankedTreeWrapper.cpp @@ -8,18 +8,6 @@ #include "UnrankedTreeWrapper.h" #include <XmlApi.hpp> -namespace tree { - -const std::set < alphabet::Symbol > & UnrankedTreeWrapper::getAlphabet ( ) const { - return this->getData ( ).getAlphabet ( ); -} - -void UnrankedTreeWrapper::extendAlphabet ( const std::set < alphabet::Symbol > & symbols ) { - this->getData ( ).extendAlphabet ( symbols ); -} - -} /* namespace tree */ - namespace alib { auto UnrankedTreeWrapperDeleter = xmlApi < ::tree::UnrankedTreeWrapper >::InputContextDeleter ( ); diff --git a/alib2data/src/tree/UnrankedTreeWrapper.h b/alib2data/src/tree/UnrankedTreeWrapper.h index 9b585b4e174fa464e1e7a623007f1ea057dea144..bf85e3e574e232a5744c342c136810f958034a5a 100644 --- a/alib2data/src/tree/UnrankedTreeWrapper.h +++ b/alib2data/src/tree/UnrankedTreeWrapper.h @@ -20,9 +20,6 @@ class UnrankedTreeWrapper : public alib::WrapperBase < UnrankedTreeBase > { using alib::WrapperBase < UnrankedTreeBase >::WrapperBase; public: - const std::set < alphabet::Symbol > & getAlphabet ( ) const; - void extendAlphabet ( const std::set < alphabet::Symbol > & symbols ); - static const std::string & getXmlTagRefName() { static std::string xmlTagName = "UnrankedTreeWrapperRef"; diff --git a/alphabetManip2/makefile b/alphabetManip2/makefile deleted file mode 100644 index dd28431218de3e5e12d74d27f43649de54c2e156..0000000000000000000000000000000000000000 --- a/alphabetManip2/makefile +++ /dev/null @@ -1,157 +0,0 @@ -SHELL:=/bin/bash -USE_RAMDISK ?= 0 --include makefile.conf - -define NEW_LINE - - -endef - -export NEW_LINE - -LDFLAGS_DEBUG:=-Wl,-no-as-needed $(addprefix -L, $(addsuffix lib-debug, $(LINK_PATHS))) -rdynamic $(addprefix -l, $(LINK_LIBRARIES)) -Wl,-rpath,. - -LDFLAGS_RELEASE:=-Wl,-no-as-needed $(addprefix -L, $(addsuffix lib-release, $(LINK_PATHS))) -rdynamic $(addprefix -l, $(LINK_LIBRARIES)) -Wl,-rpath,. - -OBJECTS_DEBUG:=$(patsubst src/%.cpp, obj-debug/%.o, $(shell find src/ -name *cpp)) - -OBJECTS_RELEASE:=$(patsubst src/%.cpp, obj-release/%.o, $(shell find src/ -name *cpp)) - -.PHONY: all build-debug clean-debug doc - -all: - @echo "What to do master?" - -FORCE: - -# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -# make subdir makefile - -%/makefile: makefile makefile.conf - if [ ! -w $(dir $@) ] && [ $(USE_RAMDISK) -eq 1 ]; then\ - ln -s /tmp/`date +'%s%N'`-$(dir $@) $(subst /, , $(dir $@)) 2>/dev/null;\ - fi;\ - if [ -L $(subst /, , $(dir $@)) ]; then\ - mkdir -p `readlink $(subst /, , $(dir $@))`;\ - else\ - mkdir -p $(dir $@);\ - fi - echo "\ - SHELL:=/bin/bash$${NEW_LINE}\ - SRCDIR:=$${NEW_LINE}\ - $${NEW_LINE}\ - define NEW_LINE$${NEW_LINE}\ - $${NEW_LINE}\ - $${NEW_LINE}\ - endef$${NEW_LINE}\ - $${NEW_LINE}\ - export NEW_LINE$${NEW_LINE}\ - $${NEW_LINE}\ - CXXFLAGS:= -pipe -std=c++11 \$$(CXX_OTHER_FLAGS) -c -Wall -pedantic -Wextra -Werror -fPIC $(addprefix -I, $(INCLUDE_PATHS))$${NEW_LINE}\ - $${NEW_LINE}\ - SOURCES:= \$$(shell find \$$(SOURCES_BASE_DIR)/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")$${NEW_LINE}\ - DEPENDENCIES:= \$$(patsubst \$$(SOURCES_BASE_DIR)/\$$(SRCDIR)%.cpp, \$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d, \$$(SOURCES))$${NEW_LINE}\ - OBJECTS:= \$$(patsubst %.d, %.o, \$$(DEPENDENCIES))$${NEW_LINE}\ - SOURCES_DIRS:= \$$(shell find \$$(SOURCES_BASE_DIR)/\$$(SRCDIR) -maxdepth 1 -mindepth 1 -type d)$${NEW_LINE}\ - OBJECTS_DIRS:= \$$(patsubst \$$(SOURCES_BASE_DIR)/\$$(SRCDIR)%, %/, \$$(SOURCES_DIRS))$${NEW_LINE}\ - OBJECTS_DIRS_MAKEFILES:= \$$(patsubst %, %makefile, \$$(OBJECTS_DIRS))$${NEW_LINE}\ - $${NEW_LINE}\ - .PHONY: all$${NEW_LINE}\ - .PRECIOUS: \$$(DEPENDECIES) \$$(OBJECTS_DIRS_MAKEFILES)$${NEW_LINE}\ - $${NEW_LINE}\ - all: \$$(OBJECTS_DIRS) \$$(OBJECTS)$${NEW_LINE}\ - $${NEW_LINE}\ - %.d: makefile$${NEW_LINE}\ - @echo \"\\$${NEW_LINE}\ - \$$(shell sha1sum <<< \"\$$@\" | sed \"s/ -//g\") = \\$$\$$(shell (\\$$\$$(CXX) -M \\$$\$$(CXXFLAGS) \$$(patsubst \$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,\$$(SOURCES_BASE_DIR)/\$$(SRCDIR)%.cpp, \$$@) 2>/dev/null || echo \\\"\$$(patsubst \$$(OBJECTS_BASE_DIR)/\$$(SRCDIR)%.d,\$$(SOURCES_BASE_DIR)/\$$(SRCDIR)%.cpp, \$$@) FORCE\\\") | sed \\\"s/.*://g;s/\\\\\\\\\\\\\\\\//g\\\")\$$\$${NEW_LINE}\\$${NEW_LINE}\ - \$$(patsubst %.d,%.o, \$$@): \\$$\$$(\$$(shell sha1sum <<< \"\$$@\" | sed \"s/ -//g\")) makefile\$$\$${NEW_LINE}\\$${NEW_LINE}\ - \\$$\$$(CXX) \\$$\$$(CXXFLAGS) \\$$\$$< -o \$$(patsubst %.d,%.o, \$$@)\$$\$${NEW_LINE}\\$${NEW_LINE}\ - \" > \$$@$${NEW_LINE}\ - $${NEW_LINE}\ - %/makefile: makefile$${NEW_LINE}\ - mkdir -p \$$(dir \$$@)$${NEW_LINE}\ - cp makefile \$$@$${NEW_LINE}\ - $${NEW_LINE}\ - %/: FORCE | %/makefile$${NEW_LINE}\ - @accesstime=\`stat -c %Y \$$@\` && \\$${NEW_LINE}\ - \$$(MAKE) -C \$$@ SRCDIR=\$$(SRCDIR)\$$(notdir \$$(patsubst %/, %, \$$@))/ OBJECTS_BASE_DIR=\$$(OBJECTS_BASE_DIR) SOURCES_BASE_DIR=\$$(SOURCES_BASE_DIR) CXX_OTHER_FLAGS=\"\$$(CXX_OTHER_FLAGS)\" && \\$${NEW_LINE}\ - accesstime2=\`stat -c %Y \$$@\` && \\$${NEW_LINE}\ - if [ "\$$\$$accesstime" -ne "\$$\$$accesstime2" ]; then \\$${NEW_LINE}\ - touch .; \\$${NEW_LINE}\ - fi$${NEW_LINE}\ - $${NEW_LINE}\ - FORCE:$${NEW_LINE}\ - $${NEW_LINE}\ - -include \$$(DEPENDENCIES)" > $@ - -# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -# final lib/bin construction - -bin-debug/$(EXECUTABLE): obj-debug/ $(OBJECTS_DEBUG) - if [ ! -w $(dir $@) ] && [ $(USE_RAMDISK) -eq 1 ]; then\ - ln -s /tmp/`date +'%s%N'`-$(dir $@) $(subst /, , $(dir $@)) 2>/dev/null;\ - fi;\ - if [ -L $(subst /, , $(dir $@)) ]; then\ - mkdir -p `readlink $(subst /, , $(dir $@))`;\ - else\ - mkdir -p $(dir $@);\ - fi - $(CXX) $(OBJECTS_DEBUG) -o $@ $(LDFLAGS_DEBUG) - -bin-release/$(EXECUTABLE): obj-release/ $(OBJECTS_RELEASE) - if [ ! -w $(dir $@) ] && [ $(USE_RAMDISK) -eq 1 ]; then\ - ln -s /tmp/`date +'%s%N'`-$(dir $@) $(subst /, , $(dir $@)) 2>/dev/null;\ - fi;\ - if [ -L $(subst /, , $(dir $@)) ]; then\ - mkdir -p `readlink $(subst /, , $(dir $@))`;\ - else\ - mkdir -p $(dir $@);\ - fi - $(CXX) $(OBJECTS_RELEASE) -o $@ $(LDFLAGS_RELEASE) - -# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -# subdir make calls - -obj-debug/: FORCE | obj-debug/makefile - $(MAKE) -C $@ OBJECTS_BASE_DIR=$(realpath obj-debug) SOURCES_BASE_DIR=$(realpath src) CXX_OTHER_FLAGS="-g -O0 -DDEBUG" - -obj-release/: FORCE | obj-release/makefile - $(MAKE) -C $@ OBJECTS_BASE_DIR=$(realpath obj-release) SOURCES_BASE_DIR=$(realpath src) CXX_OTHER_FLAGS="-O3 -DNDEBUG -DRELEASE" - -# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -# objects dependencies - -$(OBJECTS_DEBUG): obj-debug/ - -$(OBJECTS_RELEASE): obj-release/ - -# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -# main targets - -debug: bin-debug/$(EXECUTABLE) - -release: bin-release/$(EXECUTABLE) - -clean: clean-debug clean-release - $(RM) -r doc - -clean-debug: - if [ -L obj-debug ]; then\ - rm -r `readlink obj-debug`;\ - fi - if [ -L bin-debug ]; then\ - rm -r `readlink bin-debug`;\ - fi - $(RM) -r *.o *.d bin-debug obj-debug - -clean-release: - if [ -L obj-release ]; then\ - rm -r `readlink obj-release`;\ - fi - if [ -L lib-release ]; then\ - rm -r `readlink lib-release`;\ - fi - $(RM) -r *.o *.d bin-release obj-release - -doc: - doxygen diff --git a/alphabetManip2/makefile.conf b/alphabetManip2/makefile.conf deleted file mode 100644 index f6af577cd6fbb9b9bad838e537a43232f0268210..0000000000000000000000000000000000000000 --- a/alphabetManip2/makefile.conf +++ /dev/null @@ -1,4 +0,0 @@ -EXECUTABLE:=alphabetManip2 -LINK_PATHS=../alib2elgo/ ../alib2algo/ ../alib2data/ ../alib2common/ ../alib2std/ -LINK_LIBRARIES=alib2elgo alib2algo alib2data alib2common alib2std xml2 -INCLUDE_PATHS=\$$(SOURCES_BASE_DIR)/../../alib2elgo/src/ \$$(SOURCES_BASE_DIR)/../../alib2algo/src/ \$$(SOURCES_BASE_DIR)/../../alib2data/src/ \$$(SOURCES_BASE_DIR)/../../alib2common/src/ \$$(SOURCES_BASE_DIR)/../../alib2std/src/ /usr/include/libxml2/ diff --git a/alphabetManip2/src/alphabetManip.cpp b/alphabetManip2/src/alphabetManip.cpp deleted file mode 100644 index 1a279613dbe6dd6b3016ace79595df6223301974..0000000000000000000000000000000000000000 --- a/alphabetManip2/src/alphabetManip.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * alphabetManip.cpp - * - * Created on: 26. 3. 2014 - * Author: Jan Travnicek - */ - -#include <tclap/CmdLine.h> -#include <global/GlobalData.h> -#include <measure> -#include <vector> -#include <sax/FromXMLParserHelper.h> - -#include <factory/XmlDataFactory.hpp> -#include <exception/CommonException.h> -#include <tree/RankedTreeWrapper.h> -#include <tree/UnrankedTreeWrapper.h> -#include <string/String.h> -#include <container/ObjectsSet.h> - -#include <iostream> - -template < class T > -void process ( T & data, TCLAP::ValueArg < std::string > & operation, std::deque < sax::Token > && argumentTokens ) { - typedef typename std::remove_const < typename std::remove_reference < decltype ( data.getAlphabet ( ) ) >::type >::type alphabetType; - - if ( operation.getValue ( ) == "get" ) { - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - const alphabetType & res = data.getAlphabet ( ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( res ); - } else if ( operation.getValue ( ) == "add" ) { - alphabetType symbols = alib::XmlDataFactory::fromTokens < alphabetType > ( std::move ( argumentTokens ) ); - - measurements::end ( ); - measurements::start ( "Algorithm", measurements::Type::MAIN ); - - data.extendAlphabet ( symbols ); - - measurements::end ( ); - measurements::start ( "Output write", measurements::Type::AUXILIARY ); - - alib::XmlDataFactory::toStdout ( data ); - } else if ( operation.getValue ( ) == "set" ) { - } else if ( operation.getValue ( ) == "remove" ) { - } else { - throw exception::CommonException ( "Invalid operation" ); - } -} - -int main ( int argc, char * argv[] ) { - try { - common::GlobalData::argc = argc; - common::GlobalData::argv = argv; - - TCLAP::CmdLine cmd ( "Alphabet manipulation binary", ' ', "0.01" ); - - std::vector < std::string > allowed; - allowed.push_back ( "get" ); - allowed.push_back ( "set" ); - allowed.push_back ( "add" ); - allowed.push_back ( "remove" ); - TCLAP::ValuesConstraint < std::string > allowedVals ( allowed ); - - TCLAP::ValueArg < std::string > operation ( "o", "operation", "Operation type", false, "", & allowedVals ); - cmd.add ( operation ); - - TCLAP::ValueArg < std::string > input ( "i", "input", "Input from file", false, "-", "file" ); - cmd.add ( input ); - - TCLAP::ValueArg < std::string > argument ( "a", "argument", "Operation argument", false, "", "file" ); - cmd.add ( argument ); - - TCLAP::SwitchArg measure ( "m", "measure", "Measure times", false ); - cmd.add ( measure ); - - TCLAP::SwitchArg verbose ( "v", "verbose", "Be verbose", false ); - cmd.add ( verbose ); - - cmd.parse ( argc, argv ); - - if(verbose.isSet()) - common::GlobalData::verbose = true; - if(measure.isSet()) - common::GlobalData::measure = true; - - measurements::start ( "Overal", measurements::Type::OVERALL ); - measurements::start ( "Input read", measurements::Type::AUXILIARY ); - - std::deque < sax::Token > inputTokens = sax::FromXMLParserHelper::parseInput(input); - - std::deque < sax::Token > argumentTokens; - if ( argument.isSet ( ) ) - argumentTokens = sax::FromXMLParserHelper::parseInput( argument ); - - if ( alib::XmlDataFactory::first < tree::RankedTreeWrapper > ( inputTokens ) ) { - tree::RankedTreeWrapper data = alib::XmlDataFactory::fromTokens < tree::RankedTreeWrapper > ( std::move ( inputTokens ) ); - process ( data, operation, std::move ( argumentTokens ) ); - } else if ( alib::XmlDataFactory::first < tree::UnrankedTreeWrapper > ( inputTokens ) ) { - tree::UnrankedTreeWrapper data = alib::XmlDataFactory::fromTokens < tree::UnrankedTreeWrapper > ( std::move ( inputTokens ) ); - process ( data, operation, std::move ( argumentTokens ) ); - } else if ( alib::XmlDataFactory::first < string::String > ( inputTokens ) ) { - string::String data = alib::XmlDataFactory::fromTokens < string::String > ( std::move ( inputTokens ) ); - process ( data, operation, std::move ( argumentTokens ) ); - } else { - throw exception::CommonException ( "Invalid data type" ); - } - - measurements::end ( ); - measurements::end ( ); - - if ( measure.getValue ( ) ) std::cmeasure << measurements::results ( ) << std::endl; - - return 0; - } catch ( const exception::CommonException & exception ) { - alib::XmlDataFactory::toStdout ( exception ); - return 1; - } catch ( const TCLAP::ArgException & exception ) { - std::cout << exception.error ( ) << std::endl; - return 2; - } catch ( const std::exception & exception ) { - std::cerr << "Exception caught: " << exception.what ( ) << std::endl; - return 3; - } catch ( ... ) { - std::cerr << "Unknown exception caught." << std::endl; - return 127; - } -} diff --git a/makefile b/makefile index 1684b954b167c3148e3e4185dc72acdfa1632341..9012d614c88ab2703737a90ea033b0e0c1ba5fbf 100644 --- a/makefile +++ b/makefile @@ -50,7 +50,6 @@ SUBDIRS_BINS = aecho2 \ astringology2 \ atrim2 \ tniceprint \ - alphabetManip2 \ define NEW_LINE diff --git a/tests.aarbology.sh b/tests.aarbology.sh index 311614b72333c7f5c20fc85c9ddfaeff6a6e2991..2d499f13f49003e5a31fbfc5adbd1cbba195b24e 100755 --- a/tests.aarbology.sh +++ b/tests.aarbology.sh @@ -410,29 +410,29 @@ function runTestNonlinearPatternEnds { clearResults } -runTestPatternEnds "Exact Pattern Matching Automaton (PrefixRanked)" "./aarbology2 -a exactPatternMatchingAutomaton -p <(./acast2 -t PrefixRankedPattern -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <( ./alphabetManip2 -o get -i \"\$SUBJECT_FILE\" ) ) ) | ./adeterminize2 | ./arun2 -t occurrences -a - -i <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" | ./acast2 -t LinearString ) | ./astat2 -p size" +runTestPatternEnds "Exact Pattern Matching Automaton (PrefixRanked)" "./aarbology2 -a exactPatternMatchingAutomaton -p <(./acast2 -t PrefixRankedPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <( ./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\" ) ) ) | ./adeterminize2 | ./arun2 -t occurrences -a - -i <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" | ./acast2 -t LinearString ) | ./astat2 -p size" RAND_SIZE_SUBJECT=120 -runTestPatternEnds "Exact Tree Pattern Automaton (PrefixRanked)" "./aarbology2 -a exactTreePatternAutomaton -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -w <( ./aaccess2 --tree subtree_wildcard -i \"\$PATTERN_FILE\" ) | ./adeterminize2 | ./arun2 -t result -i <(./acast2 -t PrefixRankedPattern -i \"\$PATTERN_FILE\" | ./acast2 -t LinearString ) | ./astat2 -p size" +runTestPatternEnds "Exact Tree Pattern Automaton (PrefixRanked)" "./aarbology2 -a exactTreePatternAutomaton -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -w <( ./aaccess2 --tree subtree_wildcard -o get -i \"\$PATTERN_FILE\" ) | ./adeterminize2 | ./arun2 -t result -i <(./acast2 -t PrefixRankedPattern -i \"\$PATTERN_FILE\" | ./acast2 -t LinearString ) | ./astat2 -p size" RAND_SIZE_SUBJECT=80 -runTestNonlinearPatternEnds "Exact Nonlinear Tree Pattern Automaton (PrefixRanked)" "./aarbology2 -a exactNonlinearTreePatternAutomaton -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -w <( ./aaccess2 --tree subtree_wildcard -i \"\$PATTERN_FILE\" ) -n <( ./aaccess2 --tree nonlinear_variables -i \"\$PATTERN_FILE\" ) | ./adeterminize2 | ./arun2 -t result -i <(./acast2 -t PrefixRankedNonlinearPattern -i \"\$PATTERN_FILE\" | ./acast2 -t LinearString ) -f <(echo '<LabelSetLabel />') | ./aaccess2 --pairSet first | ./astat2 -p size" +runTestNonlinearPatternEnds "Exact Nonlinear Tree Pattern Automaton (PrefixRanked)" "./aarbology2 -a exactNonlinearTreePatternAutomaton -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -w <( ./aaccess2 --tree subtree_wildcard -o get -i \"\$PATTERN_FILE\" ) -n <( ./aaccess2 --tree nonlinear_variables -o get -i \"\$PATTERN_FILE\" ) | ./adeterminize2 | ./arun2 -t result -i <(./acast2 -t PrefixRankedNonlinearPattern -i \"\$PATTERN_FILE\" | ./acast2 -t LinearString ) -f <(echo '<LabelSetLabel />') | ./aaccess2 --pairSet first -o get | ./astat2 -p size" RAND_SIZE_SUBJECT=1000 -runTestSubtree "Exact Boyer Moore Horspool (Subtree PrefixRankedBar)" "./aarbology2 -a boyerMooreHorspool -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarTree -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" +runTestSubtree "Exact Boyer Moore Horspool (Subtree PrefixRankedBar)" "./aarbology2 -a boyerMooreHorspool -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarTree -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" runTestSubtree "Exact Subtree Automaton (Tree)" "./arun2 -t occurrences -a <(./aarbology2 -a exactSubtreeMatchingAutomaton -p \"\$PATTERN_FILE\" | ./adeterminize2) -i \"\$SUBJECT_FILE\" | ./astat2 -p size" -runTestPattern "Exact Boyer Moore Horspool (Pattern PrefixRankedBar)" "./aarbology2 -a boyerMooreHorspool -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarPattern -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" -runTestNonlinearPattern "Exact Pattern Match (NonlinearPattern PrefixRankedBar)" "./aarbology2 -a exactPatternMatch -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarNonlinearPattern -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" -runTestNonlinearPattern "Exact Boyer Moore Horspool (NonlinearPattern PrefixRankedBar)" "./aarbology2 -a boyerMooreHorspool -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarNonlinearPattern -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" -runTestPattern "Exact Reversed Boyer Moore Horspool (Pattern PrefixRankedBar)" "./aarbology2 -a reversedBoyerMooreHorspool -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarPattern -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" -runTestPattern "Exact Reversed Boyer Moore Horspool (Pattern PrefixRanked)" "./aarbology2 -a reversedBoyerMooreHorspool -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedPattern -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" -runTestNonlinearPattern "Exact Reversed Boyer Moore Horspool (NonlinearPattern PrefixRankedBar)" "./aarbology2 -a reversedBoyerMooreHorspool -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarNonlinearPattern -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" -runTestNonlinearPattern "Exact Reversed Boyer Moore Horspool (NonlinearPattern PrefixRanked)" "./aarbology2 -a reversedBoyerMooreHorspool -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedNonlinearPattern -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" +runTestPattern "Exact Boyer Moore Horspool (Pattern PrefixRankedBar)" "./aarbology2 -a boyerMooreHorspool -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" +runTestNonlinearPattern "Exact Pattern Match (NonlinearPattern PrefixRankedBar)" "./aarbology2 -a exactPatternMatch -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarNonlinearPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" +runTestNonlinearPattern "Exact Boyer Moore Horspool (NonlinearPattern PrefixRankedBar)" "./aarbology2 -a boyerMooreHorspool -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarNonlinearPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" +runTestPattern "Exact Reversed Boyer Moore Horspool (Pattern PrefixRankedBar)" "./aarbology2 -a reversedBoyerMooreHorspool -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" +runTestPattern "Exact Reversed Boyer Moore Horspool (Pattern PrefixRanked)" "./aarbology2 -a reversedBoyerMooreHorspool -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" +runTestNonlinearPattern "Exact Reversed Boyer Moore Horspool (NonlinearPattern PrefixRankedBar)" "./aarbology2 -a reversedBoyerMooreHorspool -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarNonlinearPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" +runTestNonlinearPattern "Exact Reversed Boyer Moore Horspool (NonlinearPattern PrefixRanked)" "./aarbology2 -a reversedBoyerMooreHorspool -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedNonlinearPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" runTestPattern "Exact Knuth Morris Pratt (Pattern PrefixRankedBar)" "./aarbology2 -a knuthMorrisPratt -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarPattern -i \"\$PATTERN_FILE\" ) | ./astat2 -p size" runTestPattern "Exact Knuth Morris Pratt (Pattern PrefixRanked)" "./aarbology2 -a knuthMorrisPratt -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedPattern -i \"\$PATTERN_FILE\" ) | ./astat2 -p size" -runTestPattern "Exact Dead Zone Using Bad Character Shift And Border Array (Pattern PrefixRanked)" "./aarbology2 -a deadZoneUsingBadCharacterShiftAndBorderArray -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedPattern -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" -runTestPattern "Exact Dead Zone Using Bad Character Shift And Border Array (Pattern PrefixRankedBar)" "./aarbology2 -a deadZoneUsingBadCharacterShiftAndBorderArray -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarPattern -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" +runTestPattern "Exact Dead Zone Using Bad Character Shift And Border Array (Pattern PrefixRanked)" "./aarbology2 -a deadZoneUsingBadCharacterShiftAndBorderArray -s <( ./acast2 -t PrefixRankedTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" +runTestPattern "Exact Dead Zone Using Bad Character Shift And Border Array (Pattern PrefixRankedBar)" "./aarbology2 -a deadZoneUsingBadCharacterShiftAndBorderArray -s <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" ) -p <( ./acast2 -t PrefixRankedBarPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\"))) | ./astat2 -p size" -runTestPattern "Exact Pattern Matching Automaton (Pattern Tree)" "./arun2 -t occurrences -a <(./aarbology2 -a exactPatternMatchingAutomaton -p <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\")) | ./adeterminize2) -i \"\$SUBJECT_FILE\" | ./astat2 -p size" -runTestPattern "Exact Pattern Matching Automaton (PrefixRankedBar)" "./aarbology2 -a exactPatternMatchingAutomaton -p <(./acast2 -t PrefixRankedBarPattern -i <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <( ./alphabetManip2 -o get -i \"\$SUBJECT_FILE\" ) ) ) | ./adeterminize2 | ./arun2 -t occurrences -a - -i <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" | ./acast2 -t LinearString ) | ./astat2 -p size" +runTestPattern "Exact Pattern Matching Automaton (Pattern Tree)" "./arun2 -t occurrences -a <(./aarbology2 -a exactPatternMatchingAutomaton -p <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\")) | ./adeterminize2) -i \"\$SUBJECT_FILE\" | ./astat2 -p size" +runTestPattern "Exact Pattern Matching Automaton (PrefixRankedBar)" "./aarbology2 -a exactPatternMatchingAutomaton -p <(./acast2 -t PrefixRankedBarPattern -i <(./aaccess2 --tree alphabet -o add -i \"\$PATTERN_FILE\" -a <( ./aaccess2 --tree alphabet -o get -i \"\$SUBJECT_FILE\" ) ) ) | ./adeterminize2 | ./arun2 -t occurrences -a - -i <( ./acast2 -t PrefixRankedBarTree -i \"\$SUBJECT_FILE\" | ./acast2 -t LinearString ) | ./astat2 -p size" diff --git a/tests.astringology.sh b/tests.astringology.sh index eefe7b4c11ee4c95a5e57d4dcd8511eb4e95717e..6a8cd14919516652e95c5c423c71e51f2f7cd776 100755 --- a/tests.astringology.sh +++ b/tests.astringology.sh @@ -212,8 +212,8 @@ function runTest { clearResults } -runTest "Exact Boyer Moore Horspool" "./astringology2 -a boyerMooreHorspool -s \"\$SUBJECT_FILE\" -p <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\")) | ./astat2 -p size" -runTest "Exact Reversed Boyer Moore Horspool" "./astringology2 -a reversedBoyerMooreHorspool -s \"\$SUBJECT_FILE\" -p <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\")) | ./astat2 -p size" -runTest "Exact Matching Automaton" "./arun2 -t occurrences -a <(./astringology2 -a exactMatchingAutomaton -p <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\")) | ./adeterminize2) -i \"\$SUBJECT_FILE\" | ./astat2 -p size" -runTest "Exact Dead Zone Using Bad Character Shift" "./astringology2 -a deadZoneUsingBadCharacterShift -s \"\$SUBJECT_FILE\" -p <(./alphabetManip2 -o add -i \"\$PATTERN_FILE\" -a <(./alphabetManip2 -o get -i \"\$SUBJECT_FILE\")) | ./astat2 -p size" +runTest "Exact Boyer Moore Horspool" "./astringology2 -a boyerMooreHorspool -s \"\$SUBJECT_FILE\" -p <(./aaccess2 --string alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --string alphabet -o get -i \"\$SUBJECT_FILE\")) | ./astat2 -p size" +runTest "Exact Reversed Boyer Moore Horspool" "./astringology2 -a reversedBoyerMooreHorspool -s \"\$SUBJECT_FILE\" -p <(./aaccess2 --string alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --string alphabet -o get -i \"\$SUBJECT_FILE\")) | ./astat2 -p size" +runTest "Exact Matching Automaton" "./arun2 -t occurrences -a <(./astringology2 -a exactMatchingAutomaton -p <(./aaccess2 --string alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --string alphabet -o get -i \"\$SUBJECT_FILE\")) | ./adeterminize2) -i \"\$SUBJECT_FILE\" | ./astat2 -p size" +runTest "Exact Dead Zone Using Bad Character Shift" "./astringology2 -a deadZoneUsingBadCharacterShift -s \"\$SUBJECT_FILE\" -p <(./aaccess2 --string alphabet -o add -i \"\$PATTERN_FILE\" -a <(./aaccess2 --string alphabet -o get -i \"\$SUBJECT_FILE\")) | ./astat2 -p size"