Index: /code/branches/objecthierarchie/src/BaseObject.cc
===================================================================
--- /code/branches/objecthierarchie/src/BaseObject.cc	(revision 243)
+++ /code/branches/objecthierarchie/src/BaseObject.cc	(revision 244)
@@ -7,10 +7,10 @@
     BaseObject::BaseObject()
     {
-        registerRootObject(BaseObject);
+        RegisterRootObject(BaseObject);
     }
 
     BaseObject::~BaseObject()
     {
-        unregisterObject();
+        UnregisterObject();
     }
 }
Index: /code/branches/objecthierarchie/src/CMakeLists.txt
===================================================================
--- /code/branches/objecthierarchie/src/CMakeLists.txt	(revision 243)
+++ /code/branches/objecthierarchie/src/CMakeLists.txt	(revision 244)
@@ -3,5 +3,5 @@
 # create a few variables to simplify life
 SET(SRC_FILES orxonox.cc IdentifierList.cc Identifier.cc Factory.cc OrxonoxClass.cc BaseObject.cc test1.cc test2.cc test3.cc)
-SET(INC_FILES IdentifierIncludes.h Identifier.h Factory.h IdentifierList.h ObjectList.h Iterator.h OrxonoxClass.h BaseObject.h Test.h test1.h test2.h test3.h)
+SET(INC_FILES IdentifierIncludes.h Identifier.h Factory.h ClassFactory.h IdentifierList.h ObjectList.h Iterator.h OrxonoxClass.h BaseObject.h Test.h test1.h test2.h test3.h)
 
 #Creates an executable
