Index: /code/branches/objecthierarchie/src/BaseObject.h
===================================================================
--- /code/branches/objecthierarchie/src/BaseObject.h	(revision 161)
+++ /code/branches/objecthierarchie/src/BaseObject.h	(revision 162)
@@ -3,8 +3,9 @@
 
 #include "ClassHierarchy.h"
+#include "OrxonoxClass.h"
 
 namespace orxonox
 {
-    class BaseObject
+    class BaseObject : virtual public OrxonoxClass
     {
         public:
@@ -13,22 +14,20 @@
 
             inline bool isA(Identifier* identifier)
-                { this->identifier_->isA(identifier); }
+                { this->getIdentifier()->isA(identifier); }
             inline bool isDirectA(Identifier* identifier)
-                { this->identifier_->isDirectA(identifier); }
+                { this->getIdentifier()->isDirectA(identifier); }
             inline bool isChildOf(Identifier* identifier)
-                { this->identifier_->isChildOf(identifier); }
+                { this->getIdentifier()->isChildOf(identifier); }
             inline bool isDirectChildOf(Identifier* identifier)
-                { this->identifier_->isDirectChildOf(identifier); }
+                { this->getIdentifier()->isDirectChildOf(identifier); }
             inline bool isParentOf(Identifier* identifier)
-                { this->identifier_->isParentOf(identifier); }
+                { this->getIdentifier()->isParentOf(identifier); }
             inline bool isDirectParentOf(Identifier* identifier)
-                { this->identifier_->isDirectParentOf(identifier); }
+                { this->getIdentifier()->isDirectParentOf(identifier); }
 
-            ClassIdentifier<class BaseObject>* identifier_;
+//            Identifier* identifier_;
 
-        protected:
-            IdentifierList* parents_; // INTERN! Don't touch this!
-
-        private:
+//        protected:
+//            IdentifierList* parents_; // INTERN! Don't touch this!
 
     };
Index: /code/branches/objecthierarchie/src/CMakeLists.txt
===================================================================
--- /code/branches/objecthierarchie/src/CMakeLists.txt	(revision 161)
+++ /code/branches/objecthierarchie/src/CMakeLists.txt	(revision 162)
@@ -2,6 +2,6 @@
 
 # create a few variables to simplify life
-SET(SRC_FILES orxonox.cc BaseObject.cc ClassHierarchy.cc)
-SET(INC_FILES BaseObject.h ClassHierarchy.h)
+SET(SRC_FILES orxonox.cc ClassHierarchy.cc OrxonoxClass.cc BaseObject.cc)
+SET(INC_FILES ClassHierarchy.h OrxonoxClass.h BaseObject.h Test.h)
 
 #Creates an executable
Index: /code/branches/objecthierarchie/src/ClassHierarchy.cc
===================================================================
--- /code/branches/objecthierarchie/src/ClassHierarchy.cc	(revision 161)
+++ /code/branches/objecthierarchie/src/ClassHierarchy.cc	(revision 162)
@@ -31,4 +31,5 @@
     void Identifier::initialize(IdentifierList* parents)
     {
+        std::cout << "*** Initialize " << this->name_ << "-Singleton.\n";
         if (parents)
         {
@@ -76,11 +77,13 @@
     }
 
-    void Identifier::addObject(BaseObject* object)
-    {
+    void Identifier::addObject(OrxonoxClass* object)
+    {
+        std::cout << "*** Added " << this->name_ << " to list.\n";
         this->objects_->add(object);
     }
 
-    void Identifier::removeObject(BaseObject* object)
-    {
+    void Identifier::removeObject(OrxonoxClass* object)
+    {
+        std::cout << "*** Removed " << this->name_ << " from list.\n";
         this->objects_->remove(object);
     }
@@ -218,5 +221,5 @@
     }
 
-    void ObjectList::add(BaseObject* object)
+    void ObjectList::add(OrxonoxClass* object)
     {
         ObjectListElement* temp = this->first_;
@@ -225,5 +228,5 @@
     }
 
-    void ObjectList::remove(BaseObject* object)
+    void ObjectList::remove(OrxonoxClass* object)
     {
         if (!object)
@@ -259,8 +262,27 @@
     // ###    ObjectListElement    ###
     // ###############################
-    ObjectListElement::ObjectListElement(BaseObject* object)
+    ObjectListElement::ObjectListElement(OrxonoxClass* object)
     {
         this->object_ = object;
         this->next_ = NULL;
     }
+
+
+    // ###############################
+    // ###     ClassHierarchy      ###
+    // ###############################
+    ClassHierarchy* ClassHierarchy::pointer_ = NULL;
+
+    ClassHierarchy* ClassHierarchy::getSingleton()
+    {
+        if (!pointer_)
+            pointer_ = new ClassHierarchy();
+
+        return pointer_;
+    }
+
+    ClassHierarchy::ClassHierarchy()
+    {
+        this->bCreatingHierarchy_ = false;
+    }
 }
Index: /code/branches/objecthierarchie/src/ClassHierarchy.h
===================================================================
--- /code/branches/objecthierarchie/src/ClassHierarchy.h	(revision 161)
+++ /code/branches/objecthierarchie/src/ClassHierarchy.h	(revision 162)
@@ -3,4 +3,5 @@
 
 #include <string>
+#include <iostream>
 
 // DONE:
@@ -18,8 +19,23 @@
 namespace orxonox
 {
+    // ##### ClassHierarchy #####
+    class ClassHierarchy
+    {
+        public:
+            static ClassHierarchy* getSingleton();
+            bool isCreatingHierarchy() { return this->bCreatingHierarchy_; }
+            void createHierarchy(bool bCreatingHierarchy) { this->bCreatingHierarchy_ = bCreatingHierarchy; std::cout << "*** Switched Hierarchy-Creating-Mode to" << bCreatingHierarchy << "\n"; }
+
+        private:
+            ClassHierarchy();
+
+            static ClassHierarchy* pointer_;
+            bool bCreatingHierarchy_;
+    };
+
     // ##### Identifier #####
     class IdentifierList;
     class ObjectList;
-    class BaseObject;
+    class OrxonoxClass;
     template <class T>
     class ClassIdentifier;
@@ -31,6 +47,6 @@
 
         public:
-            void addObject(BaseObject* object);
-            void removeObject(BaseObject* object);
+            void addObject(OrxonoxClass* object);
+            void removeObject(OrxonoxClass* object);
 
             bool isA(Identifier* identifier);
@@ -60,5 +76,5 @@
     {
         public:
-            static ClassIdentifier<T>* registerClass(IdentifierList* parents);
+            static ClassIdentifier<T>* registerClass(IdentifierList* parents, std::string name, bool bRootClass);
             static ClassIdentifier<T>* getIdentifier();
             static T* create();
@@ -71,7 +87,4 @@
     };
 
-    #define getStringFromClassName(ClassName) \
-        #ClassName
-
     template <class T>
     ClassIdentifier<T>* ClassIdentifier<T>::pointer_ = NULL;
@@ -83,11 +96,20 @@
 
     template <class T>
-    ClassIdentifier<T>* ClassIdentifier<T>::registerClass(IdentifierList* parents)
-    {
+    ClassIdentifier<T>* ClassIdentifier<T>::registerClass(IdentifierList* parents, std::string name, bool bRootClass)
+    {
+        std::cout << "*** Register Class in " << name << "-Singleton.\n";
         if (!pointer_)
         {
-            pointer_ = new ClassIdentifier();
-            pointer_->name_ = getStringFromClassName(T);
-            pointer_->initialize(parents);
+            std::cout << "*** Register Class in " << name << "-Singleton -> Create Singleton.\n";
+            if (parents || bRootClass)
+            {
+                pointer_ = new ClassIdentifier();
+                pointer_->name_ = name;
+                pointer_->initialize(parents);
+            }
+            else
+            {
+                pointer_ = getIdentifier();
+            }
         }
 
@@ -98,7 +120,11 @@
     ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
     {
+        std::cout << "*** Get Identifier.\n";
         if (!pointer_)
         {
+            std::cout << "*** Get Identifier -> Create Class\n";
+            ClassHierarchy::getSingleton()->createHierarchy(true);
             T* temp = new T();
+            ClassHierarchy::getSingleton()->createHierarchy(false);
             delete temp;
         }
@@ -147,6 +173,6 @@
             ObjectList();
             ~ObjectList();
-            void add(BaseObject* object);
-            void remove(BaseObject* object);
+            void add(OrxonoxClass* object);
+            void remove(OrxonoxClass* object);
 
             ObjectListElement* first_;
@@ -156,27 +182,32 @@
     {
         public:
-            ObjectListElement(BaseObject* object);
-
-            BaseObject* object_;
+            ObjectListElement(OrxonoxClass* object);
+
+            OrxonoxClass* object_;
             ObjectListElement* next_;
     };
-
 
     // ##### Macros #####
     #define registerRootObject(ClassName) \
-        this->parents_ = new IdentifierList(); \
-        this->identifier_ = ClassIdentifier<ClassName>::registerClass(this->parents_); \
-        this->parents_->add(this->identifier_); \
-        this->identifier_->addObject(this)
+        std::cout << "*** Register Root-Object: " << #ClassName << "\n"; \
+        if (ClassHierarchy::getSingleton()->isCreatingHierarchy() && !this->getParents()) \
+            this->setParents(new IdentifierList()); \
+        if (this->getIdentifier()) \
+            this->getIdentifier()->removeObject(this); \
+        this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, true)); \
+        if (ClassHierarchy::getSingleton()->isCreatingHierarchy() && this->getParents()) \
+            this->getParents()->add(this->getIdentifier()); \
+        this->getIdentifier()->addObject(this)
 
     #define registerObject(ClassName) \
-        this->identifier_->removeObject(this); \
-        this->identifier_ = ClassIdentifier<ClassName>::registerClass(this->parents_); \
-        this->parents_->add(this->identifier_); \
-        this->identifier_->addObject(this)
+        std::cout << "*** Register Object: " << #ClassName << "\n"; \
+        this->getIdentifier()->removeObject(this); \
+        this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, false)); \
+        if (ClassHierarchy::getSingleton()->isCreatingHierarchy() && this->getParents()) \
+            this->getParents()->add(this->getIdentifier()); \
+        this->getIdentifier()->addObject(this)
 
     #define unregisterObject() \
-        delete this->parents_; \
-        this->identifier_->removeObject(this)
+        this->getIdentifier()->removeObject(this)
 
     #define Class(ClassName) \
Index: /code/branches/objecthierarchie/src/OrxonoxClass.cc
===================================================================
--- /code/branches/objecthierarchie/src/OrxonoxClass.cc	(revision 162)
+++ /code/branches/objecthierarchie/src/OrxonoxClass.cc	(revision 162)
@@ -0,0 +1,17 @@
+#include "OrxonoxClass.h"
+#include "ClassHierarchy.h"
+
+namespace orxonox
+{
+    OrxonoxClass::OrxonoxClass()
+    {
+        this->identifier_ = 0;
+        this->parents_ = 0;
+    }
+
+    OrxonoxClass::~OrxonoxClass()
+    {
+        if (this->parents_)
+            delete this->parents_;
+    }
+}
Index: /code/branches/objecthierarchie/src/OrxonoxClass.h
===================================================================
--- /code/branches/objecthierarchie/src/OrxonoxClass.h	(revision 162)
+++ /code/branches/objecthierarchie/src/OrxonoxClass.h	(revision 162)
@@ -0,0 +1,25 @@
+#ifndef _OrxonoxClass_H__
+#define _OrxonoxClass_H__
+
+namespace orxonox
+{
+    class Identifier;
+    class IdentifierList;
+
+    class OrxonoxClass
+    {
+        public:
+            OrxonoxClass();
+            ~OrxonoxClass();
+            Identifier* getIdentifier() { return this->identifier_; }
+            void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; }
+            IdentifierList* getParents() { return this->parents_; }
+            void setParents(IdentifierList* parents) { this->parents_ = parents; }
+
+        private:
+            Identifier* identifier_;
+            IdentifierList* parents_;
+    };
+}
+
+#endif
Index: /code/branches/objecthierarchie/src/Test.h
===================================================================
--- /code/branches/objecthierarchie/src/Test.h	(revision 162)
+++ /code/branches/objecthierarchie/src/Test.h	(revision 162)
@@ -0,0 +1,132 @@
+#ifndef _Test_H__
+#define _Test_H__
+
+
+#include "BaseObject.h"
+#include "ClassHierarchy.h"
+#include "OrxonoxClass.h"
+
+namespace orxonox
+{
+    class Interface1 : virtual public OrxonoxClass
+    {
+        public:
+            Interface1() { registerRootObject(Interface1); }
+    };
+
+    class Interface2 : virtual public OrxonoxClass
+    {
+        public:
+            Interface2() { registerRootObject(Interface2); }
+    };
+
+    class A1 : public BaseObject
+    {
+        public:
+            A1() { registerObject(A1); }
+    };
+
+    class A2 : public BaseObject
+    {
+        public:
+            A2() { registerObject(A2); }
+    };
+
+    class A3: public BaseObject, public Interface1
+    {
+        public:
+            A3() { registerObject(A3); }
+    };
+
+    class A1B1 : public A1
+    {
+        public:
+            A1B1() { registerObject(A1B1); }
+    };
+
+    class A1B2 : public A1
+    {
+        public:
+            A1B2() { registerObject(A1B2); }
+    };
+
+    class A2B1 : public A2
+    {
+        public:
+            A2B1() { registerObject(A2B1); }
+    };
+
+    class A2B2 : public A2, Interface1
+    {
+        public:
+            A2B2() { registerObject(A2B2); }
+    };
+
+    class A3B1 : public A3
+    {
+        public:
+            A3B1() { registerObject(A3B1); }
+    };
+
+    class A3B2 : public A3, Interface2
+    {
+        public:
+            A3B2() { registerObject(A3B2); }
+    };
+
+    class A1B1C1 : public A1B1
+    {
+        public:
+            A1B1C1() { registerObject(A1B1C1); }
+    };
+
+    class A1B1C2 : public A1B1
+    {
+        public:
+            A1B1C2() { registerObject(A1B1C2); }
+    };
+
+    class A1B2C1 : public A1B2
+    {
+        public:
+            A1B2C1() { registerObject(A1B2C1); }
+    };
+
+    class A2B1C1 : public A2B1, Interface2
+    {
+        public:
+            A2B1C1() { registerObject(A2B1C1); }
+    };
+
+    class A2B2C1 : public A2B2
+    {
+        public:
+            A2B2C1() { registerObject(A2B2C1); }
+    };
+
+    class A3B1C1 : public A3B1
+    {
+        public:
+            A3B1C1() { registerObject(A3B1C1); }
+    };
+
+    class A3B1C2 : public A3B1, Interface2
+    {
+        public:
+            A3B1C2() { registerObject(A3B1C2); }
+    };
+
+    class A3B2C1 : public A3B2
+    {
+        public:
+            A3B2C1() { registerObject(A3B2C1); }
+    };
+
+    class A3B2C2 : public A3B2
+    {
+        public:
+            A3B2C2() { registerObject(A3B2C2); }
+    };
+}
+
+#endif
Index: /code/branches/objecthierarchie/src/orxonox.cc
===================================================================
--- /code/branches/objecthierarchie/src/orxonox.cc	(revision 161)
+++ /code/branches/objecthierarchie/src/orxonox.cc	(revision 162)
@@ -31,4 +31,7 @@
 #include <OgreCEGUIRenderer.h>
 
+#include "BaseObject.h"
+#include "Test.h"
+
 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
 #include <CoreFoundation/CoreFoundation.h>
@@ -83,5 +86,5 @@
     void go()
     {
-      createRoot();
+/*      createRoot();
       defineResources();
       setupRenderSystem();
@@ -93,4 +96,29 @@
       createFrameListener();
       startRenderLoop();
+*/
+      std::cout << "Test 1\n";
+      orxonox::BaseObject* test1;
+      test1 = new orxonox::BaseObject();
+      test1 = new orxonox::BaseObject();
+      test1 = new orxonox::BaseObject();
+
+      std::cout << "Test 2\n";
+      orxonox::A1* test2;
+      test2 = new orxonox::A1();
+      test2 = new orxonox::A1();
+      test2 = new orxonox::A1();
+
+      std::cout << "Test 3\n";
+      orxonox::BaseObject* test3;
+      test3 = new orxonox::BaseObject();
+      test3 = new orxonox::BaseObject();
+      test3 = new orxonox::BaseObject();
+
+      std::cout << "Test 4\n";
+      orxonox::A3* test4;
+      test4 = new orxonox::A3();
+      test4 = new orxonox::A3();
+      test4 = new orxonox::A3();
+
     }
 
