From 436b40ffb0257cf71a72357c9fd7d4810ea25cfc Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Mon, 7 Apr 2014 17:36:22 +0200
Subject: [PATCH] simplifications of use of visitor

---
 alib2/src/regexp/RegExpToXMLPrinter.cpp | 16 +++++-----------
 alib2/src/regexp/RegExpToXMLPrinter.h   |  7 +++----
 alib2/src/std/visitor.hpp               |  3 ++-
 3 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/alib2/src/regexp/RegExpToXMLPrinter.cpp b/alib2/src/regexp/RegExpToXMLPrinter.cpp
index aaa76d058f..39e33625a0 100644
--- a/alib2/src/regexp/RegExpToXMLPrinter.cpp
+++ b/alib2/src/regexp/RegExpToXMLPrinter.cpp
@@ -15,26 +15,20 @@ RegExpToXMLPrinter::RegExpToXMLPrinter(ostream& out) : m_Out(out) {
 
 }
 
-void RegExpToXMLPrinter::Visit(const std::elementAux<RegExp::visitor_type>& regexp) {
+void RegExpToXMLPrinter::Visit(const RegExp::element_type& regexp) {
 	m_Out << "<regexp>" << endl;
 	regexp.Accept(*this);
 	m_Out << "</regexp>" << endl;
 }
 
-void RegExpToXMLPrinter::Visit(const std::elementAux<RegExpElement::visitor_type>& element) {
+void RegExpToXMLPrinter::Visit(const RegExpElement::element_type& element) {
 	element.Accept(*this);
 }
 
-void RegExpToXMLPrinter::Visit(const list<std::elementAux<RegExpElement::visitor_type>*>& content) {
-	for (auto element : content) {
-		element->Accept(*this);
-	}
-}
-
 void RegExpToXMLPrinter::Visit(const Alternation& alternation) {
 	m_Out << "<alternation>" << endl;
 	for (auto element : alternation.getElements()) {
-		std::elementAux<RegExpElement::visitor_type>& object = static_cast<std::elementAux<RegExpElement::visitor_type>&>(*element);
+		const RegExpElement::element_type& object = static_cast<const RegExpElement::element_type&>(*element);
 		object.Accept(*this);
 	}
 	m_Out << "</alternation>" << endl;
@@ -43,7 +37,7 @@ void RegExpToXMLPrinter::Visit(const Alternation& alternation) {
 void RegExpToXMLPrinter::Visit(const Concatenation& concatenation) {
 	m_Out <<"<concatenation>" << endl;
 	for (auto element : concatenation.getElements()) {
-		std::elementAux<RegExpElement::visitor_type>& object = static_cast<std::elementAux<RegExpElement::visitor_type>&>(*element);
+		const RegExpElement::element_type& object = static_cast<const RegExpElement::element_type&>(*element);
 		object.Accept(*this);
 	}
 	m_Out <<"</concatenation>" << endl;
@@ -52,7 +46,7 @@ void RegExpToXMLPrinter::Visit(const Concatenation& concatenation) {
 
 void RegExpToXMLPrinter::Visit(const Iteration& iteration) {
 	m_Out << "<iteration>" << endl;
-	const std::elementAux<RegExpElement::visitor_type>& object = static_cast<const std::elementAux<RegExpElement::visitor_type>&>(*iteration.getElement());
+	const RegExpElement::element_type& object = static_cast<const RegExpElement::element_type&>(*iteration.getElement());
 	object.Accept(*this);
 	m_Out << "</iteration>" << endl;
 }
diff --git a/alib2/src/regexp/RegExpToXMLPrinter.h b/alib2/src/regexp/RegExpToXMLPrinter.h
index c2e634c3b4..880f455fc8 100644
--- a/alib2/src/regexp/RegExpToXMLPrinter.h
+++ b/alib2/src/regexp/RegExpToXMLPrinter.h
@@ -23,8 +23,6 @@ using namespace std;
 class RegExpToXMLPrinter : public RegExp::visitor_type, public RegExpElement::visitor_type {
 	static const string c_Indentation;
 
-	void Visit(const list<std::elementAux<RegExpElement::visitor_type>*>& content);
-
 	ostream& m_Out;
 
 public:
@@ -44,8 +42,9 @@ public:
 	 * @param regexp RegExp to print
 	 * @param out output stream to which print the RegExp
 	 */
-	void Visit(const std::elementAux<RegExp::visitor_type>& regexp);
-	void Visit(const std::elementAux<RegExpElement::visitor_type>& element);
+	void Visit(const RegExp::element_type& regexp);
+	
+	void Visit(const RegExpElement::element_type& element);
 };
 
 } /* namespace regexp */
diff --git a/alib2/src/std/visitor.hpp b/alib2/src/std/visitor.hpp
index f2764c9843..103b04335a 100644
--- a/alib2/src/std/visitor.hpp
+++ b/alib2/src/std/visitor.hpp
@@ -37,7 +37,8 @@ template<typename VisitorType>
 class elementAux {
 public:
     typedef VisitorType visitor_type;
-    
+    typedef elementAux element_type;
+
     virtual void Accept(VisitorType& visitor) const = 0;
 };
 
-- 
GitLab