Index: /code/branches/objecthierarchie/src/ClassFactory.h
===================================================================
--- /code/branches/objecthierarchie/src/ClassFactory.h	(revision 244)
+++ /code/branches/objecthierarchie/src/ClassFactory.h	(revision 244)
@@ -0,0 +1,55 @@
+#ifndef _ClassFactory_H__
+#define _ClassFactory_H__
+
+#include "Identifier.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###      ClassFactory       ###
+    // ###############################
+    template <class T>
+    class ClassFactory : public BaseFactory
+    {
+        public:
+            static bool create();
+            BaseObject* fabricate();
+
+        private:
+            ClassFactory() {}
+            ClassFactory(const ClassFactory& factory) {}
+            ~ClassFactory() {}
+
+            static T* createNewObject();
+    };
+
+    template <class T>
+    bool ClassFactory<T>::create()
+    {
+        ClassIdentifier<T>::getIdentifier()->addFactory(new ClassFactory<T>);
+
+        ClassIdentifier<T>::getIdentifier()->startCreatingHierarchy();
+#if HIERARCHY_VERBOSE
+        std::cout << "*** Create Factory -> Create Class\n";
+#endif
+        BaseObject* temp = ClassIdentifier<T>::getIdentifier()->fabricate();
+        delete temp;
+        ClassIdentifier<T>::getIdentifier()->stopCreatingHierarchy();
+
+        return true;
+    }
+
+    template <class T>
+    BaseObject* ClassFactory<T>::fabricate()
+    {
+        return ClassFactory<T>::createNewObject();
+    }
+
+    template <class T>
+    T* ClassFactory<T>::createNewObject()
+    {
+        return new T;
+    }
+}
+
+#endif
Index: /code/branches/objecthierarchie/src/Factory.cc
===================================================================
--- /code/branches/objecthierarchie/src/Factory.cc	(revision 243)
+++ /code/branches/objecthierarchie/src/Factory.cc	(revision 244)
@@ -5,18 +5,18 @@
 namespace orxonox
 {
-    ClassFactory* ClassFactory::pointer_s = NULL;
+    Factory* Factory::pointer_s = NULL;
 
-    BaseObject* ClassFactory::fabricate(const std::string& name)
+    Identifier* Factory::getIdentifier(const std::string& name)
     {
         if (!pointer_s)
-            pointer_s = new ClassFactory;
+            pointer_s = new Factory;
 
-        return pointer_s->identifierMap_[name]->fabricate();
+        return pointer_s->identifierMap_[name];
     }
 
-    void ClassFactory::add(const std::string& name, Identifier* identifier)
+    void Factory::add(const std::string& name, Identifier* identifier)
     {
         if (!pointer_s)
-            pointer_s = new ClassFactory;
+            pointer_s = new Factory;
 
         pointer_s->identifierMap_[name] = identifier;
Index: /code/branches/objecthierarchie/src/Factory.h
===================================================================
--- /code/branches/objecthierarchie/src/Factory.h	(revision 243)
+++ /code/branches/objecthierarchie/src/Factory.h	(revision 244)
@@ -7,20 +7,32 @@
 namespace orxonox
 {
+    class BaseObject;
     class Identifier;
-    class BaseObject;
 
-    class ClassFactory
+    // ###############################
+    // ###         Factory         ###
+    // ###############################
+    class Factory
     {
         public:
-            static BaseObject* fabricate(const std::string& name);
+            static Identifier* getIdentifier(const std::string& name);
             static void add(const std::string& name, Identifier* identifier);
 
         private:
-            ClassFactory() {}
-            ClassFactory(const ClassFactory& factory) {}
-            ~ClassFactory() {}
+            Factory() {}
+            Factory(const Factory& factory) {}
+            ~Factory() {}
 
-            static ClassFactory* pointer_s;
+            static Factory* pointer_s;
             std::map<std::string, Identifier*> identifierMap_;
+    };
+
+    // ###############################
+    // ###       BaseFactory       ###
+    // ###############################
+    class BaseFactory
+    {
+        public:
+            virtual BaseObject* fabricate() = 0;
     };
 }
Index: /code/branches/objecthierarchie/src/Identifier.cc
===================================================================
--- /code/branches/objecthierarchie/src/Identifier.cc	(revision 243)
+++ /code/branches/objecthierarchie/src/Identifier.cc	(revision 244)
@@ -11,4 +11,5 @@
     {
         this->bCreatedOneObject_ = false;
+        this->factory_ = 0;
 
         this->children_ = new IdentifierList;
@@ -27,8 +28,8 @@
         std::cout << "*** Initialize " << this->name_ << "-Singleton.\n";
 #endif
+        this->bCreatedOneObject_ = true;
+
         if (parents)
         {
-            this->bCreatedOneObject_ = true;
-
             IdentifierListElement* temp1 = parents->first_;
             while (temp1)
@@ -39,4 +40,18 @@
                 temp1 = temp1->next_;
             }
+        }
+    }
+
+    BaseObject* Identifier::fabricate()
+    {
+        if (this->factory_)
+        {
+            return this->factory_->fabricate();
+        }
+        else
+        {
+            std::cout << "Error: Cannot create an object of type '" << this->name_ << "'. Class is abstract.\n";
+            std::cout << "Aborting...";
+            abort();
         }
     }
Index: /code/branches/objecthierarchie/src/Identifier.h
===================================================================
--- /code/branches/objecthierarchie/src/Identifier.h	(revision 243)
+++ /code/branches/objecthierarchie/src/Identifier.h	(revision 244)
@@ -8,5 +8,5 @@
 #include "Factory.h"
 
-#define HIERARCHY_VERBOSE false
+#define HIERARCHY_VERBOSE true
 
 
@@ -26,9 +26,13 @@
         friend class SubclassIdentifier;
 
+        template <class T>
+        friend class ClassFactory;
+
         public:
             virtual void removeObject(OrxonoxClass* object) const = 0;
             virtual void removeObjectIntern(OrxonoxClass* object, bool bIterateForwards) const = 0;
 
-            virtual BaseObject* fabricate() const = 0;
+            inline void addFactory(BaseFactory* factory) { this->factory_ = factory; }
+            BaseObject* fabricate();
 
             bool isA(const Identifier* identifier) const;
@@ -37,9 +41,9 @@
             bool isParentOf(const Identifier* identifier) const;
 
-            const std::string& getName() const { return this->name_; }
-            const IdentifierList& getParents() const { return this->parents_; }
-            IdentifierList& getChildren() const { return *this->children_; }
-
-            static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
+            inline const std::string& getName() const { return this->name_; }
+            inline const IdentifierList& getParents() const { return this->parents_; }
+            inline IdentifierList& getChildren() const { return *this->children_; }
+
+            inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
 
         private:
@@ -49,5 +53,5 @@
             void initialize(const IdentifierList* parents);
 
-            static void startCreatingHierarchy()
+            inline static void startCreatingHierarchy()
             {
                 hierarchyCreatingCounter_s++;
@@ -57,5 +61,5 @@
             }
 
-            static void stopCreatingHierarchy()
+            inline static void stopCreatingHierarchy()
             {
                 hierarchyCreatingCounter_s--;
@@ -70,7 +74,6 @@
             std::string name_;
 
-            bool bIsAbstractClass_;
+            BaseFactory* factory_;
             bool bCreatedOneObject_;
-
             static int hierarchyCreatingCounter_s;
     };
@@ -87,8 +90,6 @@
 
         public:
-            static ClassIdentifier<T>* registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass, bool bIsAbstractClass);
+            static ClassIdentifier<T>* registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass);
             static ClassIdentifier<T>* getIdentifier();
