From 0ae354ea6926993a921e799b84f2b81a8d33cd56 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Tue, 16 Oct 2018 12:20:11 +0200
Subject: [PATCH] continue cleanup datastructures

---
 alib2data/src/alphabet/BarSymbol.h            | 13 +----
 alib2data/src/alphabet/BlankSymbol.h          | 13 +----
 .../src/alphabet/BottomOfTheStackSymbol.h     | 13 +----
 alib2data/src/alphabet/EndSymbol.h            | 13 +----
 alib2data/src/alphabet/InitialSymbol.h        | 13 +----
 .../src/alphabet/NonlinearVariableSymbol.h    | 13 +----
 alib2data/src/alphabet/StartSymbol.h          | 13 +----
 alib2data/src/alphabet/SymbolBase.h           | 53 -------------------
 alib2data/src/alphabet/VariablesBarSymbol.h   | 13 +----
 alib2data/src/alphabet/WildcardSymbol.h       | 13 +----
 alib2data/test-src/alphabet/SymbolTest.cpp    | 10 ----
 11 files changed, 18 insertions(+), 162 deletions(-)
 delete mode 100644 alib2data/src/alphabet/SymbolBase.h

diff --git a/alib2data/src/alphabet/BarSymbol.h b/alib2data/src/alphabet/BarSymbol.h
index 4a1e9ce10e..6da7fc0f60 100644
--- a/alib2data/src/alphabet/BarSymbol.h
+++ b/alib2data/src/alphabet/BarSymbol.h
@@ -24,7 +24,7 @@
 #ifndef BAR_SYMBOL_H_
 #define BAR_SYMBOL_H_
 
-#include "SymbolBase.h"
+#include <alib/compare>
 #include <object/Object.h>
 #include <common/ranked_symbol.hpp>
 
