From 8acc052ff6c9387af5f395aa251c429220ba0a74 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Wed, 3 Oct 2018 11:51:51 +0200
Subject: [PATCH] remove ObjectsSet class in favour of plain ext::set

---
 alib2aux/src/stats/SizeStat.cpp               |   8 +-
 alib2aux/src/stats/SizeStat.h                 |  15 +-
 alib2common/src/container/ObjectsSet.cpp      |  15 --
 alib2common/src/container/ObjectsSet.h        | 174 ------------------
 .../test-src/container/ContainerTest.cpp      |   5 -
 .../test-src/container/ContainerTest.h        |   2 -
 alib2data/src/PrimitiveRegistrator.cpp        |   1 -
 .../arbology/CompressedBitParallelTreeIndex.h |   1 -
 .../NonlinearCompressedBitParallelTreeIndex.h |   1 -
 .../indexes/stringology/BitParallelIndex.h    |   1 -
 .../stringology/CompressedBitParallelIndex.h  |   1 -
 .../src/indexes/stringology/SuffixTrie.h      |   1 -
 alib2data/src/string/LinearString.cpp         |   2 -
 alib2data/test-src/string/StringTest.cpp      |   3 +-
 alib2str/src/container/string/ObjectsSet.cpp  |   8 +-
 alib2str/src/container/string/ObjectsSet.h    |  24 +--
 alib2str/src/core/stringApi.hpp               |  56 +++++-
 alib2str/src/object/string/AnyObject.cpp      |   2 -
 alib2xml/src/container/xml/ObjectsSet.cpp     |   6 +-
 alib2xml/src/container/xml/ObjectsSet.h       |  30 +--
 alib2xml/src/core/xmlApi.hpp                  |  58 +++++-
 alib2xml/test-src/container/ContainerTest.cpp |   4 +-
 22 files changed, 136 insertions(+), 282 deletions(-)
 delete mode 100644 alib2common/src/container/ObjectsSet.cpp
 delete mode 100644 alib2common/src/container/ObjectsSet.h

diff --git a/alib2aux/src/stats/SizeStat.cpp b/alib2aux/src/stats/SizeStat.cpp
index 64272f3ad1..7b84220a5d 100644
--- a/alib2aux/src/stats/SizeStat.cpp
+++ b/alib2aux/src/stats/SizeStat.cpp
@@ -6,14 +6,12 @@
  */
 
 #include "SizeStat.h"
-
-#include <container/ObjectsSet.h>
-
 #include <registration/AlgoRegistration.hpp>
 
 namespace {
 
-auto SizeStatObjectsSet = registration::AbstractRegister < stats::SizeStat, unsigned, const container::ObjectsSet < > & > ( stats::SizeStat::stat );
-auto SizeStatSetUnsigned = registration::AbstractRegister < stats::SizeStat, unsigned, const std::set < unsigned > & > ( stats::SizeStat::stat );
+auto SizeStatObjectsSet = registration::AbstractRegister < stats::SizeStat, unsigned, const object::AnyObject < ext::set < object::Object > > & > ( stats::SizeStat::stat );
+auto SizeStatSetUnsigned = registration::AbstractRegister < stats::SizeStat, unsigned, const ext::set < unsigned > & > ( stats::SizeStat::stat );
+auto SizeStatObjectsSet2 = registration::AbstractRegister < stats::SizeStat, unsigned, const ext::set < object::Object > & > ( stats::SizeStat::stat );
 
 }
diff --git a/alib2aux/src/stats/SizeStat.h b/alib2aux/src/stats/SizeStat.h
index a914674c67..f7c6b9b74f 100644
--- a/alib2aux/src/stats/SizeStat.h
+++ b/alib2aux/src/stats/SizeStat.h
@@ -8,19 +8,30 @@
 #ifndef _SIZE_STAT_H_
 #define _SIZE_STAT_H_
 