-            BaseObject* fabricate() const;
-            T* fabricateClass() const;
             static void addObject(T* object);
             void removeObject(OrxonoxClass* object) const;
@@ -121,26 +122,5 @@
 
     template <class T>
-    BaseObject* ClassIdentifier<T>::fabricate() const
-    {
-        return dynamic_cast<BaseObject*>(this->fabricateClass());
-    }
-
-    template <class T>
-    T* ClassIdentifier<T>::fabricateClass() const
-    {
-        if (!this->bIsAbstractClass_)
-        {
-            return new T;
-        }
-        else
-        {
-            std::cout << "Error: Couldn't create a new Object - Class " << this->name_ << " is abstract!\n";
-            std::cout << "Aborting...\n";
-            abort();
-        }
-    }
-
-    template <class T>
-    ClassIdentifier<T>* ClassIdentifier<T>::registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass, bool bIsAbstractClass)
+    ClassIdentifier<T>* ClassIdentifier<T>::registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass)
     {
 #if HIERARCHY_VERBOSE
@@ -152,21 +132,19 @@
             std::cout << "*** Register Class in " << name << "-Singleton -> Create Singleton.\n";
 #endif
-            if (parents || bRootClass)
-            {
-                pointer_s = new ClassIdentifier();
-                pointer_s->name_ = name;
-                pointer_s->bIsAbstractClass_ = bIsAbstractClass;
-
-                ClassFactory::add(name, pointer_s);
-
-                if (!bRootClass)
-                    pointer_s->initialize(parents);
-                else
-                    pointer_s->initialize(NULL);
-            }
+            pointer_s = new ClassIdentifier();
+        }
+
+        if (!pointer_s->bCreatedOneObject_)
+        {
+#if HIERARCHY_VERBOSE
+            std::cout << "*** Register Class in " << name << "-Singleton -> Initialize Singleton.\n";
+#endif
+            pointer_s->name_ = name;
+            Factory::add(name, pointer_s);
+
+            if (bRootClass)
+                pointer_s->initialize(NULL);
             else
-            {
-                pointer_s = getIdentifier();
-            }
+                pointer_s->initialize(parents);
         }
 
