Index: code/branches/core3/src/core/Iterator.h
===================================================================
--- code/branches/core3/src/core/Iterator.h	(revision 1573)
+++ code/branches/core3/src/core/Iterator.h	(revision 1574)
@@ -35,11 +35,9 @@
 
     Usage:
-    for (Iterator<class> it = ObjectList<class>::start(); it != 0; ++it)
+    for (Iterator<myClass> it = ObjectList<myClass>::begin(); it != ObjectList<myClass>::end(); ++it)
     {
         it->someFunction(...);
-        class* myObject = *it;
+        myClass* myObject = *it;
     }
-
-    Warning: Don't delete objects directly through the iterator.
 */
 
@@ -49,11 +47,11 @@
 #include "CorePrereqs.h"
 
-#include "ObjectList.h"
+#include "IteratorBase.h"
 
 namespace orxonox
 {
-    //! The iterator allows to iterate through an ObjectList of a given class.
+    //! The Iterator allows to iterate through the ObjectList of a given class.
     template <class T>
-    class Iterator
+    class Iterator : public IteratorBase
     {
         public:
@@ -61,7 +59,6 @@
                 @brief Constructor: Sets the element, whereon the iterator points, to zero.
             */
-            Iterator()
+            inline Iterator()
             {
-                this->element_ = 0;
                 ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this);
             }
@@ -71,7 +68,6 @@
                 @param element The element to start with
             */
-            Iterator(ObjectListElement<T>* element)
+            inline Iterator(ObjectListBaseElement* element) : IteratorBase((ObjectListBaseElement*)element)
             {
-                this->element_ = element;
                 ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this);
             }
@@ -80,16 +76,7 @@
                 @brief Unregisters the Iterator from the ObjectList.
             */
-            ~Iterator()
+            inline ~Iterator()
             {
                 ClassIdentifier<T>::getIdentifier()->getObjects()->unregisterIterator(this);
-            }
-
-            /**
-                @brief Assigns an element to the iterator.
-                @param element The element
-            */
-            Iterator<T> operator=(ObjectListElement<T>* element)
-            {
-                this->element_ = element;
             }
 
@@ -98,8 +85,7 @@
                 @return The Iterator itself
             */
-            Iterator<T> operator++()
+            inline Iterator<T> operator++()
             {
-                if (this->element_)
-                    this->element_ = this->element_->next_;
+                IteratorBase::operator++();
                 return *this;
             }
@@ -109,9 +95,8 @@
                 @return The Iterator itself
             */
-            Iterator<T> operator++(int i)
+            inline Iterator<T> operator++(int i)
             {
                 Iterator<T> copy = *this;
-                if (this->element_)
-                    this->element_ = this->element_->next_;
+                IteratorBase::operator++();
                 return copy;
             }
@@ -121,8 +106,7 @@
                 @return The Iterator itself
             */
-            Iterator<T> operator--()
+            inline Iterator<T> operator--()
             {
-                if (this->element_)
-                    this->element_ = this->element_->prev_;
+                IteratorBase::operator--();
                 return *this;
             }
@@ -132,9 +116,8 @@
                 @return The Iterator itself
             */
-            Iterator<T> operator--(int i)
+            inline Iterator<T> operator--(int i)
             {
                 Iterator<T> copy = *this;
-                if (this->element_)
-                    this->element_ = this->element_->prev_;
+                IteratorBase::operator--();
                 return copy;
             }
@@ -144,10 +127,7 @@
                 @return The object the Iterator points at
             */
-            T* operator*()
+            inline T* operator*()
             {
-                if (this->element_)
-                    return this->element_->object_;
-                else
-                    return 0;
+                return dynamic_cast<T*>(IteratorBase::operator*());
             }
 
@@ -156,36 +136,33 @@
                 @return The object the Iterator points at
             */
-            T* operator->() const
+            inline T* operator->() const
             {
-                if (this->element_)
-                    return this->element_->object_;
-                else
-                    return 0;
-
+                return dynamic_cast<T*>(IteratorBase::operator->());
             }
 
             /**
-                @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.
+                @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
             */
-            operator bool()
+            inline bool operator==(const Iterator<T>& compare)
             {
-                return (this->element_ != 0);
+                return (this->element_ == compare.element_);
             }
 
             /**
-                @brief Overloading of the (it != int) operator: Used for (it != 0) instead of typecast-operator to bool.
-                @param compare The integer (must be zero, everything else makes no sense).
-                @return True if the iterator points to an existing object.
+                @brief Overloading of the != operator to compare with another Iterator.
+                @param compare The other Iterator
+                @return True if the iterators point to different elements
             */
-            bool operator!=(ObjectListElement<T>* compare)
+            inline bool operator!=(const Iterator<T>& compare)
             {
-                return (this->element_ != compare);
+                return (this->element_ != compare.element_);
             }
-
-        private:
-            ObjectListElement<T>* element_;     //!< The element the Iterator points at
     };
 }
 
+// Include ObjectList.h so the user only has to include one file: Iterator.h
+#include "ObjectList.h"
+
 #endif /* _Iterator_H__ */