@@ -34,7 +34,7 @@ namespace alphabet {
  * \brief
  * Represents bar symbol used in tree linearization.
  */
-class BarSymbol : public SymbolBase {
+class BarSymbol : public ext::CompareOperators < BarSymbol > {
 public:
 	/**
 	 * \brief
@@ -42,15 +42,6 @@ public:
 	 */
 	explicit BarSymbol ( );
 
-	/**
-	 * @copydoc base::CommonBase < SymbolBase >::compare ( const SymbolBase & ) const
-	 */
-	virtual int compare ( const SymbolBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
diff --git a/alib2data/src/alphabet/BlankSymbol.h b/alib2data/src/alphabet/BlankSymbol.h
index 656274e333..6399009ebf 100644
--- a/alib2data/src/alphabet/BlankSymbol.h
+++ b/alib2data/src/alphabet/BlankSymbol.h
@@ -24,7 +24,7 @@
 #ifndef BLANK_SYMBOL_H_
 #define BLANK_SYMBOL_H_
 
-#include "SymbolBase.h"
+#include <alib/compare>
 #include <object/Object.h>
 #include <common/ranked_symbol.hpp>
 
@@ -34,7 +34,7 @@ namespace alphabet {
  * \brief
  * Represents blank symbol used in the turing machine.
  */
-class BlankSymbol : public SymbolBase {
+class BlankSymbol : public ext::CompareOperators < BlankSymbol > {
 public:
 	/**
 	 * \brief
@@ -42,15 +42,6 @@ public:
 	 */
 	explicit BlankSymbol ( );
 
-	/**
-	 * @copydoc base::CommonBase < SymbolBase >::compare ( const SymbolBase & ) const
-	 */
-	virtual int compare ( const SymbolBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
diff --git a/alib2data/src/alphabet/BottomOfTheStackSymbol.h b/alib2data/src/alphabet/BottomOfTheStackSymbol.h
index fa6a13ac5c..21ea81bb97 100644
--- a/alib2data/src/alphabet/BottomOfTheStackSymbol.h
+++ b/alib2data/src/alphabet/BottomOfTheStackSymbol.h
@@ -24,7 +24,7 @@
 #ifndef BOTTOM_OF_THE_STACK_SYMBOL_H_
 #define BOTTOM_OF_THE_STACK_SYMBOL_H_
 
-#include "SymbolBase.h"
+#include <alib/compare>
 #include <object/Object.h>
 #include <common/ranked_symbol.hpp>
 
@@ -34,7 +34,7 @@ namespace alphabet {
  * \brief
  * Represents bottom of the stack symbol used in the visibly pushdown automata.
  */
-class BottomOfTheStackSymbol : public SymbolBase {
+class BottomOfTheStackSymbol : public ext::CompareOperators < BottomOfTheStackSymbol > {
 public:
 	/**
 	 * \brief
@@ -42,15 +42,6 @@ public:
 	 */
 	explicit BottomOfTheStackSymbol ( );
 
-	/**
-	 * @copydoc base::CommonBase < SymbolBase >::compare ( const SymbolBase & ) const
-	 */
-	virtual int compare ( const SymbolBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
diff --git a/alib2data/src/alphabet/EndSymbol.h b/alib2data/src/alphabet/EndSymbol.h
index 464b14d9bf..b0ab079c93 100644
--- a/alib2data/src/alphabet/EndSymbol.h
+++ b/alib2data/src/alphabet/EndSymbol.h
@@ -24,7 +24,7 @@
 #ifndef END_SYMBOL_H_
 #define END_SYMBOL_H_
 
-#include "SymbolBase.h"
+#include <alib/compare>
 #include <object/Object.h>
 #include <common/ranked_symbol.hpp>
 
@@ -34,7 +34,7 @@ namespace alphabet {
  * \brief
  * Represents end symbol used as termation symbol of a string.
  */
-class EndSymbol : public SymbolBase {
+class EndSymbol : public ext::CompareOperators < EndSymbol > {
 public:
 	/**
 	 * \brief
@@ -42,15 +42,6 @@ public:
 	 */
 	explicit EndSymbol ( );
 
-	/**
-	 * @copydoc base::CommonBase < SymbolBase >::compare ( const SymbolBase & ) const
-	 */
-	virtual int compare ( const SymbolBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
diff --git a/alib2data/src/alphabet/InitialSymbol.h b/alib2data/src/alphabet/InitialSymbol.h
index f11f6069fe..7c5c74691d 100644
--- a/alib2data/src/alphabet/InitialSymbol.h
+++ b/alib2data/src/alphabet/InitialSymbol.h
@@ -24,7 +24,7 @@
 #ifndef INITIAL_SYMBOL_LABEL_H_
 #define INITIAL_SYMBOL_LABEL_H_
 
-#include "SymbolBase.h"
+#include <alib/compare>
 #include <object/Object.h>
 #include <common/ranked_symbol.hpp>
 
@@ -34,7 +34,7 @@ namespace alphabet {
  * \brief
  * Represents initial symbol used as an initial symbol of a grammar.
  */
-class InitialSymbol : public SymbolBase {
+class InitialSymbol : public ext::CompareOperators < InitialSymbol > {
 public:
 	/**
 	 * \brief
@@ -42,15 +42,6 @@ public:
 	 */
 	explicit InitialSymbol ( );
 
-	/**
-	 * @copydoc base::CommonBase < SymbolBase >::compare ( const SymbolBase & ) const
-	 */
-	virtual int compare ( const SymbolBase & other ) const override{
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
diff --git a/alib2data/src/alphabet/NonlinearVariableSymbol.h b/alib2data/src/alphabet/NonlinearVariableSymbol.h
index 4522c8965e..1670e71985 100644
--- a/alib2data/src/alphabet/NonlinearVariableSymbol.h
+++ b/alib2data/src/alphabet/NonlinearVariableSymbol.h
@@ -24,7 +24,7 @@
 #ifndef NONLINEAR_VARIABLE_SYMBOL_H_
 #define NONLINEAR_VARIABLE_SYMBOL_H_
 
-#include "SymbolBase.h"
+#include <alib/compare>
 #include <core/normalize.hpp>
 #include <alphabet/common/SymbolNormalize.h>
 
@@ -35,7 +35,7 @@ namespace alphabet {
  * Represents the nonlinear variable symbol used in a nonlinear tree pattern.
  */
 template < class SymbolType = DefaultSymbolType >
-class NonlinearVariableSymbol : public SymbolBase {
+class NonlinearVariableSymbol : public ext::CompareOperators < NonlinearVariableSymbol < SymbolType > > {
 	/**
 	 * \brief the symbol of the nonlinear variable.
 	 */
@@ -62,15 +62,6 @@ public:
 	 */
 	SymbolType && getSymbol ( ) &&;
 
-	/**
-	 * @copydoc base::CommonBase < SymbolBase >::compare ( const SymbolBase & ) const
-	 */
-	virtual int compare ( const SymbolBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
diff --git a/alib2data/src/alphabet/StartSymbol.h b/alib2data/src/alphabet/StartSymbol.h
index fcc0f744a5..0de4fdbd4c 100644
--- a/alib2data/src/alphabet/StartSymbol.h
+++ b/alib2data/src/alphabet/StartSymbol.h
@@ -24,7 +24,7 @@
 #ifndef START_SYMBOL_H_
 #define START_SYMBOL_H_
 
-#include "SymbolBase.h"
+#include <alib/compare>
 #include <object/Object.h>
 #include <common/ranked_symbol.hpp>
 
@@ -34,7 +34,7 @@ namespace alphabet {
  * \brief
  * Represents start symbol used as initializing symbol of a string.
  */
-class StartSymbol : public SymbolBase {
+class StartSymbol : public ext::CompareOperators < StartSymbol > {
 public:
 	/**
 	 * \brief
@@ -42,15 +42,6 @@ public:
 	 */
 	explicit StartSymbol ( );
 
-	/**
-	 * @copydoc base::CommonBase < SymbolBase >::compare ( const SymbolBase & ) const
-	 */
-	virtual int compare ( const SymbolBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
diff --git a/alib2data/src/alphabet/SymbolBase.h b/alib2data/src/alphabet/SymbolBase.h
deleted file mode 100644
index 73531bf7e1..0000000000
--- a/alib2data/src/alphabet/SymbolBase.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SymbolBase.h
- *
- * This file is part of Algorithms library toolkit.
- * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
-
- * Algorithms library toolkit is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * Algorithms library toolkit is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
- *
- *  Created on: Mar 26, 2013
- *      Author: Jan Travnicek
- */
-
-#ifndef SYMBOL_BASE_H_
-#define SYMBOL_BASE_H_
-
-#include <alib/compare>
-
-namespace alphabet {
-
-/**
- * \brief Represents base for a concrete symbol type.
- */
-class SymbolBase : public ext::CompareOperators < SymbolBase > {
-public:
-	virtual ~SymbolBase ( ) noexcept {
-	}
-
-	/**
-	 * \brief Comparison helper method evaluating allowing possibly deeper comparison of this with other class of the same type.
-	 *
-	 * \details If the other class is of different type the relative order is computer by means of type_index.
-	 *
-	 * \param other the other class to compare with
-	 *
-	 * \returns result of actual comparison if type of this class and other class is the same, result of difference of type indexes othervise.
-	 */
-	virtual int compare ( const SymbolBase & other ) const = 0;
-};
-
-} /* namespace alphabet */
-
-#endif /* SYMBOL_BASE_H_ */
diff --git a/alib2data/src/alphabet/VariablesBarSymbol.h b/alib2data/src/alphabet/VariablesBarSymbol.h
index ae68937536..801a829169 100644
--- a/alib2data/src/alphabet/VariablesBarSymbol.h
+++ b/alib2data/src/alphabet/VariablesBarSymbol.h
@@ -24,7 +24,7 @@
 #ifndef VARIABLES_BAR_SYMBOL_H_
 #define VARIABLES_BAR_SYMBOL_H_
 
-#include "SymbolBase.h"
+#include <alib/compare>
 #include <common/ranked_symbol.hpp>
 #include <object/Object.h>
 
@@ -34,7 +34,7 @@ namespace alphabet {
  * \brief
  * Represents variables bar symbol used in tree linearization.
  */
-class VariablesBarSymbol : public SymbolBase {
+class VariablesBarSymbol : public ext::CompareOperators < VariablesBarSymbol > {
 public:
 	/**
 	 * \brief
@@ -42,15 +42,6 @@ public:
 	 */
 	explicit VariablesBarSymbol ( );
 
-	/**
-	 * @copydoc base::CommonBase < SymbolBase >::compare ( const SymbolBase & ) const
-	 */
-	virtual int compare ( const SymbolBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
diff --git a/alib2data/src/alphabet/WildcardSymbol.h b/alib2data/src/alphabet/WildcardSymbol.h
index 37b61c540d..f674b455fd 100644
--- a/alib2data/src/alphabet/WildcardSymbol.h
+++ b/alib2data/src/alphabet/WildcardSymbol.h
@@ -24,7 +24,7 @@
 #ifndef SUBTREE_WILDCARD_SYMBOL_H_
 #define SUBTREE_WILDCARD_SYMBOL_H_
 
-#include "SymbolBase.h"
+#include <alib/compare>
 #include <common/ranked_symbol.hpp>
 #include <object/Object.h>
 
@@ -34,7 +34,7 @@ namespace alphabet {
  * \brief
  * Represents a wildcard used as representation of anything here in a string or a tree.
  */
-class WildcardSymbol : public SymbolBase {
+class WildcardSymbol : public ext::CompareOperators < WildcardSymbol > {
 public:
 	/**
 	 * \brief
@@ -42,15 +42,6 @@ public:
 	 */
 	explicit WildcardSymbol ( );
 
-	/**
-	 * @copydoc base::CommonBase < SymbolBase >::compare ( const SymbolBase & ) const
-	 */
-	virtual int compare ( const SymbolBase & other ) const override {
-		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
-
-		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
-	}
-
 	/**
 	 * The actual compare method
 	 *
diff --git a/alib2data/test-src/alphabet/SymbolTest.cpp b/alib2data/test-src/alphabet/SymbolTest.cpp
index 0ece732e72..13d1e7ead1 100644
--- a/alib2data/test-src/alphabet/SymbolTest.cpp
+++ b/alib2data/test-src/alphabet/SymbolTest.cpp
@@ -23,20 +23,10 @@ void SymbolTest::tearDown ( ) {
 }
 
 void SymbolTest::testOrder ( ) {
-	alphabet::BlankSymbol bs;
-	alphabet::StartSymbol ss;
-	alphabet::EndSymbol es;
-
 	common::ranked_symbol < > rs1 ( DefaultSymbolType ( alphabet::BarSymbol { } ), DefaultRankType ( 0 ) );
 	common::ranked_symbol < > rs2 ( DefaultSymbolType ( alphabet::BarSymbol { } ), DefaultRankType ( 0 ) );
 
-	CPPUNIT_EXCLUSIVE_OR ( bs < ss, ss < bs );
-	CPPUNIT_EXCLUSIVE_OR ( bs < es, es < bs );
-
 	CPPUNIT_ASSERT ( rs1 == rs2 );
-
-	// CPPUNIT_ASSERT(es < ls); //End symbol typically denoted by '$' is lexicographically smaller than any other symbol
-	// CPPUNIT_ASSERT(ls < ss); //Start symbol typically denoted by '^' is lexicographically bigger than any other symbol
 }
 
 namespace alphabet {
-- 
GitLab