Skip to content
Snippets Groups Projects
Commit 1c611e20 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

final removal of CommonBase classes

parent 03ca6bf2
No related branches found
No related tags found
No related merge requests found
Pipeline #19646 passed
/*
* 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_ */
......@@ -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 >
......
......@@ -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 >
......
......@@ -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 >
......
......@@ -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"
 
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment