Orxonox  0.0.5 Codename: Arcturus
Iterator.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Fabian 'x3n' Landau
24  * Co-authors:
25  * ...
26  *
27  */
28 
53 #ifndef _Iterator_H__
54 #define _Iterator_H__
55 
56 #include "core/CorePrereqs.h"
57 
58 #include "ObjectListBase.h"
59 #include "IteratorBase.h"
60 
61 namespace orxonox
62 {
71  template <class T>
72  class Iterator : public IteratorBase<T, Iterator<T>>
73  {
74  public:
78  inline Iterator() : IteratorBase<T, Iterator<T>>() {}
79 
84  template <class OT, class OI>
85  inline Iterator(const IteratorBase<OT, OI>& other) : IteratorBase<T, Iterator<T>>(other) {}
86 
92  {
93  this->setElement(element);
94  return (*this);
95  }
96 
101  inline T* operator*() const
102  {
103  return orxonox_cast<T*>(this->element_->objectBase_);
104  }
105 
110  inline T* operator->() const
111  {
112  return orxonox_cast<T*>(this->element_->objectBase_);
113  }
114  };
115 }
116 
117 #endif /* _Iterator_H__ */
The Iterator allows to iterate through a given ObjectList.
Definition: CorePrereqs.h:192
Declaration of the ObjectListBase class which stores all objects of each class.
Listable * objectBase_
The object.
Definition: ObjectListBase.h:66
Shared library macros, enums, constants and forward declarations for the core library ...
Definition of the IteratorBase class, used to iterate through object-lists.
void setElement(ObjectListBaseElement *element)
Definition: IteratorBase.h:189
ObjectListBaseElement * element_
The element the Iterator points at.
Definition: IteratorBase.h:219
T * operator->() const
Overloading of the it-> operator: returns the pointer to the object.
Definition: Iterator.h:110
The Iterator allows to iterate through object lists.
Definition: IteratorBase.h:49
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
ORX_FORCEINLINE T orxonox_cast(U *source)
Casts on object of type Identifiable to any derived type that is registered in the class hierarchy...
Definition: Identifier.h:485
T * operator*() const
Overloading of the *it operator: returns the pointer to the object.
Definition: Iterator.h:101
Definition: InputPrereqs.h:78
Iterator()
Constructor: Sets the element, whereon the iterator points, to zero.
Definition: Iterator.h:78
Iterator(const IteratorBase< OT, OI > &other)
Constructor: Sets this element to the element of another Iterator.
Definition: Iterator.h:85
The list-element of the ObjectListBase.
Definition: ObjectListBase.h:52
Iterator< T > & operator=(ObjectListBaseElement *element)
Assigns a given element.
Definition: Iterator.h:91