Index: code/branches/objecthierarchie/src/BaseObject.cc
===================================================================
--- code/branches/objecthierarchie/src/BaseObject.cc	(revision 132)
+++ code/branches/objecthierarchie/src/BaseObject.cc	(revision 149)
@@ -1,23 +1,14 @@
 #include "BaseObject.h"
 
-//namespace orxonox
-//{
+namespace orxonox
+{
     BaseObject::BaseObject()
     {
-//        registerObject(BaseObject, true);
+        registerRootObject(BaseObject);
     }
 
     BaseObject::~BaseObject()
     {
-//        unregisterObject();
+        unregisterObject();
     }
-/*
-    void* BaseObject::operator new (size_t size)
-    {
-        void *pMem = new char[size];
-        memset(pMem,0,size);
-
-        return pMem;
-    }
-*/
-//}
+}
Index: code/branches/objecthierarchie/src/BaseObject.h
===================================================================
--- code/branches/objecthierarchie/src/BaseObject.h	(revision 132)
+++ code/branches/objecthierarchie/src/BaseObject.h	(revision 149)
@@ -4,6 +4,6 @@
 #include "ClassHierarchy.h"
 
-//namespace orxonox
-//{
+namespace orxonox
+{
     class BaseObject
     {
@@ -12,17 +12,26 @@
             ~BaseObject();
 
-            bool isA(ClassName* className);
-            bool isChildOf(ClassName* className);
-            bool isParentOf(ClassName* className);
-            static bool getParentOf(ClassName* className);
+            inline bool isA(Identifier* identifier)
+                { this->identifier_->isA(identifier); }
+            inline bool isDirectA(Identifier* identifier)
+                { this->identifier_->isDirectA(identifier); }
+            inline bool isChildOf(Identifier* identifier)
+                { this->identifier_->isChildOf(identifier); }
+            inline bool isDirectChildOf(Identifier* identifier)
+                { this->identifier_->isDirectChildOf(identifier); }
+            inline bool isParentOf(Identifier* identifier)
+                { this->identifier_->isParentOf(identifier); }
+            inline bool isDirectParentOf(Identifier* identifier)
+                { this->identifier_->isDirectParentOf(identifier); }
 
-//            static void operator new (size_t size);
+            Identifier* identifier_;
 
-            ClassName *className;
+        protected:
+            IdentifierList* parents_; // INTERN! Don't touch this!
 
         private:
 
     };
-//}
+}
 
 #endif
Index: code/branches/objecthierarchie/src/ClassHierarchy.cc
===================================================================
--- code/branches/objecthierarchie/src/ClassHierarchy.cc	(revision 132)
+++ code/branches/objecthierarchie/src/ClassHierarchy.cc	(revision 149)
@@ -1,259 +1,266 @@
 #include "ClassHierarchy.h"