@@ -177,16 +155,10 @@
     ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
     {
-#if HIERARCHY_VERBOSE
-//        std::cout << "*** Get Identifier.\n";
-#endif
         if (!pointer_s)
         {
 #if HIERARCHY_VERBOSE
-            std::cout << "*** Get Identifier -> Create Class\n";
-#endif
-            Identifier::startCreatingHierarchy();
-            T* temp = new T();
-            delete temp;
-            Identifier::stopCreatingHierarchy();
+            std::cout << "*** Create Singleton.\n";
+#endif
+            pointer_s = new ClassIdentifier();
         }
 
Index: /code/branches/objecthierarchie/src/IdentifierIncludes.h
===================================================================
--- /code/branches/objecthierarchie/src/IdentifierIncludes.h	(revision 243)
+++ /code/branches/objecthierarchie/src/IdentifierIncludes.h	(revision 244)
@@ -1,4 +1,5 @@
 #include "Identifier.h"
 #include "Factory.h"
+#include "ClassFactory.h"
 #include "IdentifierList.h"
 #include "ObjectList.h"
@@ -7,55 +8,34 @@
 
 
-#define internRegisterRootObject(ClassName, bAbstract) \
-    if (Identifier::isCreatingHierarchy() && !this->getParents()) \
-        this->setParents(new IdentifierList()); \
-    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, true, bAbstract)); \
+#define InternRegisterObject(ClassName, bRootClass) \
+    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, bRootClass)); \
     if (Identifier::isCreatingHierarchy() && this->getParents()) \
         this->getParents()->add(this->getIdentifier()); \
     ClassIdentifier<ClassName>::addObject(this)
 
+#define InternRegisterRootObject(ClassName) \
+    if (Identifier::isCreatingHierarchy() && !this->getParents()) \
+        this->setParents(new IdentifierList()); \
+    InternRegisterObject(ClassName, true)
+
 #if HIERARCHY_VERBOSE
-#define registerRootObject(ClassName) \
-    std::cout << "*** Register Root-Object: " << #ClassName << "\n"; \
-    internRegisterRootObject(ClassName, false)
+#define RegisterObject(ClassName) \
+    std::cout << "*** Register Object: " << #ClassName << "\n"; \
+    InternRegisterObject(ClassName, false)
 #else
-#define registerRootObject(ClassName) \
-    internRegisterRootObject(ClassName, false)
+#define RegisterObject(ClassName) \
+    InternRegisterObject(ClassName, false)
 #endif
 
 #if HIERARCHY_VERBOSE
-#define registerAbstractRootObject(ClassName) \
-    std::cout << "*** Register abstract Root-Object: " << #ClassName << "\n"; \
-    internRegisterRootObject(ClassName, true)
+#define RegisterRootObject(ClassName) \
+    std::cout << "*** Register Root-Object: " << #ClassName << "\n"; \
+    InternRegisterRootObject(ClassName)
 #else
-#define registerAbstractRootObject(ClassName) \
-    internRegisterRootObject(ClassName, true)
+#define RegisterRootObject(ClassName) \
+    InternRegisterRootObject(ClassName)
 #endif
 
-#define internRegisterObject(ClassName, bAbstract) \
-    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, false, bAbstract)); \
-    if (Identifier::isCreatingHierarchy() && this->getParents()) \
-        this->getParents()->add(this->getIdentifier()); \
-    ClassIdentifier<ClassName>::addObject(this)
-
-#if HIERARCHY_VERBOSE
-#define registerObject(ClassName) \
-    std::cout << "*** Register Object: " << #ClassName << "\n"; \
-    internRegisterObject(ClassName, false)
-#else
-#define registerObject(ClassName) \
-    internRegisterObject(ClassName, false)
-#endif
-
-#if HIERARCHY_VERBOSE
-#define registerAbstractObject(ClassName) \
-    std::cout << "*** Register abstract Object: " << #ClassName << "\n"; \
-    internRegisterObject(ClassName, true)
-#else
-#define registerAbstractObject(ClassName) \
-    internRegisterObject(ClassName, true)
-#endif
-
-#define unregisterObject() \
+#define UnregisterObject() \
     this->getIdentifier()->removeObject(this)
 
@@ -64,6 +44,6 @@
 
 #define CreateFactory(ClassName) \
