Index: code/branches/core6/src/libraries/core/object/Iterator.h
===================================================================
--- code/branches/core6/src/libraries/core/object/Iterator.h	(revision 9597)
+++ code/branches/core6/src/libraries/core/object/Iterator.h	(revision 9598)
@@ -57,4 +57,5 @@
 
 #include "ObjectListBase.h"
+#include "IteratorBase.h"
 
 namespace orxonox
@@ -69,5 +70,5 @@
     */
     template <class T>
-    class Iterator
+    class Iterator : public IteratorBase<T, Iterator<T> >
     {
         public:
@@ -75,9 +76,11 @@
                 @brief Constructor: Sets the element, whereon the iterator points, to zero.
             */
-            inline Iterator()
-            {
-                this->element_ = NULL;
-                this->list_ = NULL;
-            }
+            inline Iterator() : IteratorBase<T, Iterator<T> >(NULL) {}
+
+            /**
+                @brief Constructor: Sets this element to a given element
+                @param element The element
+            */
+            inline Iterator(ObjectListBaseElement* element) : IteratorBase<T, Iterator<T> >(element) {}
 
             /**
@@ -85,51 +88,5 @@
                 @param other The other Iterator
             */
-            inline Iterator(const Iterator<T>& other)
-            {
-                this->element_ = other.element_;
-                this->registerIterator();
-            }
-
-            /**
-                @brief Constructor: Sets this element to a given element
-                @param element The element
-            */
-            inline Iterator(ObjectListBaseElement* element)
-            {
-                this->element_ = element;
-                this->registerIterator();
-            }
-
-            /**
-                @brief Constructor: Sets this element to the element an ObjectListIterator.
-                @param other The ObjectListIterator
-            */
-            template <class O>
-            inline Iterator(const ObjectListIterator<O>& other)
-            {
-                this->element_ = other.element_;
-                this->registerIterator();
-            }
-
-            /**
-                @brief Unregisters the Iterator from the ObjectList.
-            */
-            inline ~Iterator()
-            {
-                this->unregisterIterator();
-            }
-
-            /**
-                @brief Assigns the element of another Iterator.
-                @param other The other Iterator
-            */
-            inline Iterator<T>& operator=(const Iterator<T>& other)
-            {
-                this->unregisterIterator();
-                this->element_ = other.element_;
-                this->registerIterator();
-
-                return (*this);
-            }
+            inline Iterator(const Iterator<T>& other) : IteratorBase<T, Iterator<T> >(other) {}
 
             /**
@@ -139,65 +96,6 @@
             inline Iterator<T>& operator=(ObjectListBaseElement* element)
             {
-                this->unregisterIterator();
-                this->element_ = element;
-                this->registerIterator();
-
+                this->setElement(element);
                 return (*this);
-            }
-
-            /**
-                @brief Assigns the element of an ObjectListIterator.
-                @param other The ObjectListIterator
-            */
-            template <class O>
-            inline Iterator<T>& operator=(const ObjectListIterator<O>& other)
-            {
-                this->unregisterIterator();
-                this->element_ = other.element_;
-                this->registerIterator();
-
-                return (*this);
-            }
-
-            /**
-                @brief Overloading of the ++it operator: Iterator points to the next object in the list.
-                @return The Iterator itself
-            */
-            inline const Iterator<T>& operator++()
-            {
-                this->element_ = this->element_->next_;
-                return *this;
-            }
-
-            /**
-                @brief Overloading of the it++ operator: Iterator points to the next object in the list.
-                @return The Iterator itself
-            */
-            inline Iterator<T> operator++(int)
-            {
-                Iterator<T> copy = *this;
-                this->element_ = this->element_->next_;
-                return copy;
-            }
-
-            /**
-                @brief Overloading of the --it operator: Iterator points to the previous object in the list.
-                @return The Iterator itself
-            */
-            inline const Iterator<T>& operator--()
-            {
-                this->element_ = this->element_->prev_;
-                return *this;
-            }
-
-            /**
-                @brief Overloading of the it-- operator: Iterator points to the previous object in the list.
-                @return The Iterator itself
-            */
-            inline Iterator<T> operator--(int i)
-            {
-                Iterator<T> copy = *this;
-                this->element_ = this->element_->prev_;
-                return copy;
             }
 
@@ -219,70 +117,4 @@
                 return orxonox_cast<T*>(this->element_->objectBase_);
             }