-#include "BaseObject.h"
-
-//namespace orxonox
-//{
-    // ##### ClassName #####
-    ClassName::ClassName(const std::string& name, ClassNameSingleton<class T>* factory)
-    {
-        this->parentClass = NULL;
-        this->childClasses = new ClassList();
-        this->objects = new ObjectList();
-        this->name = name;
-        this->factory = factory;
-    }
-
-    ClassName::~ClassName()
-    {
-        delete this->childClasses;
-        delete this->objects;
-    }
-
-
-    // ##### ClassListItem #####
-    ClassListItem::ClassListItem(ClassName* className)
-    {
-        this->next = NULL;
-        this->className = className;
-    }
-
-    ClassListItem::~ClassListItem()
-    {
-        delete this->className;
-        delete this->next;
-    }
-
-
-    // ##### ClassList #####
-    ClassList::ClassList()
-    {
-        this->first = NULL;
-    }
-
-    ClassList::~ClassList()
-    {
-        delete this->first;
-    }
-
-    void ClassList::add(ClassName* className)
-    {
-        if (!this->first)
-        {
-            this->first = new ClassListItem(className);
-            return;
-        }
-
-        ClassListItem* iterator = this->first;
-        while (iterator != NULL)
-        {
-            if (iterator->next == NULL)
-            {
-                iterator->next = new ClassListItem(className);
+
+namespace orxonox
+{
+    // ###############################
+    // ###       Identifier        ###
+    // ###############################
+    Identifier* Identifier::pointer_ = NULL;
+/*
+    Identifier* Identifier::registerClass(IdentifierList* parents)
+    {
+        if (!pointer_)
+        {
+            pointer_ = new Identifier();
+            pointer_->initialize(parents);
+        }
+
+        return pointer_;
+    }
+*/
+    Identifier::Identifier()
+    {
+        this->bCreatedOneObject_ = false;
+        this->directParents_ = new IdentifierList();
+        this->allParents_ = new IdentifierList();
+        this->directChildren_ = new IdentifierList();
+        this->allChildren_ = new IdentifierList();
+        this->objects_ = new ObjectList();
+    }
+
+    void Identifier::initialize(IdentifierList* parents)
+    {
+        if (parents)
+        {
+            this->bCreatedOneObject_ = true;
+
+            IdentifierListElement* temp1;
+            IdentifierListElement* temp2;
+            IdentifierListElement* temp3;
+
+            temp1 = parents->first_;
+            while (temp1)
+            {
+                temp2 = temp1->identifier_->directParents_->first_;
+                while (temp2)
+                {
+                    temp3 = parents->first_;
+                    while(temp3)
+                    {
+                        if (temp3->identifier_ == temp2->identifier_)
+                            temp3->bDirect_ = false;
+
+                        temp3 = temp3->next_;
+                    }
+
+                    temp2 = temp2->next_;
+                }
+                temp1 = temp1->next_;
+            }
+
+            temp1 = parents->first_;
+            while (temp1)
+            {
+                if (temp1->bDirect_)
+                {
+                    this->directParents_->add(temp1->identifier_);
+                    temp1->identifier_->directChildren_->add(this->pointer_);
+                }
+
+                this->allParents_->add(temp1->identifier_);
+                temp1->identifier_->allChildren_->add(this->pointer_);
+
+                temp1 = temp1->next_;
+            }
+        }
+    }
+
+    void Identifier::addObject(BaseObject* object)
+    {
+        this->objects_->add(object);
+    }
+
+    void Identifier::removeObject(BaseObject* object)
+    {
+        this->objects_->remove(object);
+    }
+
+    bool Identifier::isA(Identifier* identifier)
+    {
+        return (identifier == this->pointer_ || this->allParents_->isInList(identifier));
+    }
+
+    bool Identifier::isDirectA(Identifier* identifier)
+    {
+        return (identifier == this->pointer_);
+    }
+
+    bool Identifier::isChildOf(Identifier* identifier)
+    {
+        return this->allParents_->isInList(identifier);
+    }
+
+    bool Identifier::isDirectChildOf(Identifier* identifier)
+    {
+        return this->directParents_->isInList(identifier);
+    }
+
+    bool Identifier::isParentOf(Identifier* identifier)
+    {
+        return this->allChildren_->isInList(identifier);
+    }
+
+    bool Identifier::isDirectParentOf(Identifier* identifier)
+    {
+        return this->directChildren_->isInList(identifier);
+    }
+
+
+    // ###############################
+    // ###     IdentifierList      ###
+    // ###############################
+    IdentifierList::IdentifierList()
+    {
+        this->first_ = NULL;
+    }
+
+    IdentifierList::~IdentifierList()
+    {
+        IdentifierListElement* temp;
+        while (this->first_)
+        {
+            temp = this->first_->next_;
+            delete this->first_;
+            this->first_ = temp;
+        }
+    }
+
+    void IdentifierList::add(Identifier* identifier)
+    {
+        IdentifierListElement* temp = this->first_;
+        this->first_ = new IdentifierListElement(identifier);
+        this->first_->next_ = temp;
+    }
+
+    void IdentifierList::remove(Identifier* identifier)
+    {
+        if (!identifier)
+            return;
+
+        if (this->first_->identifier_ == identifier)
+        {
+            IdentifierListElement* temp = this->first_->next_;
+            delete this->first_;
+            this->first_ = temp;
+
+            return;
+        }
+
+        IdentifierListElement* temp = this->first_;
+        while (temp->next_)
+        {
+            if (temp->next_->identifier_ == identifier)
+            {
+                IdentifierListElement* temp2 = temp->next_->next_;
+                delete temp->next_;
+                temp->next_ = temp2;
+
                 return;
             }
 
-            iterator = iterator->next;
-        }
-    }
-
-    // ##### ObjectListItem #####
-    ObjectListItem::ObjectListItem(BaseObject* object)
-    {
-        this->next = NULL;
-        this->object = object;
-    }
-
-    ObjectListItem::~ObjectListItem()
-    {
-        delete this->object;
-        delete this->next;
-    }
-
-
-    // ##### ObjectList #####
+            temp = temp->next_;
+        }
+    }
+
+    bool IdentifierList::isInList(Identifier* identifier)
+    {
+        IdentifierListElement* temp = this->first_;
+        while (temp)
+        {
+            if (temp->identifier_ == identifier)
+                return true;
+
+            temp = temp->next_;
+        }
+
+        return false;
+    }
+
+
+    // ###############################
+    // ###  IdentifierListElement  ###
+    // ###############################
+    IdentifierListElement::IdentifierListElement(Identifier* identifier)
+    {
+        this->identifier_ = identifier;
+        this->next_ = NULL;
+        this->bDirect_ = true;
+    }
+
+
+    // ###############################
+    // ###       ObjectList        ###
+    // ###############################
     ObjectList::ObjectList()
     {
-        this->first = NULL;
+        this->first_ = NULL;
     }
 
     ObjectList::~ObjectList()
     {
-        delete this->first;
+        ObjectListElement* temp;
+        while (this->first_)
+        {
+            temp = this->first_->next_;
+            delete this->first_;
+            this->first_ = temp;
+        }
     }
 
     void ObjectList::add(BaseObject* object)
     {
-        if (!this->first)
-        {
-            this->first = new ObjectListItem(object);
-            return;
-        }
-
-        ObjectListItem* iterator = this->first;
-        while (iterator != NULL)
-        {
-            if (iterator->next == NULL)
-            {
-                iterator->next = new ObjectListItem(object);
+        ObjectListElement* temp = this->first_;
+        this->first_ = new ObjectListElement(object);
+        this->first_->next_ = temp;
+    }
+
+    void ObjectList::remove(BaseObject* object)
+    {
+        if (!object)
+            return;
+
+        if (this->first_->object_ == object)
+        {
+            ObjectListElement* temp = this->first_->next_;
+            delete this->first_;
+            this->first_ = temp;
+
+            return;
+        }
+
+        ObjectListElement* temp = this->first_;
+        while (temp->next_)
+        {
+            if (temp->next_->object_ == object)
+            {
+                ObjectListElement* temp2 = temp->next_->next_;
+                delete temp->next_;
+                temp->next_ = temp2;
+
                 return;
             }
 
-            iterator = iterator->next;
-        }
-    }
-
-    void ObjectList::remove(BaseObject* object)
-    {
-        if (!this->first || !object)
-            return;
-
-        if (this->first->object == object)
-        {
-            ObjectListItem* temp = this->first->next;
-            delete this->first;
-            this->first = temp;
-
-            return;
-        }
-
-        ObjectListItem* iterator = this->first;
-        while (iterator->next != NULL)
-        {
-            if (iterator->next->object == object)
-            {
-                ObjectListItem* temp = iterator->next->next;
-                delete iterator->next;
-                iterator->next = temp;
-
-                return;
-            }
-
-            iterator = iterator->next;
-        }
-    }
-
-    // ##### ClassNameTree #####
-    ClassNameTree* ClassNameTree::pointer = NULL;
-
-    ClassNameTree::ClassNameTree()
-    {
-    }
-
-    ClassNameTree::~ClassNameTree()
-    {
-        this->pointer = NULL;
-    }
-
-    ClassNameTree* ClassNameTree::getSingleton()
-    {
-        if (!pointer)
-        {
-            pointer = new ClassNameTree();
-        }
-
-        return pointer;
-    }
-/*
-    BaseObject* ClassNameTree::create(ClassName* className)
-    {
-        return className->factory->create();
-    }
-
-    BaseObject* ClassNameTree::create(std::string& name)
-    {
-        return this->getClassName(name)->factory->create();
-    }
-*/
-    ClassName* ClassNameTree::getClassName(std::string& name)
-    {
-        return getClassName(name, this->rootClass);
-    }
-
-    ClassName* ClassNameTree::getClassName(std::string& name, ClassName* root)
-    {
-        if (root->name == name)
-            return root;
-
-        ClassListItem* temp = root->childClasses->first;
-        while (temp != NULL)
-        {
-            ClassName* temp2 = this->getClassName(name, temp->className);
-            if (temp2)
-                return temp2;
-
-            temp = temp->next;
-        }
-
-        return NULL;
-    }
-
-
-    // ##### ClassNameSingleton #####
-    #define getClassNameString(ClassName) \
-        #ClassName
-
-    template <class T>
-    ClassNameSingleton<T>* ClassNameSingleton<T>::pointer = NULL;
-
-    template <class T>
-    ClassName* ClassNameSingleton<T>::className = NULL;
-
-    template <class T>
-    ClassName* ClassNameSingleton<T>::getClassName(BaseObject* object, bool bIsRootClass)
-    {
-        if (!pointer || !className)
-        {
-            pointer = new ClassNameSingleton<T>();
-            className = new ClassName(getClassNameString(T), pointer);
-
-            if (bIsRootClass)
-            {
-                className->parentClass = NULL;
-                ClassNameTree::getSingleton()->setRootClass(className);
-            }
-            else
-            {
-                className->parentClass = object->className;
-                object->className->childClasses->add(className);
-            }
-        }
-
-        return className;
-    }
-
-    template <class T>
-    ClassName* ClassNameSingleton<T>::getNewClassName()
-    {
-        if (!pointer || !className)
-        {
-            T* temp = new T();
-            delete temp;
-        }
-
-        return className;
-    }
-
-    template <class T>
-    BaseObject* ClassNameSingleton<T>::create()
-    {
-        return new T();
-    }
-
-    template <class T>
-    ClassNameSingleton<T>::~ClassNameSingleton()
-    {
-        this->pointer = NULL;
-        delete this->className;
-        this->className = NULL;
-    }
-//}
+            temp = temp->next_;
+        }
+    }
+
+
+    // ###############################
+    // ###    ObjectListElement    ###
+    // ###############################
+    ObjectListElement::ObjectListElement(BaseObject* object)
+    {
+        this->object_ = object;
+        this->next_ = NULL;
+    }
+}
Index: code/branches/objecthierarchie/src/ClassHierarchy.h
===================================================================
--- code/branches/objecthierarchie/src/ClassHierarchy.h	(revision 132)
+++ code/branches/objecthierarchie/src/ClassHierarchy.h	(revision 149)
@@ -6,76 +6,137 @@
 // DONE:
 // - klassenhierarchie aufbauen
+// - in listen einfügen
+// - factory
 // - klassen-identifier
+// - isA u.ä. vergleiche
 
 // TODO:
 // - durch listen iterieren
-// - isA usw vergleiche
-// - new überladen + objekt in liste eintragen
 // - searchtree für classname-strings
 
-//namespace orxonox
-//{
-    class ClassName;
-    class ClassList;
+
+namespace orxonox
+{
+    // ##### Identifier #####
+    class IdentifierList;
     class ObjectList;
     class BaseObject;
 
+    class Identifier
+    {
+        template <class T>
+        friend class ClassIdentifier;
+
+        public:
+//            static Identifier* registerClass(IdentifierList* parents);
+            void addObject(BaseObject* object);
+            void removeObject(BaseObject* object);
+
+            bool isA(Identifier* identifier);
+            bool isDirectA(Identifier* identifier);
+            bool isChildOf(Identifier* identifier);
+            bool isDirectChildOf(Identifier* identifier);
+            bool isParentOf(Identifier* identifier);
+            bool isDirectParentOf(Identifier* identifier);
+
+        protected:
+            Identifier();
+            void initialize(IdentifierList* identifier);
+
+            static Identifier* pointer_;
+
+            IdentifierList* directParents_;
+            IdentifierList* allParents_;
+            IdentifierList* directChildren_;
+            IdentifierList* allChildren_;
+
+            ObjectList* objects_;
+            std::string name_;
+
+        private:
+            bool bCreatedOneObject_;
+    };
+
     template <class T>
-    class ClassNameSingleton
+    class ClassIdentifier : public Identifier
+    {
+//        friend class Identifier;
+
+        public:
+            static Identifier* registerClass(IdentifierList* parents);
+            static Identifier* getIdentifier();
+            static T* create();
+
+        private:
+            ClassIdentifier();
+    };
+
+    #define getStringFromClassName(ClassName) \
+        #ClassName
+
+    template <class T>
+    ClassIdentifier<T>::ClassIdentifier()
+    {
+    }
+
+    template <class T>
+    Identifier* ClassIdentifier<T>::registerClass(IdentifierList* parents)
+    {
+        if (!pointer_)
+        {
+            pointer_ = new ClassIdentifier();
+            pointer_->name_ = getStringFromClassName(T);
+            pointer_->initialize(parents);
+        }
+
+        return pointer_;
+    }
+
+    template <class T>
+    Identifier* ClassIdentifier<T>::getIdentifier()
+    {
+        if (!pointer_)
+        {
+            T* temp = new T();
+            delete temp;
+        }
+
+        return pointer_;
+    }
+
+    template <class T>
+    T* ClassIdentifier<T>::create()
+    {
+        return new T();
+    }
+
+    // ##### Identifier List #####
+    class IdentifierListElement;
+
+    class IdentifierList
     {
         public:
-            static ClassName* getClassName(BaseObject* object, bool bIsRootClass);
-            static ClassName* getNewClassName();
-            BaseObject* create();
+            IdentifierList();
+            ~IdentifierList();
+            void add(Identifier* identifier);
+            void remove(Identifier* identifier);
+            bool isInList(Identifier* identifier);
 
-        private:
-            ClassNameSingleton();
-            ~ClassNameSingleton();
-            static ClassNameSingleton *pointer;
-            static ClassName *className;
+            IdentifierListElement* first_;
     };
 
-    class ClassName
+    class IdentifierListElement
     {
         public:
-            ClassName(const std::string& name, ClassNameSingleton<class T>* factory);
-            ~ClassName();
+            IdentifierListElement(Identifier* identifier);
 
-            std::string name;
-            ClassName *parentClass;
-            ClassList *childClasses;
-            ObjectList *objects;
-            ClassNameSingleton<class T> *factory;
+            Identifier* identifier_;
+            IdentifierListElement* next_;
+            bool bDirect_;
     };
 
-    class ClassListItem
-    {
-        public:
-            ClassListItem(ClassName* className);
-            ~ClassListItem();
 
-            ClassListItem *next;
-            ClassName *className;
-    };
-
-    class ClassList
-    {
-        public:
-            ClassList();
-            ~ClassList();
-            void add(ClassName* className);
-
-            ClassListItem *first;
-    };
-
-    class ObjectListItem
-    {
-        public:
-            ObjectListItem(BaseObject* object);
-            ~ObjectListItem();
-
-            ObjectListItem *next;
-            BaseObject *object;
-    };
+    // ##### Object List #####
+    class ObjectListElement;
 
     class ObjectList
@@ -87,38 +148,40 @@
             void remove(BaseObject* object);
 
-            ObjectListItem *first;
+            ObjectListElement* first_;
     };
 
-    class ClassNameTree
+    class ObjectListElement
     {
         public:
-            static ClassNameTree* getSingleton();
-            BaseObject* create(ClassName* className);
-            BaseObject* create(std::string& name);
-            ClassName* getClassName(std::string& name);
-            ClassName* getClassName(std::string& name, ClassName* root);
-            ClassName* getRootClass() { return this->rootClass; }
-            void setRootClass(ClassName* className) { this->rootClass = className; }
+            ObjectListElement(BaseObject* object);
 
-        private:
-            ClassNameTree();
-            ~ClassNameTree();
-            static ClassNameTree *pointer;
-            ClassName* rootClass;
+            BaseObject* object_;
+            ObjectListElement* next_;
     };
 
 
-    #define className(ClassName) \
-        ClassNameSingleton<ClassName>::getNewClassName()
+    // ##### Macros #####
+    #define registerRootObject(ClassName) \
+        this->parents_ = new IdentifierList(); \
+        this->identifier_ = ClassIdentifier<ClassName>::registerClass(this->parents_); \
+        this->parents_->add(this->identifier_); \
+        this->identifier_->addObject(this)
 
-    #define registerObject(ClassName, bIsRootClass) \
-        this->className = ClassNameSingleton<ClassName>::getClassName(this, bIsRootClass)
+    #define registerObject(ClassName) \
+        this->identifier_->removeObject(this); \
+        this->identifier_ = ClassIdentifier<ClassName>::registerClass(this->parents_); \
+        this->parents_->add(this->identifier_); \
+        this->identifier_->addObject(this)
 
     #define unregisterObject() \
-        this->className->objects->remove(this)
+        delete this->parents_; \
+        this->identifier_->removeObject(this)
 
-    #define factory(ClassName) \
-        ClassNameTree::getSingleton()->create(ClassName)
-//}
+    #define Class(ClassName) \
+        ClassIdentifier<ClassName>::getIdentifier()
+
+    #define Factory(ClassName) \
+        ClassIdentifier<ClassName>::create()
+}
 
 #endif