-    Identifier* global_##ClassName##_Identifier = ClassIdentifier<ClassName>::getIdentifier()
+    bool bCreated##ClassName##Factory = ClassFactory<ClassName>::create()
 
-#define Factory(Name) \
-    ClassFactory::fabricate(Name)
+#define ID(Name) \
+    Factory::getIdentifier(Name)
Index: /code/branches/objecthierarchie/src/Test.h
===================================================================
--- /code/branches/objecthierarchie/src/Test.h	(revision 243)
+++ /code/branches/objecthierarchie/src/Test.h	(revision 244)
@@ -9,12 +9,12 @@
     class Interface1 : virtual public OrxonoxClass
     {
-        public:
-            Interface1() { registerAbstractRootObject(Interface1); }
+        protected:
+            Interface1() { RegisterRootObject(Interface1); }
     };
 
     class Interface2 : virtual public OrxonoxClass
     {
-        public:
-            Interface2() { registerAbstractRootObject(Interface2); }
+        protected:
+            Interface2() { RegisterRootObject(Interface2); }
     };
 
@@ -22,5 +22,5 @@
     {
         public:
-            A1() { registerObject(A1); }
+            A1() { RegisterObject(A1); }
     };
 
@@ -28,5 +28,5 @@
     {
         public:
-            A2() { registerObject(A2); }
+            A2() { RegisterObject(A2); }
     };
 
@@ -34,5 +34,5 @@
     {
         public:
-            A3() { registerObject(A3); }
+            A3() { RegisterObject(A3); }
     };
 
@@ -40,5 +40,5 @@
     {
         public:
-            A1B1() { registerObject(A1B1); }
+            A1B1() { RegisterObject(A1B1); }
     };
 
@@ -46,5 +46,5 @@
     {
         public:
-            A1B2() { registerObject(A1B2); }
+            A1B2() { RegisterObject(A1B2); }
     };
 
@@ -52,5 +52,5 @@
     {
         public:
-            A2B1() { registerObject(A2B1); }
+            A2B1() { RegisterObject(A2B1); }
     };
 
@@ -58,5 +58,5 @@
     {
         public:
-            A2B2() { registerObject(A2B2); }
+            A2B2() { RegisterObject(A2B2); }
     };
 
@@ -64,5 +64,5 @@
     {
         public:
-            A3B1() { registerObject(A3B1); }
+            A3B1() { RegisterObject(A3B1); }
     };
 
@@ -70,5 +70,5 @@
     {
         public:
-            A3B2() { registerObject(A3B2); }
+            A3B2() { RegisterObject(A3B2); }
     };
 
@@ -76,5 +76,5 @@
     {
         public:
-            A1B1C1() { registerObject(A1B1C1); }
+            A1B1C1() { RegisterObject(A1B1C1); }
     };
 
@@ -82,5 +82,5 @@
     {
         public:
-            A1B1C2() { registerObject(A1B1C2); }
+            A1B1C2() { RegisterObject(A1B1C2); }
     };
 
@@ -88,5 +88,5 @@
     {
         public:
-            A1B2C1() { registerObject(A1B2C1); }
+            A1B2C1() { RegisterObject(A1B2C1); }
     };
 
@@ -94,5 +94,5 @@
     {
         public:
-            A2B1C1() { registerObject(A2B1C1); }
+            A2B1C1() { RegisterObject(A2B1C1); }
     };
 
@@ -100,5 +100,5 @@
     {
         public:
-            A2B2C1() { registerObject(A2B2C1); }
+            A2B2C1() { RegisterObject(A2B2C1); }
     };
 
@@ -106,5 +106,5 @@
     {
         public:
-            A3B1C1() { registerObject(A3B1C1); }
+            A3B1C1() { RegisterObject(A3B1C1); }
     };
 
@@ -112,5 +112,5 @@
     {
         public:
-            A3B1C2() { registerObject(A3B1C2); }
+            A3B1C2() { RegisterObject(A3B1C2); }
     };
 
