From 0588ca0c82a2d2d724151ffb2227304360d3738d Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Mon, 3 Apr 2017 21:42:32 +0200
Subject: [PATCH] prepare for introduction of normalize method

---
 alib2common/src/base/CommonBase.hpp  |  9 +++++--
 alib2common/src/base/WrapperBase.hpp | 38 ++++++++++++++++------------
 alib2common/src/object/ObjectBase.h  |  8 +++---
 3 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/alib2common/src/base/CommonBase.hpp b/alib2common/src/base/CommonBase.hpp
index a09a624344..d95240caf9 100644
--- a/alib2common/src/base/CommonBase.hpp
+++ b/alib2common/src/base/CommonBase.hpp
@@ -21,8 +21,8 @@ public:
 
 };
 
-template< typename T >
-class CommonBase : public CommonBaseBase {
+template < typename T >
+class CommonBaseMiddle : public CommonBaseBase {
 public:
 	virtual T * clone ( ) const = 0;
 
@@ -62,6 +62,11 @@ public:
 	virtual void operator >>( std::ostream & ) const = 0;
 
 	virtual explicit operator std::string ( ) const = 0;
+
+};
+
+template< typename T >
+class CommonBase : public CommonBaseMiddle < T > {
 };
 
 } /* namespace alib */
diff --git a/alib2common/src/base/WrapperBase.hpp b/alib2common/src/base/WrapperBase.hpp
index 36460ac2b2..126a634f46 100644
--- a/alib2common/src/base/WrapperBase.hpp
+++ b/alib2common/src/base/WrapperBase.hpp
@@ -20,12 +20,12 @@ public:
 };
 
 template < typename T >
-class WrapperBase : public WrapperBaseBase {
+class WrapperBaseMiddle : public WrapperBaseBase {
 protected:
 	std::cow_shared_ptr < T > m_data;
 
 private:
-	void unify ( WrapperBase & other ) {
+	void unify ( WrapperBaseMiddle & other ) {
 		if ( this->m_data.getUseCount ( ) > other.m_data.getUseCount ( ) )
 			other.m_data = this->m_data;
 		else
@@ -33,15 +33,15 @@ private:
 	}
 
 public:
-	WrapperBase ( int ) = delete;
+	WrapperBaseMiddle ( int ) = delete;
 
-	explicit WrapperBase ( T * data ) : m_data ( data ) {
+	explicit WrapperBaseMiddle ( T * data ) : m_data ( data ) {
 	}
 
-	explicit WrapperBase ( const T & data ) : m_data ( data.clone ( ) ) {
+	explicit WrapperBaseMiddle ( const T & data ) : m_data ( data.clone ( ) ) {
 	}
 
-	explicit WrapperBase ( T && data ) : m_data ( std::move ( data ).plunder ( ) ) {
+	explicit WrapperBaseMiddle ( T && data ) : m_data ( std::move ( data ).plunder ( ) ) {
 	}
 
 	const T & getData ( ) const {
@@ -67,41 +67,41 @@ public:
 		setData ( std::move ( data ).plunder ( ) );
 	}
 
-	bool operator >=( const WrapperBase & other ) const {
+	bool operator >=( const WrapperBaseMiddle & other ) const {
 		return this->compare ( other ) >= 0;
 	}
 
-	bool operator <=( const WrapperBase & other ) const {
+	bool operator <=( const WrapperBaseMiddle & other ) const {
 		return this->compare ( other ) <= 0;
 	}
 
-	bool operator >( const WrapperBase & other ) const {
+	bool operator >( const WrapperBaseMiddle & other ) const {
 		return this->compare ( other ) > 0;
 	}
 
-	bool operator <( const WrapperBase & other ) const {
+	bool operator <( const WrapperBaseMiddle & other ) const {
 		return this->compare ( other ) < 0;
 	}
 
-	bool operator !=( const WrapperBase & other ) const {
+	bool operator !=( const WrapperBaseMiddle & other ) const {
 		return this->compare ( other ) != 0;
 	}
 
-	bool operator ==( const WrapperBase & other ) const {
+	bool operator ==( const WrapperBaseMiddle & other ) const {
 		return this->compare ( other ) == 0;
 	}
 
-	int compare ( const WrapperBase & other ) const {
+	int compare ( const WrapperBaseMiddle & other ) const {
 		if ( this->m_data.get ( ) == other.m_data.get ( ) ) return 0;
 
 		int res = ( * this->m_data ).compare ( * other.m_data );
 
-		if ( res == 0 ) const_cast < WrapperBase * > ( this )->unify ( const_cast < WrapperBase & > ( other ) );
+		if ( res == 0 ) const_cast < WrapperBaseMiddle * > ( this )->unify ( const_cast < WrapperBaseMiddle & > ( other ) );
 
 		return res;
 	}
 
-	friend std::ostream & operator <<( std::ostream & os, const WrapperBase & instance ) {
+	friend std::ostream & operator <<( std::ostream & os, const WrapperBaseMiddle & instance ) {
 		os << * ( instance.m_data );
 		return os;
 	}
@@ -110,7 +110,7 @@ public:
 		return ( std::string ) * m_data;
 	}
 
-	WrapperBase < T > & operator ++ ( ) {
+	WrapperBaseMiddle < T > & operator ++ ( ) {
 		T * res = std::move ( this->getData ( ) ).inc ( );
 
 		if ( res != NULL )
@@ -118,6 +118,12 @@ public:
 
 		return *this;
 	}
+};
+
+template < typename T >
+class WrapperBase : public WrapperBaseMiddle < T > {
+public:
+	using WrapperBaseMiddle < T >::WrapperBaseMiddle;
 
 };
 
diff --git a/alib2common/src/object/ObjectBase.h b/alib2common/src/object/ObjectBase.h
index 0c75fc9f52..ca47293812 100644
--- a/alib2common/src/object/ObjectBase.h
+++ b/alib2common/src/object/ObjectBase.h
@@ -20,12 +20,12 @@ namespace alib {
  */
 class ObjectBase : public alib::CommonBase<ObjectBase>, public std::cow_shared_ptr_base {
 public:
-	virtual void compose(std::deque<sax::Token>& out) const = 0;
+	virtual void compose ( std::deque < sax::Token > & out ) const = 0;
 
-	virtual ObjectBase* clone() const = 0;
-	virtual ObjectBase* plunder() && = 0;
+	virtual ObjectBase * clone() const = 0;
+	virtual ObjectBase * plunder() && = 0;
 
-	virtual ObjectBase* inc() && = 0;
+	virtual ObjectBase * inc() && = 0;
 };
 
 } /* namespace alib */
-- 
GitLab