-
-            /**
-                @brief Overloading of the typecast-operator to bool: returns true if the iterator points to an existing object.
-                @return True if the Iterator points to an existing object.
-            */
-            inline operator bool() const
-            {
-                return (this->element_ != NULL);
-            }
-
-            /**
-                @brief Overloading of the == operator to compare with another Iterator.
-                @param compare The other Iterator
-                @return True if the iterators point to the same element
-            */
-            inline bool operator==(const Iterator<T>& compare) const
-            {
-                return (this->element_ == compare.element_);
-            }
-
-            /**
-                @brief Overloading of the != operator to compare with another Iterator.
-                @param compare The other Iterator
-                @return True if the iterators point to different elements
-            */
-            inline bool operator!=(const Iterator<T>& compare) const
-            {
-                return (this->element_ != compare.element_);
-            }
-
-            /**
-                @brief Increments the Iterator if it points at the given object.
-                @param object The object to compare with
-            */
-            inline void incrementIfEqual(Listable* object)
-            {
-                if (this->element_ && this->element_->objectBase_ == object)
-                    this->operator++();
-            }
-
-        private:
-            /**
-             * @brief Registers the Iterator at the list to which it belongs
-             */
-            inline void registerIterator()
-            {
-                if (this->element_)
-                {
-                    this->list_ = this->element_->list_;
-                    this->list_->registerIterator(this);
-                }
-                else
-                    this->list_ = NULL;
-            }
-
-            /**
-             * @brief Unregisters the Iterator from the list (if any)
-             */
-            inline void unregisterIterator()
-            {
-                if (this->list_)
-                    this->list_->unregisterIterator(this);
-            }
-
-            ObjectListBaseElement* element_;    //!< The element the Iterator points at
-            ObjectListBase* list_;              //!< The list in which the Iterator registered itself
     };
 }