@@ -118,5 +118,5 @@
     {
         public:
-            A3B2C1() { registerObject(A3B2C1); }
+            A3B2C1() { RegisterObject(A3B2C1); }
     };
 
@@ -124,5 +124,5 @@
     {
         public:
-            A3B2C2() { registerObject(A3B2C2); }
+            A3B2C2() { RegisterObject(A3B2C2); }
     };
 
Index: /code/branches/objecthierarchie/src/orxonox.cc
===================================================================
--- /code/branches/objecthierarchie/src/orxonox.cc	(revision 243)
+++ /code/branches/objecthierarchie/src/orxonox.cc	(revision 244)
@@ -102,4 +102,8 @@
         startRenderLoop();
 */
+
+        #define testandcout(code) \
+          std::cout << #code << " " << code << "\n"
+
 /*
         std::cout << "Test 1\n";
@@ -176,8 +180,4 @@
         }
 */
-
-        #define testandcout(code) \
-          std::cout << #code << " " << code << "\n"
-
 /*
         std::cout << "\n";
@@ -205,5 +205,4 @@
         testandcout(test5_03->isA(Class(BaseObject)));
         testandcout(test5_03->isA(Class(Interface1)));
-
 
         std::cout << "\n";
@@ -346,6 +345,6 @@
         std::cout << "\n";
         std::cout << "A2 parent of A2B1C1: " << Class(A2)->isParentOf(Class(A2B1C1)) << "\n";
-
-
+*/
+/*
         std::cout << "Test 7\n";
         std::cout << "1\n";
@@ -427,5 +426,5 @@
 
         std::cout << "\n4\n";
-        BaseObject* test9_06 = Factory("A2B2");
+        BaseObject* test9_06 = ID("A2B2")->fabricate();
         std::cout << test9_06->getIdentifier()->getName() << "\n";
 
@@ -436,5 +435,5 @@
         delete test9_06;
 */
-
+/*
         std::cout << "Test 10\n";
         Identifier* test10_01 = Class(A1B2);
@@ -449,5 +448,5 @@
         BaseObject* test10_07;
         for (int i = 0; i < 10; i++)
-            test10_07 = Factory("A1B1C1");
+            test10_07 = ID("A1B1C1")->fabricate();
 
         std::cout << "1\n";
@@ -484,5 +483,5 @@
         for (int i = 0; i < 10; i++)
         {
-            test10_08 = Factory("A2B1C1");
+            test10_08 = ID("A2B1C1")->fabricate();
             test10_08->name_ = "A2B1C1#";
             test10_08->name_ += ('0' + i);
@@ -534,5 +533,5 @@
         for (Iterator<A2B1C1> it; it; --it)
             std::cout << "Name: " << it->name_ << "\n";
-
+*/
 
       }
Index: /code/branches/objecthierarchie/src/test1.cc
===================================================================
--- /code/branches/objecthierarchie/src/test1.cc	(revision 243)
+++ /code/branches/objecthierarchie/src/test1.cc	(revision 244)
@@ -9,5 +9,5 @@
     Test1::Test1()
     {
-        registerObject(Test1);
+        RegisterObject(Test1);
 
         this->usefullClass1_ = Class(Test1);
Index: /code/branches/objecthierarchie/src/test2.cc
===================================================================
--- /code/branches/objecthierarchie/src/test2.cc	(revision 243)
+++ /code/branches/objecthierarchie/src/test2.cc	(revision 244)
@@ -9,5 +9,5 @@
     Test2::Test2()
     {
-        registerObject(Test2);
+        RegisterObject(Test2);
 
         this->usefullClass1_ = Class(Test1);
Index: /code/branches/objecthierarchie/src/test3.cc
===================================================================
--- /code/branches/objecthierarchie/src/test3.cc	(revision 243)
+++ /code/branches/objecthierarchie/src/test3.cc	(revision 244)
@@ -9,5 +9,5 @@
     Test3::Test3()
     {
-        registerObject(Test3);
+        RegisterObject(Test3);
     }
 
