From 9f1023f55aad1dbe4077c50f183e4466dc2592c0 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Sat, 15 Oct 2016 19:45:44 +0200 Subject: [PATCH] step one rethinking visitors --- .../src/regexp/convert/ToAutomatonThompson.h | 2 +- alib2algo/src/regexp/properties/RegExpEmpty.h | 2 +- .../src/regexp/properties/RegExpEpsilon.h | 2 +- .../src/regexp/transform/RegExpDerivation.h | 2 +- .../src/regexp/transform/RegExpIntegral.h | 2 +- .../src/regexp/common/RegExpToXMLComposer.h | 2 +- .../regexp/formal/FormalRegExpAlternation.h | 2 +- .../regexp/formal/FormalRegExpConcatenation.h | 2 +- .../src/regexp/formal/FormalRegExpElement.h | 22 +++++++++---------- .../src/regexp/formal/FormalRegExpEmpty.h | 2 +- .../src/regexp/formal/FormalRegExpEpsilon.h | 2 +- .../src/regexp/formal/FormalRegExpIteration.h | 2 +- .../src/regexp/formal/FormalRegExpSymbol.h | 2 +- .../unbounded/UnboundedRegExpAlternation.h | 2 +- .../unbounded/UnboundedRegExpConcatenation.h | 2 +- .../regexp/unbounded/UnboundedRegExpElement.h | 22 +++++++++---------- .../regexp/unbounded/UnboundedRegExpEmpty.h | 2 +- .../regexp/unbounded/UnboundedRegExpEpsilon.h | 2 +- .../unbounded/UnboundedRegExpIteration.h | 2 +- .../regexp/unbounded/UnboundedRegExpSymbol.h | 2 +- alib2str/src/regexp/RegExpToStringComposer.h | 2 +- 21 files changed, 41 insertions(+), 41 deletions(-) diff --git a/alib2algo/src/regexp/convert/ToAutomatonThompson.h b/alib2algo/src/regexp/convert/ToAutomatonThompson.h index 6e1b4872ce..db03923803 100644 --- a/alib2algo/src/regexp/convert/ToAutomatonThompson.h +++ b/alib2algo/src/regexp/convert/ToAutomatonThompson.h @@ -29,7 +29,7 @@ namespace convert { * http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.7450&rep=rep1&type=ps * Melichar 2.112 */ -class ToAutomatonThompson : public std::SingleDispatch<ToAutomatonThompson, automaton::EpsilonNFA < >, const regexp::RegExpBase &>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { +class ToAutomatonThompson : public std::SingleDispatch<ToAutomatonThompson, automaton::EpsilonNFA < >, const regexp::RegExpBase &>, regexp::FormalRegExpElement::Visitor, regexp::UnboundedRegExpElement::Visitor { public: ToAutomatonThompson() {} diff --git a/alib2algo/src/regexp/properties/RegExpEmpty.h b/alib2algo/src/regexp/properties/RegExpEmpty.h index cc3790c371..3d4a53012c 100644 --- a/alib2algo/src/regexp/properties/RegExpEmpty.h +++ b/alib2algo/src/regexp/properties/RegExpEmpty.h @@ -24,7 +24,7 @@ namespace properties { * Determines whether regular expression is empty (regexp == \0) * */ -class RegExpEmpty : public std::SingleDispatch<RegExpEmpty, bool, const regexp::RegExpBase &>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { +class RegExpEmpty : public std::SingleDispatch<RegExpEmpty, bool, const regexp::RegExpBase &>, regexp::FormalRegExpElement::Visitor, regexp::UnboundedRegExpElement::Visitor { public: RegExpEmpty() {} diff --git a/alib2algo/src/regexp/properties/RegExpEpsilon.h b/alib2algo/src/regexp/properties/RegExpEpsilon.h index 3602a80d52..8485e273f4 100644 --- a/alib2algo/src/regexp/properties/RegExpEpsilon.h +++ b/alib2algo/src/regexp/properties/RegExpEpsilon.h @@ -24,7 +24,7 @@ namespace properties { * Checks, whether regexp (or its subtree) describes epsilon (empty string). * */ -class RegExpEpsilon : public std::SingleDispatch<RegExpEpsilon, bool, const regexp::RegExpBase &>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { +class RegExpEpsilon : public std::SingleDispatch<RegExpEpsilon, bool, const regexp::RegExpBase &>, regexp::FormalRegExpElement::Visitor, regexp::UnboundedRegExpElement::Visitor { public: RegExpEpsilon() {} diff --git a/alib2algo/src/regexp/transform/RegExpDerivation.h b/alib2algo/src/regexp/transform/RegExpDerivation.h index c5697cfdc2..678fa129c1 100644 --- a/alib2algo/src/regexp/transform/RegExpDerivation.h +++ b/alib2algo/src/regexp/transform/RegExpDerivation.h @@ -27,7 +27,7 @@ namespace regexp { * - Melichar, definition 2.91 in chapter 2.4.3 * - Brzozowski, J. A. - Derivatives of regular expressions (1964) */ -class RegExpDerivation : public std::SingleDispatch < RegExpDerivation, regexp::RegExp, const regexp::RegExpBase &, const string::LinearString < >&>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { +class RegExpDerivation : public std::SingleDispatch < RegExpDerivation, regexp::RegExp, const regexp::RegExpBase &, const string::LinearString < >&>, regexp::FormalRegExpElement::Visitor, regexp::UnboundedRegExpElement::Visitor { public: RegExpDerivation() {} diff --git a/alib2algo/src/regexp/transform/RegExpIntegral.h b/alib2algo/src/regexp/transform/RegExpIntegral.h index e2a5c0217d..8b829d9d21 100644 --- a/alib2algo/src/regexp/transform/RegExpIntegral.h +++ b/alib2algo/src/regexp/transform/RegExpIntegral.h @@ -24,7 +24,7 @@ namespace regexp { * Calculates integral of regular expression * Source: Melichar definition 2.93 in chapter 2.4.4 */ -class RegExpIntegral : public std::SingleDispatch < RegExpIntegral, regexp::RegExp, const regexp::RegExpBase &, const string::LinearString < >&>, regexp::FormalRegExpElementVisitor, regexp::UnboundedRegExpElementVisitor { +class RegExpIntegral : public std::SingleDispatch < RegExpIntegral, regexp::RegExp, const regexp::RegExpBase &, const string::LinearString < >&>, regexp::FormalRegExpElement::Visitor, regexp::UnboundedRegExpElement::Visitor { public: RegExpIntegral() {} diff --git a/alib2data/src/regexp/common/RegExpToXMLComposer.h b/alib2data/src/regexp/common/RegExpToXMLComposer.h index f1dc2f030e..522973afc8 100644 --- a/alib2data/src/regexp/common/RegExpToXMLComposer.h +++ b/alib2data/src/regexp/common/RegExpToXMLComposer.h @@ -19,7 +19,7 @@ namespace regexp { /** * This class contains methods to print XML representation of regular expression to the output stream. */ -class RegExpToXMLComposer : public UnboundedRegExpElementVisitor, public FormalRegExpElementVisitor { +class RegExpToXMLComposer : public UnboundedRegExpElement::Visitor, public FormalRegExpElement::Visitor { public: RegExpToXMLComposer() {} diff --git a/alib2data/src/regexp/formal/FormalRegExpAlternation.h b/alib2data/src/regexp/formal/FormalRegExpAlternation.h index bf6852a935..4bc686593f 100644 --- a/alib2data/src/regexp/formal/FormalRegExpAlternation.h +++ b/alib2data/src/regexp/formal/FormalRegExpAlternation.h @@ -19,7 +19,7 @@ namespace regexp { */ class FormalRegExpAlternation : public FormalRegExpElement, public std::BinaryNode < std::smart_ptr < FormalRegExpElement >, std::smart_ptr < const FormalRegExpElement >, FormalRegExpAlternation > { public: - void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const FormalRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2data/src/regexp/formal/FormalRegExpConcatenation.h b/alib2data/src/regexp/formal/FormalRegExpConcatenation.h index ef0e0138f5..d15208d7fe 100644 --- a/alib2data/src/regexp/formal/FormalRegExpConcatenation.h +++ b/alib2data/src/regexp/formal/FormalRegExpConcatenation.h @@ -21,7 +21,7 @@ namespace regexp { */ class FormalRegExpConcatenation : public FormalRegExpElement, public std::BinaryNode < std::smart_ptr < FormalRegExpElement >, std::smart_ptr < const FormalRegExpElement >, FormalRegExpConcatenation > { public: - void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const FormalRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2data/src/regexp/formal/FormalRegExpElement.h b/alib2data/src/regexp/formal/FormalRegExpElement.h index 88ab23594d..bff3f0c3cb 100644 --- a/alib2data/src/regexp/formal/FormalRegExpElement.h +++ b/alib2data/src/regexp/formal/FormalRegExpElement.h @@ -24,22 +24,22 @@ class FormalRegExpEpsilon; class UnboundedRegExpElement; -class FormalRegExpElementVisitor { -public: - virtual void Visit ( void *, const FormalRegExpAlternation & ) const = 0; - virtual void Visit ( void *, const FormalRegExpConcatenation & ) const = 0; - virtual void Visit ( void *, const FormalRegExpIteration & ) const = 0; - virtual void Visit ( void *, const FormalRegExpSymbol & ) const = 0; - virtual void Visit ( void *, const FormalRegExpEmpty & ) const = 0; - virtual void Visit ( void *, const FormalRegExpEpsilon & ) const = 0; -}; - /** * Abstract class representing element in the formal regular expression. Can be operator or symbol. */ class FormalRegExpElement : public alib::CommonBase < FormalRegExpElement >, public std::BaseNode < FormalRegExpElement > { public: - virtual void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const = 0; + class Visitor { + public: + virtual void Visit ( void *, const FormalRegExpAlternation & ) const = 0; + virtual void Visit ( void *, const FormalRegExpConcatenation & ) const = 0; + virtual void Visit ( void *, const FormalRegExpIteration & ) const = 0; + virtual void Visit ( void *, const FormalRegExpSymbol & ) const = 0; + virtual void Visit ( void *, const FormalRegExpEmpty & ) const = 0; + virtual void Visit ( void *, const FormalRegExpEpsilon & ) const = 0; + }; + + virtual void Accept ( void * userData, const FormalRegExpElement::Visitor & visitor ) const = 0; /** * Creates copy of the element. diff --git a/alib2data/src/regexp/formal/FormalRegExpEmpty.h b/alib2data/src/regexp/formal/FormalRegExpEmpty.h index 17d7461f5c..5f41279146 100644 --- a/alib2data/src/regexp/formal/FormalRegExpEmpty.h +++ b/alib2data/src/regexp/formal/FormalRegExpEmpty.h @@ -18,7 +18,7 @@ namespace regexp { */ class FormalRegExpEmpty : public FormalRegExpElement, public std::NullaryNode < std::smart_ptr < FormalRegExpElement >, std::smart_ptr < const FormalRegExpElement >, FormalRegExpSymbol > { public: - void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const FormalRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2data/src/regexp/formal/FormalRegExpEpsilon.h b/alib2data/src/regexp/formal/FormalRegExpEpsilon.h index e758ec00e2..2260db4c3f 100644 --- a/alib2data/src/regexp/formal/FormalRegExpEpsilon.h +++ b/alib2data/src/regexp/formal/FormalRegExpEpsilon.h @@ -18,7 +18,7 @@ namespace regexp { */ class FormalRegExpEpsilon : public FormalRegExpElement, public std::NullaryNode < std::smart_ptr < FormalRegExpElement >, std::smart_ptr < const FormalRegExpElement >, FormalRegExpSymbol > { public: - void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const FormalRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2data/src/regexp/formal/FormalRegExpIteration.h b/alib2data/src/regexp/formal/FormalRegExpIteration.h index e9d74a5a90..c799ec2811 100644 --- a/alib2data/src/regexp/formal/FormalRegExpIteration.h +++ b/alib2data/src/regexp/formal/FormalRegExpIteration.h @@ -19,7 +19,7 @@ namespace regexp { */ class FormalRegExpIteration : public FormalRegExpElement, public std::UnaryNode < std::smart_ptr < FormalRegExpElement >, std::smart_ptr < const FormalRegExpElement >, FormalRegExpIteration > { public: - void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const FormalRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2data/src/regexp/formal/FormalRegExpSymbol.h b/alib2data/src/regexp/formal/FormalRegExpSymbol.h index 04f8a32702..568770a84a 100644 --- a/alib2data/src/regexp/formal/FormalRegExpSymbol.h +++ b/alib2data/src/regexp/formal/FormalRegExpSymbol.h @@ -20,7 +20,7 @@ class FormalRegExpSymbol : public FormalRegExpElement, public std::NullaryNode < alphabet::Symbol symbol; public: - void Accept ( void * userData, const FormalRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const FormalRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h b/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h index 573bc0885f..93e7e17bf6 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpAlternation.h @@ -25,7 +25,7 @@ class RegExpOptimize; */ class UnboundedRegExpAlternation : public UnboundedRegExpElement, public std::VararyNode < std::smart_ptr < UnboundedRegExpElement >, std::smart_ptr < const UnboundedRegExpElement >, UnboundedRegExpAlternation > { public: - void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const UnboundedRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h b/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h index 94a7700513..deef3a8c9b 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpConcatenation.h @@ -25,7 +25,7 @@ class RegExpOptimize; */ class UnboundedRegExpConcatenation : public UnboundedRegExpElement, public std::VararyNode < std::smart_ptr < UnboundedRegExpElement >, std::smart_ptr < const UnboundedRegExpElement >, UnboundedRegExpConcatenation > { public: - void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const UnboundedRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h index d5a521ded0..8ceb0bbe46 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h @@ -24,22 +24,22 @@ class UnboundedRegExpEpsilon; class FormalRegExpElement; -class UnboundedRegExpElementVisitor { -public: - virtual void Visit ( void *, const UnboundedRegExpAlternation & ) const = 0; - virtual void Visit ( void *, const UnboundedRegExpConcatenation & ) const = 0; - virtual void Visit ( void *, const UnboundedRegExpIteration & ) const = 0; - virtual void Visit ( void *, const UnboundedRegExpSymbol & ) const = 0; - virtual void Visit ( void *, const UnboundedRegExpEmpty & ) const = 0; - virtual void Visit ( void *, const UnboundedRegExpEpsilon & ) const = 0; -}; - /** * Abstract class representing element in the regular expression. Can be operator or symbol. */ class UnboundedRegExpElement : public alib::CommonBase < UnboundedRegExpElement >, public std::BaseNode < UnboundedRegExpElement > { public: - virtual void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const = 0; + class Visitor { + public: + virtual void Visit ( void *, const UnboundedRegExpAlternation & ) const = 0; + virtual void Visit ( void *, const UnboundedRegExpConcatenation & ) const = 0; + virtual void Visit ( void *, const UnboundedRegExpIteration & ) const = 0; + virtual void Visit ( void *, const UnboundedRegExpSymbol & ) const = 0; + virtual void Visit ( void *, const UnboundedRegExpEmpty & ) const = 0; + virtual void Visit ( void *, const UnboundedRegExpEpsilon & ) const = 0; + }; + + virtual void Accept ( void * userData, const UnboundedRegExpElement::Visitor & visitor ) const = 0; /** * Creates copy of the element. diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h b/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h index 879d149d95..860c16dfb0 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpEmpty.h @@ -17,7 +17,7 @@ namespace regexp { */ class UnboundedRegExpEmpty : public UnboundedRegExpElement, public std::NullaryNode < std::smart_ptr < UnboundedRegExpElement >, std::smart_ptr < const UnboundedRegExpElement >, UnboundedRegExpSymbol > { public: - void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const UnboundedRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h b/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h index b3937f1619..24c240d7e7 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpEpsilon.h @@ -17,7 +17,7 @@ namespace regexp { */ class UnboundedRegExpEpsilon : public UnboundedRegExpElement, public std::NullaryNode < std::smart_ptr < UnboundedRegExpElement >, std::smart_ptr < const UnboundedRegExpElement >, UnboundedRegExpSymbol > { public: - void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const UnboundedRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h b/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h index 724f0e4363..56ffbdf75a 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpIteration.h @@ -25,7 +25,7 @@ class RegExpOptimize; */ class UnboundedRegExpIteration : public UnboundedRegExpElement, public std::UnaryNode < std::smart_ptr < UnboundedRegExpElement >, std::smart_ptr < const UnboundedRegExpElement >, UnboundedRegExpIteration > { public: - void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const UnboundedRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h b/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h index 288b4a7bf0..013de4c1fe 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpSymbol.h @@ -20,7 +20,7 @@ class UnboundedRegExpSymbol : public UnboundedRegExpElement, public std::Nullary alphabet::Symbol symbol; public: - void Accept ( void * userData, const UnboundedRegExpElementVisitor & visitor ) const { + void Accept ( void * userData, const UnboundedRegExpElement::Visitor & visitor ) const { visitor.Visit ( userData, * this ); } diff --git a/alib2str/src/regexp/RegExpToStringComposer.h b/alib2str/src/regexp/RegExpToStringComposer.h index 5dccab5730..7fa74196a6 100644 --- a/alib2str/src/regexp/RegExpToStringComposer.h +++ b/alib2str/src/regexp/RegExpToStringComposer.h @@ -18,7 +18,7 @@ namespace regexp { -class RegExpToStringComposer : public std::SingleDispatchFirstStaticParam<RegExpToStringComposer, void, std::ostream&, const RegExpBase &>, UnboundedRegExpElementVisitor, FormalRegExpElementVisitor { +class RegExpToStringComposer : public std::SingleDispatchFirstStaticParam<RegExpToStringComposer, void, std::ostream&, const RegExpBase &>, UnboundedRegExpElement::Visitor, FormalRegExpElement::Visitor { private: void Visit(void*, const UnboundedRegExpAlternation& alternation) const; void Visit(void*, const UnboundedRegExpConcatenation& concatenation) const; -- GitLab