Index: code/branches/core6/src/libraries/core/object/IteratorBase.h
===================================================================
--- code/branches/core6/src/libraries/core/object/IteratorBase.h	(revision 9598)
+++ code/branches/core6/src/libraries/core/object/IteratorBase.h	(revision 9598)
@@ -0,0 +1,216 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program 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 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program 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 this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @ingroup Object ObjectList
+    @brief Definition of the IteratorBase class, used to iterate through object-lists.
+*/
+
+#ifndef _IteratorBase_H__
+#define _IteratorBase_H__
+
+#include "core/CorePrereqs.h"
+
+#include "ObjectListBase.h"
+
+namespace orxonox
+{
+    /**
+        @brief The Iterator allows to iterate through object lists.
+        It serves as base class for @ref ObjectListIterator and @ref Iterator
+    */
+    template <class T, class I>
+    class IteratorBase
+    {
+        public:
+            /**
+                @brief Constructor: Sets the element, whereon the iterator points, to zero.
+            */
+            inline IteratorBase(ObjectListBaseElement* element)
+            {
+                this->element_ = element;
+                this->registerIterator();
+            }
+
+            /**
+                @brief Constructor: Sets this element to the element of another Iterator.
+                @param other The other Iterator
+            */
+            inline IteratorBase(const IteratorBase& other)
+            {
+                this->element_ = other.element_;
+                this->registerIterator();
+            }
+
+            /**
+                @brief Unregisters the Iterator from the ObjectList.
+            */
+            inline ~IteratorBase()
+            {
+                this->unregisterIterator();
+            }
+
+            /**
+                @brief Assigns a given element.
+                @param element The element
+            */
+            inline IteratorBase<T, I>& operator=(ObjectListElement<T>* element)
+            {
+                this->setElement(element);
+                return (*this);
+            }
+
+            /**
+                @brief Assigns the element of another Iterator.
+                @param other The other Iterator
+            */
+            inline IteratorBase<T, I>& operator=(const IteratorBase<T, I>& other)
+            {
+                this->setElement(other.element_);
+                return (*this);
+            }
+
+            /**
+                @brief Overloading of the ++it operator: Iterator points to the next object in the list.
+                @return The Iterator itself
+            */
+            inline const IteratorBase<T, I>& operator++()
+            {
+                this->element_ = this->element_->next_;
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the it++ operator: Iterator points to the next object in the list.
+                @return The Iterator itself
+            */
+            inline I operator++(int)
+            {
+                I copy = *this;
+                this->element_ = this->element_->next_;
+                return copy;
+            }
+
+            /**
+                @brief Overloading of the --it operator: Iterator points to the previous object in the list.
+                @return The Iterator itself
+            */
+            inline const IteratorBase<T, I>& operator--()
+            {
+                this->element_ = this->element_->prev_;
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the it-- operator: Iterator points to the previous object in the list.
+                @return The Iterator itself
+            */
+            inline I operator--(int i)
+            {
+                I copy = *this;
+                this->element_ = this->element_->prev_;
+                return copy;
+            }
+
+            /**
+                @brief Overloading of the typecast-operator to bool: returns true if the iterator points to an existing object.
+                @return True if the Iterator points to an existing object.
+            */
+            inline operator bool() const
+            {
+                return (this->element_ != NULL);
+            }
+
+            /**
+                @brief Overloading of the == operator to compare with another Iterator.
+                @param compare The other Iterator
+                @return True if the iterators point to the same element
+            */
+            inline bool operator==(const IteratorBase<T, I>& compare) const
+            {
+                return (this->element_ == compare.element_);
+            }
+
+            /**
+                @brief Overloading of the != operator to compare with another Iterator.
+                @param compare The other Iterator
+                @return True if the iterators point to different elements
+            */
+            inline bool operator!=(const IteratorBase<T, I>& compare) const
+            {
+                return (this->element_ != compare.element_);
+            }
+
+            /**
+                @brief Increments the Iterator if it points at the given object.
+                @param object The object to compare with
+            */
+            inline void incrementIfEqual(Listable* object)
+            {
+                if (this->element_ && this->element_->objectBase_ == object)
+                    this->operator++();
+            }
+
+        protected:
+            inline void setElement(ObjectListBaseElement* element)
+            {
+                this->unregisterIterator();
+                this->element_ = element;
+                this->registerIterator();
+            }
+
+            /**
+             * @brief Registers the Iterator at the list to which it belongs
+             */
+            inline void registerIterator()
+            {
+                if (this->element_)
+                {
+                    this->list_ = this->element_->list_;
+                    this->list_->registerIterator(this);
+                }
+                else
+                    this->list_ = NULL;
+            }
+
+            /**
+             * @brief Unregisters the Iterator from the list (if any)
+             */
+            inline void unregisterIterator()
+            {
+                if (this->list_)
+                    this->list_->unregisterIterator(this);
+            }
+
+            ObjectListBaseElement* element_;    //!< The element the Iterator points at
+            ObjectListBase* list_;              //!< The list in which the Iterator registered itself
+    };
+}
+
+#endif /* _IteratorBase_H__ */
Index: code/branches/core6/src/libraries/core/object/ObjectListIterator.h
===================================================================
--- code/branches/core6/src/libraries/core/object/ObjectListIterator.h	(revision 9597)
+++ code/branches/core6/src/libraries/core/object/ObjectListIterator.h	(revision 9598)
@@ -58,4 +58,5 @@
 #include "core/class/Identifier.h"
 #include "ObjectList.h"
+#include "IteratorBase.h"
 
 namespace orxonox
@@ -67,5 +68,5 @@
     */
     template <class T>
-    class ObjectListIterator
+    class ObjectListIterator : public IteratorBase<T, ObjectListIterator<T> >
     {
         template <class I>
@@ -76,9 +77,5 @@
                 @brief Constructor: Sets the element, whereon the ObjectListIterator points, to zero.
             */
-            inline ObjectListIterator()
-            {
-                this->element_ = 0;
-                ClassIdentifier<T>::getIdentifier()->getObjects()->registerObjectListIterator(this);
-            }
+            inline ObjectListIterator() : IteratorBase<T, ObjectListIterator<T> >(NULL) {}
 
             /**
@@ -86,9 +83,5 @@
                 @param element The element to start with
             */
-            inline ObjectListIterator(ObjectListElement<T>* element)
-            {
-                this->element_ = element;
-                ClassIdentifier<T>::getIdentifier()->getObjects()->registerObjectListIterator(this);
-            }
+            inline ObjectListIterator(ObjectListElement<T>* element) : IteratorBase<T, ObjectListIterator<T> >(element) {}
 
             /**
@@ -96,79 +89,5 @@
                 @param other The other ObjectListIterator
             */
-            inline ObjectListIterator(const ObjectListIterator<T>& other)
-            {
-                this->element_ = other.element_;
-                ClassIdentifier<T>::getIdentifier()->getObjects()->registerObjectListIterator(this);
-            }
-
-            /**
-                @brief Unregisters the ObjectListIterator from the ObjectList.
-            */
-            inline ~ObjectListIterator()
-            {
-                ClassIdentifier<T>::getIdentifier()->getObjects()->unregisterObjectListIterator(this);
-            }
-
-            /**
-                @brief Assigns an ObjectListElement.
-                @param element The ObjectListElement
-            */
-            inline ObjectListIterator<T>& operator=(ObjectListElement<T>* element)
-            {
-                this->element_ = element;
-                return (*this);
-            }
-
-            /**
-                @brief Assigns the element of another ObjectListIterator.
-                @param other The other ObjectListIterator
-            */
-            inline ObjectListIterator<T>& operator=(const ObjectListIterator<T>& other)
-            {
-                this->element_ = other.element_;
-                return (*this);
-            }
-
-            /**
-                @brief Overloading of the ++it operator: ObjectListIterator points to the next object in the list.
-                @return The ObjectListIterator itself
-            */
-            inline const ObjectListIterator<T>& operator++()
-            {
-                this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_);
-                return *this;
-            }
-
-            /**
-                @brief Overloading of the it++ operator: ObjectListIterator points to the next object in the list.
-                @return The ObjectListIterator itself
-            */
-            inline ObjectListIterator<T> operator++(int)
-            {
-                ObjectListIterator<T> copy = *this;
-                this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_);
-                return copy;
-            }
-
-            /**
-                @brief Overloading of the --it operator: ObjectListIterator points to the previous object in the list.
-                @return The ObjectListIterator itself
-            */
-            inline const ObjectListIterator<T>& operator--()
-            {
-                this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_);
-                return *this;
-            }
-
-            /**
-                @brief Overloading of the it-- operator: ObjectListIterator points to the previous object in the list.
-                @return The ObjectListIterator itself
-            */
-            inline ObjectListIterator<T> operator--(int i)
-            {
-                ObjectListIterator<T> copy = *this;
-                this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_);
-                return copy;
-            }
+            inline ObjectListIterator(const IteratorBase<T, ObjectListIterator<T> >& other) : IteratorBase<T, ObjectListIterator<T> >(other) {}
 
             /**
@@ -178,5 +97,5 @@
             inline T* operator*() const
             {
-                return this->element_->object_;
+                return static_cast<ObjectListElement<T>*>(this->element_)->object_;
             }
 
@@ -187,48 +106,6 @@
             inline T* operator->() const
             {
-                return this->element_->object_;
+                return static_cast<ObjectListElement<T>*>(this->element_)->object_;
             }
-
-            /**
-                @brief Overloading of the typecast-operator to bool: returns true if the ObjectListIterator points to an existing object.
-                @return True if the ObjectListIterator points to an existing object.
-            */
-            inline operator bool() const
-            {
-                return (this->element_ != 0);
-            }
-
-            /**
-                @brief Overloading of the == operator to compare with another ObjectListIterator.
-                @param compare The other ObjectListIterator
-                @return True if the ObjectListIterator point to the same element
-            */
-            inline bool operator==(const ObjectListIterator<T>& compare) const
-            {
-                return (this->element_ == compare.element_);
-            }
-
-            /**
-                @brief Overloading of the != operator to compare with another ObjectListIterator.
-                @param compare The other ObjectListIterator
-                @return True if the ObjectListIterator point to different elements
-            */
-            inline bool operator!=(const ObjectListIterator<T>& compare) const
-            {
-                return (this->element_ != compare.element_);
-            }
-
-            /**
-                @brief Increments the ObjectListIterator if it points at the given object.
-                @param object The object to compare with
-            */
-            inline void incrementIfEqual(Listable* object)
-            {
-                if (this->element_ && this->element_->objectBase_ == object)
-                    this->operator++();
-            }
-
-        private:
-            ObjectListElement<T>* element_;        //!< The element the iterator points at
     };
 }