+#include <alib/set>
+#include <object/AnyObject.h>
+
 namespace stats {
 
 class SizeStat {
 public:
 	template < class T >
-	static unsigned stat ( const T & object );
+	static unsigned stat ( const ext::set < T > & object );
+
+	template < class T >
+	static unsigned stat ( const object::AnyObject < ext::set < T > > & object );
 };
 
 template < class T >
-unsigned SizeStat::stat ( const T & object ) {
+unsigned SizeStat::stat ( const ext::set < T > & object ) {
 	return object.size ( );
 }
 
+template < class T >
+unsigned SizeStat::stat ( const object::AnyObject < ext::set < T > > & object ) {
+	return stat ( object.getData ( ) );
+}
+
 }
 
 #endif /* _SIZE_STAT_H_ */
diff --git a/alib2common/src/container/ObjectsSet.cpp b/alib2common/src/container/ObjectsSet.cpp
deleted file mode 100644
index e2b7f57e08..0000000000
--- a/alib2common/src/container/ObjectsSet.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Set.cpp
- *
- * Created on: Apr 1, 2013
- * Author: Jan Travnicek
- */
-
-#include "ObjectsSet.h"
-#include <registration/ValuePrinterRegistration.hpp>
-
-namespace {
-
-static auto valuePrinter = registration::ValuePrinterRegister < container::ObjectsSet < > > ( );
-
-} /* namespace */
diff --git a/alib2common/src/container/ObjectsSet.h b/alib2common/src/container/ObjectsSet.h
deleted file mode 100644
index 0c4fcc2d81..0000000000
--- a/alib2common/src/container/ObjectsSet.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Set.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: Apr 1, 2013
- * Author: Jan Travnicek
- */
-
-#ifndef OBJECTS_SET_H_
-#define OBJECTS_SET_H_
-
-#include <alib/set>
-#include <alib/string>
-#include <sstream>
-
-#include "ContainerBase.h"
-
-#include <object/UniqueObject.h>
-#include <object/ObjectFactory.h>
-
-#include <core/normalize.hpp>
-
-namespace container {
-
-/**
- * \brief
- * Represents an adaptor of a set container from the stl extensions provided by the algorithms library.
- *
- * The set is an associative container.
- *
- * \tparam ElementType the type of values stored in the container.
- */
-template < class ElementType = object::Object >
-class ObjectsSet final : public ext::set < ElementType >, public ContainerBase {
-public:
-	/**
-	 * \brief
-	 * Creates a new instance of the container based on the extended version of the stl set container.
-	 *
-	 * \param raw the extended set contaier
-	 */
-	explicit ObjectsSet ( ext::set < ElementType > raw );
-
-	/**
-	 * \brief
-	 * Creates a new instance of the contaier based on defaultly construted underlying container.
-	 */
-	explicit ObjectsSet ( );
-
-	/**
-	 * @copydoc alphabet::ContainerBase::clone ( ) const &
-	 */
-	virtual ContainerBase * clone ( ) const & override;
-
-	/**
-	 * @copydoc alphabet::ContainerBase::clone ( ) &&
-	 */
-	virtual ContainerBase * clone ( ) && override;
-
-	/**
-	 * @copydoc base::CommonBase < ObjectBase >::compare ( const ObjectBase & ) const
-	 */
-	virtual int compare ( const ObjectBase & 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
-	 *
-	 * \param other the other instance
-	 *
-	 * \returns the actual relation between two by type same containers
-	 */
-	int compare ( const ObjectsSet & other ) const;
-
-	/**
-	 * @copydoc base::CommonBase < ObjectBase >::operator >> ( std::ostream & ) const
-	 */
-	virtual void operator >>( std::ostream & os ) const override;
-
-	/**
-	 * @copydoc base::CommonBase < ObjectBase >::operator std::string ( ) const
-	 */
-	virtual explicit operator std::string ( ) const override;
-
-	/**
-	 * @copydoc object::ObjectBase::inc ( ) &&
-	 */
-	virtual object::ObjectBase * inc ( ) && override;
-};
-
-template < class ElementType >
-ObjectsSet < ElementType >::ObjectsSet(ext::set<ElementType> raw) : ext::set<ElementType>(std::move(raw)) {
-
-}
-
-template < class ElementType >
-ObjectsSet < ElementType >::ObjectsSet() : ext::set<ElementType>() {
-
-}
-
-template < class ElementType >
-ContainerBase* ObjectsSet < ElementType >::clone ( ) const & {
-	return new ObjectsSet(*this);
-}
-
-template < class ElementType >
-ContainerBase* ObjectsSet < ElementType >::clone() && {
-	return new ObjectsSet(std::move(*this));
-}
-
-template < class ElementType >
-int ObjectsSet < ElementType >::compare(const ObjectsSet& other) const {
-	static ext::compare<ext::set<ElementType>> comp;
-	return comp ( static_cast < const ext::set < ElementType > & > ( * this ), static_cast < const ext::set < ElementType > & > ( other ) );
-}
-
-template < class ElementType >
-void ObjectsSet < ElementType >::operator>>(std::ostream& os) const {
-	os << "(ObjectsSet " << static_cast < const ext::set < ElementType > & > ( * this ) << ")";
-}
-
-template < class ElementType >
-ObjectsSet < ElementType >::operator std::string() const {
-	std::stringstream ss;
-	ss << *this;
-	return std::move(ss).str();
-}
-
-template < class ElementType >
-object::ObjectBase* ObjectsSet < ElementType >::inc() && {
-	return new object::UniqueObject(object::Object(std::move(*this)), primitive::Integer(0));
-}
-
-} /* namespace container */
-
-namespace core {
-
-template < class ElementType >
-struct normalize < container::ObjectsSet < ElementType > > {
-	static ext::set < object::Object > raw ( ext::set < ElementType > && source ) {
-		ext::set < object::Object > res;
-
-		for ( ElementType && element : ext::make_mover ( source ) )
-			res.insert ( object::ObjectFactory::make ( std::move ( element ) ) );
-
-		return res;
-	}
-
-	static container::ObjectsSet < > eval ( container::ObjectsSet < ElementType > && value ) {
-		return container::ObjectsSet < > ( raw ( std::move ( value ) ) );
-	}
-};
-
-} /* namespace core */
-
-#endif /* OBJECTS_SET_H_ */
diff --git a/alib2common/test-src/container/ContainerTest.cpp b/alib2common/test-src/container/ContainerTest.cpp
index 2ffbb9d595..5a9a10439b 100644
--- a/alib2common/test-src/container/ContainerTest.cpp
+++ b/alib2common/test-src/container/ContainerTest.cpp
@@ -1,7 +1,6 @@
 #include "ContainerTest.h"
 
 #include "object/Object.h"
-#include "container/ObjectsSet.h"
 #include "container/ObjectsDeque.h"
 #include "container/ObjectsVector.h"
 #include "container/ObjectsMap.h"
@@ -19,10 +18,6 @@ void ContainerTest::setUp ( ) {
 void ContainerTest::tearDown ( ) {
 }
 
-void ContainerTest::testProperties ( ) {
-	CPPUNIT_ASSERT ( std::is_nothrow_move_constructible < container::ObjectsSet < object::Object > >::value );
-}
-
 void ContainerTest::testNormalize ( ) {
 	ext::deque < int > dint;
 	ext::deque < object::Object > dnor = core::normalize < container::ObjectsDeque < int > >::raw ( std::move ( dint ) );
diff --git a/alib2common/test-src/container/ContainerTest.h b/alib2common/test-src/container/ContainerTest.h
index 0a83808293..a8ce770b03 100644
--- a/alib2common/test-src/container/ContainerTest.h
+++ b/alib2common/test-src/container/ContainerTest.h
@@ -5,7 +5,6 @@
 
 class ContainerTest : public CppUnit::TestFixture {
 	CPPUNIT_TEST_SUITE ( ContainerTest );
-	CPPUNIT_TEST ( testProperties );
 	CPPUNIT_TEST ( testNormalize );
 	CPPUNIT_TEST_SUITE_END ( );
 
@@ -13,7 +12,6 @@ public:
 	void setUp ( );
 	void tearDown ( );
 
-	void testProperties ( );
 	void testNormalize ( );
 };
 
diff --git a/alib2data/src/PrimitiveRegistrator.cpp b/alib2data/src/PrimitiveRegistrator.cpp
index 25b0232c34..a4b5883167 100644
--- a/alib2data/src/PrimitiveRegistrator.cpp
+++ b/alib2data/src/PrimitiveRegistrator.cpp
@@ -74,7 +74,6 @@ public:
 		core::xmlApi < object::Object >::template registerXmlWriter < object::AnyObject < ext::pair < object::Object, ext::variant < string::Epsilon < object::Object >, object::Object > > > > ( );
 		core::xmlApi < object::Object >::template registerXmlWriter < object::AnyObject < ext::vector < object::Object > > > ( );
 		core::xmlApi < object::Object >::template registerXmlWriter < object::AnyObject < ext::vector < ext::variant < object::Object, object::Object > > > > ( );
-		core::xmlApi < object::Object >::template registerXmlWriter < object::AnyObject < ext::set < object::Object > > > ( );
 		core::xmlApi < object::Object >::template registerXmlWriter < object::AnyObject < unsigned int > > ( );
 		core::xmlApi < object::Object >::template registerXmlWriter < object::AnyObject < common::ranked_symbol < object::Object, primitive::Unsigned > > > ( );
 		core::xmlApi < object::Object >::template registerXmlWriter < object::AnyObject < ext::pair < unsigned int, unsigned int > > > ( );
diff --git a/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h b/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h
index efc5f16788..87f2d14b07 100644
--- a/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h
+++ b/alib2data/src/indexes/arbology/CompressedBitParallelTreeIndex.h
@@ -38,7 +38,6 @@
 #include <object/UniqueObject.h>
 #include <object/ObjectBase.h>
 
-#include <container/ObjectsSet.h>
 #include <container/ObjectsMap.h>
 #include <container/ObjectsVector.h>
 #include <common/SparseBoolVector.hpp>
diff --git a/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h b/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h
index 01c4cb7d60..d328b07a3e 100644
--- a/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h
+++ b/alib2data/src/indexes/arbology/NonlinearCompressedBitParallelTreeIndex.h
@@ -37,7 +37,6 @@
 #include <object/UniqueObject.h>
 #include <object/ObjectBase.h>
 
-#include <container/ObjectsSet.h>
 #include <container/ObjectsMap.h>
 #include <container/ObjectsVector.h>
 #include <common/SparseBoolVector.hpp>
diff --git a/alib2data/src/indexes/stringology/BitParallelIndex.h b/alib2data/src/indexes/stringology/BitParallelIndex.h
index b88f73f368..38eb4d4a91 100644
--- a/alib2data/src/indexes/stringology/BitParallelIndex.h
+++ b/alib2data/src/indexes/stringology/BitParallelIndex.h
@@ -37,7 +37,6 @@
 #include <object/UniqueObject.h>
 #include <object/ObjectBase.h>
 
-#include <container/ObjectsSet.h>
 #include <container/ObjectsMap.h>
 #include <container/ObjectsVector.h>
 
diff --git a/alib2data/src/indexes/stringology/CompressedBitParallelIndex.h b/alib2data/src/indexes/stringology/CompressedBitParallelIndex.h
index abec9616c2..d446c97e0f 100644
--- a/alib2data/src/indexes/stringology/CompressedBitParallelIndex.h
+++ b/alib2data/src/indexes/stringology/CompressedBitParallelIndex.h
@@ -37,7 +37,6 @@
 #include <object/UniqueObject.h>
 #include <object/ObjectBase.h>
 
-#include <container/ObjectsSet.h>
 #include <container/ObjectsMap.h>
 
 #include <common/SparseBoolVector.hpp>
diff --git a/alib2data/src/indexes/stringology/SuffixTrie.h b/alib2data/src/indexes/stringology/SuffixTrie.h
index 9c7de1c29c..e94fd4e282 100644
--- a/alib2data/src/indexes/stringology/SuffixTrie.h
+++ b/alib2data/src/indexes/stringology/SuffixTrie.h
@@ -41,7 +41,6 @@
 #include <object/UniqueObject.h>
 #include <object/ObjectBase.h>
 
-#include <container/ObjectsSet.h>
 #include <container/ObjectsTrie.h>
 
 #include <object/Void.h>
diff --git a/alib2data/src/string/LinearString.cpp b/alib2data/src/string/LinearString.cpp
index 86f1ecdd86..c164f62c62 100644
--- a/alib2data/src/string/LinearString.cpp
+++ b/alib2data/src/string/LinearString.cpp
@@ -12,8 +12,6 @@
 #include <registration/SetRegistration.hpp>
 #include <registration/ComponentRegistration.hpp>
 
-#include <container/ObjectsSet.h>
-
 namespace {
 
 static auto components = registration::ComponentRegister < string::LinearString < > > ( );
diff --git a/alib2data/test-src/string/StringTest.cpp b/alib2data/test-src/string/StringTest.cpp
index 8824ad930b..7a5e31eaf9 100644
--- a/alib2data/test-src/string/StringTest.cpp
+++ b/alib2data/test-src/string/StringTest.cpp
@@ -19,7 +19,6 @@
 
 #include <primitive/Character.h>
 #include <primitive/xml/Character.h>
-#include <container/ObjectsSet.h>
 #include <container/xml/ObjectsSet.h>
 
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( StringTest, "string" );
@@ -145,7 +144,7 @@ void StringTest::testNormalize3 ( ) {
 
 	CPPUNIT_ASSERT ( s1x == s2x );
 
-	string::LinearString < object::Object > ref ( ext::vector < object::Object > { object::Object ( container::ObjectsSet < object::Object > ( ext::set < object::Object > { object::Object ( primitive::Character ( 'a' ) ) } ) ), object::Object ( container::ObjectsSet < object::Object > ( ext::set < object::Object > { object::Object ( primitive::Character ( 'b' ) ) } ) ) } );
+	string::LinearString < object::Object > ref ( ext::vector < object::Object > { object::Object ( object::AnyObject < ext::set < object::Object > > ( ext::set < object::Object > { object::Object ( primitive::Character ( 'a' ) ) } ) ), object::Object ( object::AnyObject < ext::set < object::Object > > ( ext::set < object::Object > { object::Object ( primitive::Character ( 'b' ) ) } ) ) } );
 
 	std::cout << s1x << std::endl;
 	std::cout << ref << std::endl;
diff --git a/alib2str/src/container/string/ObjectsSet.cpp b/alib2str/src/container/string/ObjectsSet.cpp
index 8b95f24165..bbb2124ca5 100644
--- a/alib2str/src/container/string/ObjectsSet.cpp
+++ b/alib2str/src/container/string/ObjectsSet.cpp
@@ -12,10 +12,10 @@
 
 namespace {
 
-static auto stringWrite = registration::StringWriterRegister < container::ObjectsSet < > > ( );
-static auto stringReaded = registration::StringReaderRegister < object::Object, container::ObjectsSet < > > ( );
+static auto stringWrite = registration::StringWriterRegister < ext::set < object::Object > > ( );
+static auto stringReaded = registration::StringReaderRegister < object::Object, ext::set < object::Object > > ( );
 
-static auto stringWriteGroup = registration::StringWriterRegisterTypeInGroup < object::Object, container::ObjectsSet < > > ( );
-static auto stringReadedGroup = registration::StringReaderRegisterTypeInGroup < object::Object, container::ObjectsSet < > > ( );
+static auto stringWriteGroup = registration::StringWriterRegisterTypeInGroup < object::Object, ext::set < object::Object > > ( );
+static auto stringReadedGroup = registration::StringReaderRegisterTypeInGroup < object::Object, ext::set < object::Object > > ( );
 
 } /* namespace */
diff --git a/alib2str/src/container/string/ObjectsSet.h b/alib2str/src/container/string/ObjectsSet.h
index a5b370e4f9..2882ab0d29 100644
--- a/alib2str/src/container/string/ObjectsSet.h
+++ b/alib2str/src/container/string/ObjectsSet.h
@@ -8,7 +8,7 @@
 #ifndef _STRING_OBJECTS_SET_H_
 #define _STRING_OBJECTS_SET_H_
 
-#include <container/ObjectsSet.h>
+#include <alib/set>
 #include <core/stringApi.hpp>
 
 #include <container/ContainerFromStringLexer.h>
@@ -70,28 +70,6 @@ void stringApi < ext::set < ValueType > >::compose ( std::ostream & output, cons
 	output << '}';
 }
 
-template<class ValueType >
-struct stringApi < container::ObjectsSet < ValueType > > {
-	static container::ObjectsSet < ValueType > parse ( std::istream & input );
-	static bool first ( std::istream & input );
-	static void compose ( std::ostream & output, const container::ObjectsSet < ValueType > & container );
-};
-
-template<class ValueType >
-container::ObjectsSet < ValueType > stringApi < container::ObjectsSet < ValueType > >::parse ( std::istream & input ) {
-	return container::ObjectsSet < ValueType > ( stringApi < ext::set < ValueType > >::parse ( input ) );
-}
-
-template<class ValueType >
-bool stringApi < container::ObjectsSet < ValueType > >::first ( std::istream & input ) {
-	return stringApi < ext::set < ValueType > >::first ( input );
-}
-
-template<class ValueType >
-void stringApi < container::ObjectsSet < ValueType > >::compose ( std::ostream & output, const container::ObjectsSet < ValueType > & container ) {
-	stringApi < ext::set < ValueType > >::compose ( output, container );
-}
-
 } /* namespace core */
 
 #endif /* _STRING_OBJECTS_SET_H_ */
diff --git a/alib2str/src/core/stringApi.hpp b/alib2str/src/core/stringApi.hpp
index fe06be7e69..45bf8e733e 100644
--- a/alib2str/src/core/stringApi.hpp
+++ b/alib2str/src/core/stringApi.hpp
@@ -16,6 +16,7 @@
 #include <alib/algorithm>
 
 #include <object/Object.h>
+#include <object/AnyObject.h>
 
 #include "exception/CommonException.h"
 
@@ -40,8 +41,11 @@ private:
 		return res;
 	}
 
+	template < class Type, typename Enable = void >
+	class ReaderRegister;
+
 	template < class Type >
-	class ReaderRegister : public GroupReader {
+	class ReaderRegister < Type, typename std::enable_if < std::is_base_of < base::CommonBaseBase, Type >::value >::type > : public GroupReader {
 		std::function < Type ( std::istream & ) > parseFunction;
 
 	public:
@@ -56,6 +60,22 @@ private:
 		}
 	};
 
+	template < class Type >
+	class ReaderRegister < Type, typename std::enable_if < ! std::is_base_of < base::CommonBaseBase, Type >::value >::type > : public GroupReader {
+		std::function < Type ( std::istream & ) > parseFunction;
+
+	public:
+		ReaderRegister( ) : parseFunction ( stringApi < Type >::parse ) {
+		}
+
+		virtual ~ReaderRegister ( ) {
+		}
+
+		virtual object::Object parse ( std::istream & input ) {
+			return object::Object ( object::AnyObject < Type > ( parseFunction ( input ) ) );
+		}
+	};
+
 	class GroupWriter {
 	public:
 		virtual void compose ( std::ostream & output, const object::Object & group ) = 0;
@@ -70,8 +90,11 @@ private:
 		return res;
 	}
 
+	template < class Type, typename Enable = void >
+	class WriterRegister;
+
 	template < class Type >
-	class WriterRegister : public GroupWriter {
+	class WriterRegister < Type, typename std::enable_if < std::is_base_of < base::CommonBaseBase, Type >::value >::type > : public GroupWriter {
 		std::function < void ( std::ostream &, const Type & ) > composeFunction;
 
 	public:
@@ -86,13 +109,29 @@ private:
 		}
 	};
 
+	template < class Type >
+	class WriterRegister < Type, typename std::enable_if < ! std::is_base_of < base::CommonBaseBase, Type >::value >::type > : public GroupWriter {
+		std::function < void ( std::ostream &, const Type & ) > composeFunction;
+
+	public:
+		WriterRegister( ) : composeFunction ( stringApi < Type >::compose ) {
+		}
+
+		virtual ~WriterRegister ( ) {
+		}
+
+		virtual void compose ( std::ostream & output, const object::Object & group ) {
+			composeFunction ( output, static_cast < const object::AnyObject < Type > & > ( group.getData ( ) ).getData ( ) );
+		}
+	};
+
 public:
 	template < class Type >
 	static void registerStringReader ( ) {
 		parseFunctions ( ).push_back ( std::make_pair ( stringApi < Type >::first, std::unique_ptr < GroupReader > ( new ReaderRegister < Type > ( ) ) ) );
 	}
 
-	template < class Type >
+	template < class Type, typename std::enable_if < std::is_base_of < base::CommonBaseBase, Type >::value >::type * = nullptr >
 	static void registerStringWriter ( ) {
 		bool res = composeFunctions ( ).insert ( std::make_pair ( ext::to_string < Type > ( ), std::unique_ptr < GroupWriter > ( new WriterRegister < Type > ( ) ) ) ).second;
 		if ( ! res ) {
@@ -103,6 +142,17 @@ public:
 		}
 	}
 
+	template < class Type, typename std::enable_if < ! std::is_base_of < base::CommonBaseBase, Type >::value >::type * = nullptr >
+	static void registerStringWriter ( ) {
+		bool res = composeFunctions ( ).insert ( std::make_pair ( ext::to_string < object::AnyObject < Type > > ( ), std::unique_ptr < GroupWriter > ( new WriterRegister < Type > ( ) ) ) ).second;
+		if ( ! res ) {
+			std::string groupName = ext::to_string < object::Object > ( );
+			std::string typeName = ext::to_string < Type > ( );
+
+			throw::exception::CommonException ( "Parse callback of " + typeName + " already registered in group " + groupName + "." );
+		}
+	}
+
 	static object::Object parse ( std::istream & input ) {
 		auto lambda = [ & ] ( const std::pair < std::function < bool ( std::istream & ) >, std::unique_ptr < GroupReader > > & entry ) {
 
diff --git a/alib2str/src/object/string/AnyObject.cpp b/alib2str/src/object/string/AnyObject.cpp
index 7d62f1971b..6716f58e79 100644
--- a/alib2str/src/object/string/AnyObject.cpp
+++ b/alib2str/src/object/string/AnyObject.cpp
@@ -9,7 +9,6 @@
 #include <object/Object.h>
 #include <primitive/string/Unsigned.h>
 #include <container/string/ObjectsPair.h>
-#include <container/string/ObjectsSet.h>
 #include <container/string/ObjectsVector.h>
 
 #include <registration/StringRegistration.hpp>
@@ -17,7 +16,6 @@
 namespace {
 
 static auto stringWriteGroup0 = registration::StringWriterRegisterTypeInGroup < object::Object, object::AnyObject < ext::vector < object::Object > > > ( );
-static auto stringWriteGroup1 = registration::StringWriterRegisterTypeInGroup < object::Object, object::AnyObject < ext::set < object::Object > > > ( );
 static auto stringWriteGroup2 = registration::StringWriterRegisterTypeInGroup < object::Object, object::AnyObject < ext::pair < object::Object, object::Object > > > ( );
 static auto stringWriteGroup3 = registration::StringWriterRegisterTypeInGroup < object::Object, object::AnyObject < unsigned > > ( );
 static auto stringWriteGroup4 = registration::StringWriterRegisterTypeInGroup < object::Object, object::AnyObject < ext::pair < unsigned, unsigned > > > ( );
diff --git a/alib2xml/src/container/xml/ObjectsSet.cpp b/alib2xml/src/container/xml/ObjectsSet.cpp
index 9ecd0e4dab..32d045ca1f 100644
--- a/alib2xml/src/container/xml/ObjectsSet.cpp
+++ b/alib2xml/src/container/xml/ObjectsSet.cpp
@@ -11,9 +11,9 @@
 
 namespace {
 
-static auto xmlWrite = registration::XmlWriterRegister < container::ObjectsSet < > > ( );
-static auto xmlRead = registration::XmlReaderRegister < container::ObjectsSet < > > ( );
+static auto xmlWrite = registration::XmlWriterRegister < ext::set < object::Object > > ( );
+static auto xmlRead = registration::XmlReaderRegister < ext::set < object::Object > > ( );
 
-static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, container::ObjectsSet < > > ( );
+static auto xmlGroup = registration::XmlRegisterTypeInGroup < object::Object, ext::set < object::Object > > ( );
 
 } /* namespace */
diff --git a/alib2xml/src/container/xml/ObjectsSet.h b/alib2xml/src/container/xml/ObjectsSet.h
index 8a0475ad49..f9c1db173f 100644
--- a/alib2xml/src/container/xml/ObjectsSet.h
+++ b/alib2xml/src/container/xml/ObjectsSet.h
@@ -8,7 +8,7 @@
 #ifndef _XML_OBJECTS_SET_H_
 #define _XML_OBJECTS_SET_H_
 
-#include <container/ObjectsSet.h>
+#include <alib/set>
 #include <core/xmlApi.hpp>
 
 namespace core {
@@ -56,34 +56,6 @@ void xmlApi < ext::set < T > >::compose ( ext::deque < sax::Token > & output, co
 	output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::END_ELEMENT );
 }
 
-template < typename T >
-struct xmlApi < container::ObjectsSet < T > > {
-	static container::ObjectsSet < T > parse ( ext::deque < sax::Token >::iterator & input );
-	static bool first ( const ext::deque < sax::Token >::const_iterator & input );
-	static const std::string & xmlTagName ( );
-	static void compose ( ext::deque < sax::Token > & output, const container::ObjectsSet < T > & data );
-};
-
-template < typename T >
-container::ObjectsSet < T > xmlApi < container::ObjectsSet < T > >::parse ( ext::deque < sax::Token >::iterator & input ) {
-	return container::ObjectsSet < T > ( xmlApi < ext::set < T > >::parse ( input ) );
-}
-
-template < typename T >
-bool xmlApi < container::ObjectsSet < T > >::first ( const ext::deque < sax::Token >::const_iterator & input ) {
-	return xmlApi < ext::set < T > >::first ( input );
-}
-
-template < typename T >
-const std::string & xmlApi < container::ObjectsSet < T > >::xmlTagName ( ) {
-	return xmlApi < ext::set < T > >::xmlTagName ( );
-}
-
-template < typename T >
-void xmlApi < container::ObjectsSet < T > >::compose ( ext::deque < sax::Token > & output, const container::ObjectsSet < T > & input ) {
-	xmlApi < ext::set < T > >::compose ( output, input );
-}
-
 } /* namespace core */
 
 #endif /* _XML_OBJECTS_SET_H_ */
diff --git a/alib2xml/src/core/xmlApi.hpp b/alib2xml/src/core/xmlApi.hpp
index 6959f95087..568fc65a6e 100644
--- a/alib2xml/src/core/xmlApi.hpp
+++ b/alib2xml/src/core/xmlApi.hpp
@@ -18,6 +18,7 @@
 
 #include "base/CommonBase.hpp"
 #include "object/Object.h"
+#include "object/AnyObject.h"
 
 #include <global/GlobalData.h>
 
@@ -76,8 +77,11 @@ private:
 		return res;
 	}
 
+	template < class Type, typename Enable = void >
+	class ParserRegister;
+
 	template < class Type >
-	class ParserRegister : public GroupParser {
+	class ParserRegister < Type, typename std::enable_if < std::is_base_of < base::CommonBaseBase, Type >::value >::type > : public GroupParser {
 		std::function < Type ( ext::deque < sax::Token >::iterator & ) > parseFunction;
 
 	public:
@@ -93,6 +97,23 @@ private:
 
 	};
 
+	template < class Type >
+	class ParserRegister < Type, typename std::enable_if < ! std::is_base_of < base::CommonBaseBase, Type >::value >::type > : public GroupParser {
+		std::function < Type ( ext::deque < sax::Token >::iterator & ) > parseFunction;
+
+	public:
+		ParserRegister( ) : parseFunction ( xmlApi < Type >::parse ) {
+		}
+
+		virtual ~ParserRegister( ) {
+		}
+
+		virtual object::Object parse ( ext::deque < sax::Token >::iterator & input ) {
+			return object::Object ( object::AnyObject < Type > ( parseFunction ( input ) ) );
+		}
+
+	};
+
 	class GroupComposer {
 	public:
 		virtual void compose ( ext::deque < sax::Token > & input, const object::Object & group ) = 0;
@@ -107,8 +128,11 @@ private:
 		return res;
 	}
 
+	template < class Type, typename Enable = void >
+	class ComposerRegister;
+
 	template < class Type >
-	class ComposerRegister : public GroupComposer {
+	class ComposerRegister < Type, typename std::enable_if < std::is_base_of < base::CommonBaseBase, Type >::value >::type > : public GroupComposer {
 		std::function < void ( ext::deque < sax::Token > &, const Type & ) > composeFunction;
 
 	public:
@@ -124,6 +148,23 @@ private:
 
 	};
 
+	template < class Type >
+	class ComposerRegister < Type, typename std::enable_if < ! std::is_base_of < base::CommonBaseBase, Type >::value >::type > : public GroupComposer {
+		std::function < void ( ext::deque < sax::Token > &, const Type & ) > composeFunction;
+
+	public:
+		ComposerRegister( ) : composeFunction ( xmlApi < Type >::compose ) {
+		}
+
+		virtual ~ComposerRegister ( ) {
+		}
+
+		virtual void compose ( ext::deque < sax::Token > & input, const object::Object & group ) {
+			composeFunction ( input, static_cast < const object::AnyObject < Type > & > ( group.getData ( ) ).getData ( ) );
+		}
+
+	};
+
 public:
 	template < class Type >
 	static void registerXmlReader ( ) {
@@ -136,7 +177,7 @@ public:
 		}
 	}
 
-	template < class Type >
+	template < class Type, typename std::enable_if < std::is_base_of < base::CommonBaseBase, Type >::value >::type * = nullptr >
 	static void registerXmlWriter ( ) {
 		bool res = composeFunctions ( ).insert ( std::make_pair ( ext::to_string < Type > ( ), std::unique_ptr < GroupComposer > ( new ComposerRegister < Type > ( ) ) ) ).second;
 		if ( ! res ) {
@@ -147,6 +188,17 @@ public:
 		}
 	}
 
+	template < class Type, typename std::enable_if < ! std::is_base_of < base::CommonBaseBase, Type >::value >::type * = nullptr >
+	static void registerXmlWriter ( ) {
+		bool res = composeFunctions ( ).insert ( std::make_pair ( ext::to_string < object::AnyObject < Type > > ( ), std::unique_ptr < GroupComposer > ( new ComposerRegister < Type > ( ) ) ) ).second;
+		if ( ! res ) {
+			std::string groupName = ext::to_string < object::Object > ( );
+			std::string typeName = ext::to_string < Type > ( );
+
+			throw::exception::CommonException ( "Parse callback of " + typeName + " already registered in group " + groupName + "." );
+		}
+	}
+
 	static object::Object parse ( ext::deque < sax::Token >::iterator & data ) {
 		xmlApiInputContext & input = ( xmlApiInputContext & ) data;
 		sax::FromXMLParserHelper::skipAttributes ( input, sax::Token::TokenType::START_ELEMENT );
diff --git a/alib2xml/test-src/container/ContainerTest.cpp b/alib2xml/test-src/container/ContainerTest.cpp
index 71e40d76e3..ddc4886b5a 100644
--- a/alib2xml/test-src/container/ContainerTest.cpp
+++ b/alib2xml/test-src/container/ContainerTest.cpp
@@ -24,11 +24,11 @@ void ContainerTest::testXMLParser ( ) {
 
 	object::Object tmp ( primitive::String ( "1" ) );
 
-	container::ObjectsSet < > set;
+	ext::set < object::Object > set;
 
 	set.insert ( tmp );
 
-	object::Object object ( set );
+	object::Object object { object::AnyObject < ext::set < object::Object > > ( set ) };
 
 	{
 		std::string tmp2 = factory::XmlDataFactory::toString ( object );
-- 
GitLab