From 1c611e201f07cc44094c6b1de770a784129b9105 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Mon, 15 Oct 2018 16:29:58 +0200 Subject: [PATCH] final removal of CommonBase classes --- alib2common/src/base/CommonBase.hpp | 66 ------------------- .../src/regexp/formal/FormalRegExpElement.h | 15 ++++- .../regexp/unbounded/UnboundedRegExpElement.h | 15 ++++- alib2data/src/rte/formal/FormalRTEElement.h | 14 +++- alib2xml/src/core/xmlApi.hpp | 2 +- 5 files changed, 40 insertions(+), 72 deletions(-) delete mode 100644 alib2common/src/base/CommonBase.hpp diff --git a/alib2common/src/base/CommonBase.hpp b/alib2common/src/base/CommonBase.hpp deleted file mode 100644 index 146954e4cd..0000000000 --- a/alib2common/src/base/CommonBase.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * CommonBase.h - * - * Created on: Apr 05, 2014 - * Author: Jan Travnicek - */ - -#ifndef COMMON_BASE_H_ -#define COMMON_BASE_H_ - -#include <alib/typeinfo> -#include <alib/typeindex> -#include <ostream> -#include <stdexcept> - -namespace base { - -/** - * Most common base for every datatype in algorithms library toolkit. - */ -class CommonBaseBase { -public: - /** - * Virtual destructor just to have it. - */ - virtual ~CommonBaseBase ( ) noexcept { } - -}; - -/** - * Middle common base specifies usual operations of all datatypes in algorithms library toolkit. - * - * \tparam T type that inherits from the commmon base. - */ -template < typename T > -class CommonBaseMiddle : public CommonBaseBase, public ext::CompareOperators < T > { -public: - /** - * \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 T & other ) const = 0; -}; - -/** - * The actual common base that is to be used as a base class for concrete type hierarchy object types. - * - * \tparam T type that inherits from the commmon base. - */ -template< typename T > -class CommonBase : public CommonBaseMiddle < T > { -public: - /** - * @copydoc base::CommonBaseMiddle < T > ::compare ( const T & ) const - */ - virtual int compare ( const T & other ) const override = 0; -}; - -} /* namespace base */ - -#endif /* COMMON_BASE_H_ */ diff --git a/alib2data/src/regexp/formal/FormalRegExpElement.h b/alib2data/src/regexp/formal/FormalRegExpElement.h index e4aac660e8..7e9bd68a5d 100644 --- a/alib2data/src/regexp/formal/FormalRegExpElement.h +++ b/alib2data/src/regexp/formal/FormalRegExpElement.h @@ -35,8 +35,8 @@ class FormalRegExpElement; #include <alib/set> #include <alib/tree> +#include <alib/compare> #include <core/visitor.hpp> -#include <base/CommonBase.hpp> #include "../unbounded/UnboundedRegExpElement.h" @@ -61,7 +61,7 @@ class FormalRegExpEpsilon; * \tparam SymbolType used for the terminal alphabet */ template < class SymbolType > -class FormalRegExpElement : public base::CommonBaseMiddle < FormalRegExpElement < SymbolType > >, public ext::BaseNode < FormalRegExpElement < SymbolType > > { +class FormalRegExpElement : public ext::CompareOperators < FormalRegExpElement < SymbolType > >, public ext::BaseNode < FormalRegExpElement < SymbolType > > { protected: /** * Visitor interface of the element. @@ -234,6 +234,17 @@ public: * \returns string representation of the object */ virtual explicit operator std::string ( ) const = 0; + + /** + * \brief Comparison helper method evaluating allowing possibly deeper comparison of this with other class of the same hierarchy. + * + * \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 FormalRegExpElement < SymbolType > & other ) const = 0; }; template < class SymbolType > diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h index 1b35ac1b05..6dcf1ffc9f 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExpElement.h @@ -35,8 +35,8 @@ class UnboundedRegExpElement; #include <alib/set> #include <alib/tree> +#include <alib/compare> #include <core/visitor.hpp> -#include <base/CommonBase.hpp> #include "../formal/FormalRegExpElement.h" @@ -61,7 +61,7 @@ class UnboundedRegExpEpsilon; * \tparam SymbolType used for the terminal alphabet */ template < class SymbolType > -class UnboundedRegExpElement : public base::CommonBaseMiddle < UnboundedRegExpElement < SymbolType > >, public ext::BaseNode < UnboundedRegExpElement < SymbolType > > { +class UnboundedRegExpElement : public ext::CompareOperators < UnboundedRegExpElement < SymbolType > >, public ext::BaseNode < UnboundedRegExpElement < SymbolType > > { protected: /** * Visitor interface of the element. @@ -234,6 +234,17 @@ public: * \returns string representation of the object */ virtual explicit operator std::string ( ) const = 0; + + /** + * \brief Comparison helper method evaluating allowing possibly deeper comparison of this with other class of the same hierarchy. + * + * \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 UnboundedRegExpElement < SymbolType > & other ) const = 0; }; template < class SymbolType > diff --git a/alib2data/src/rte/formal/FormalRTEElement.h b/alib2data/src/rte/formal/FormalRTEElement.h index 8faa3f402f..3821cb0ea8 100644 --- a/alib2data/src/rte/formal/FormalRTEElement.h +++ b/alib2data/src/rte/formal/FormalRTEElement.h @@ -28,6 +28,7 @@ #include <alphabet/xml/RankedSymbol.h> #include <alib/set> #include <alib/tree> +#include <alib/compare> #include <core/visitor.hpp> namespace rte { @@ -54,7 +55,7 @@ class FormalRTEEmpty; * \tparam RankType used for the rank part of the ranked symbol */ template < class SymbolType, class RankType > -class FormalRTEElement : public base::CommonBase < FormalRTEElement < SymbolType, RankType > >, public ext::BaseNode < FormalRTEElement < SymbolType, RankType > > { +class FormalRTEElement : public ext::CompareOperators < FormalRTEElement < SymbolType, RankType > >, public ext::BaseNode < FormalRTEElement < SymbolType, RankType > > { protected: /** * Visitor interface of the element. @@ -222,6 +223,17 @@ public: * \returns string representation of the object */ virtual explicit operator std::string ( ) const = 0; + + /** + * \brief Comparison helper method evaluating allowing possibly deeper comparison of this with other class of the same hierarchy. + * + * \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 FormalRTEElement < SymbolType, RankType > & other ) const = 0; }; template < class SymbolType, class RankType > diff --git a/alib2xml/src/core/xmlApi.hpp b/alib2xml/src/core/xmlApi.hpp index 0f9bfd9be2..31a34e3294 100644 --- a/alib2xml/src/core/xmlApi.hpp +++ b/alib2xml/src/core/xmlApi.hpp @@ -13,10 +13,10 @@ #include <alib/map> #include <alib/string> #include <alib/memory> +#include <alib/typeinfo> #include "sax/Token.h" #include "sax/FromXMLParserHelper.h" -#include "base/CommonBase.hpp" #include "object/Object.h" #include "object/AnyObject.h" -- GitLab