[1505] | 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 | |
---|
| 29 | /** |
---|
[2171] | 30 | @file |
---|
[1505] | 31 | @brief Definition and implementation of the ObjectList class. |
---|
| 32 | |
---|
[1747] | 33 | The ObjectList is a wrapper of an ObjectListBase of a given class. |
---|
[1505] | 34 | Use Iterator<class> to iterate through all objects of the class. |
---|
| 35 | */ |
---|
| 36 | |
---|
| 37 | #ifndef _ObjectList_H__ |
---|
| 38 | #define _ObjectList_H__ |
---|
| 39 | |
---|
| 40 | #include "CorePrereqs.h" |
---|
| 41 | |
---|
[1543] | 42 | #include "Identifier.h" |
---|
[7278] | 43 | #include "ObjectListBase.h" |
---|
[1747] | 44 | #include "ObjectListIterator.h" |
---|
[1505] | 45 | |
---|
| 46 | namespace orxonox |
---|
| 47 | { |
---|
| 48 | // ############################### |
---|
| 49 | // ### ObjectList ### |
---|
| 50 | // ############################### |
---|
[1747] | 51 | //! The ObjectList contains all objects of the given class. |
---|
[1505] | 52 | /** |
---|
[1747] | 53 | Wraps the ObjectListBase of the corresponding Identifier. |
---|
| 54 | Use ObjectListIterator<class> to iterate through all objects in the list. |
---|
[1505] | 55 | */ |
---|
| 56 | template <class T> |
---|
| 57 | class ObjectList |
---|
| 58 | { |
---|
| 59 | public: |
---|
[1747] | 60 | typedef ObjectListIterator<T> iterator; |
---|
[1505] | 61 | |
---|
[1747] | 62 | /** @brief Returns an Iterator to the first element in the list. @return The Iterator */ |
---|
| 63 | inline static ObjectListElement<T>* begin() |
---|
[7271] | 64 | { |
---|
| 65 | ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects(); |
---|
| 66 | return static_cast<ObjectListElement<T>*>(list->begin().element_); |
---|
| 67 | } |
---|
[1505] | 68 | |
---|
[1747] | 69 | /** @brief Returns an Iterator to the element after the last element in the list. @return The Iterator */ |
---|
| 70 | inline static ObjectListElement<T>* end() |
---|
[7271] | 71 | { |
---|
| 72 | ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects(); |
---|
| 73 | return static_cast<ObjectListElement<T>*>(list->end().element_); |
---|
| 74 | } |
---|
[1505] | 75 | |
---|
[1747] | 76 | /** @brief Returns an Iterator to the last element in the list. @return The Iterator */ |
---|
| 77 | inline static ObjectListElement<T>* rbegin() |
---|
[7271] | 78 | { |
---|
| 79 | ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects(); |
---|
| 80 | return static_cast<ObjectListElement<T>*>(list->rbegin().element_); |
---|
| 81 | } |
---|
[1505] | 82 | |
---|
[1747] | 83 | /** @brief Returns an Iterator to the element before the first element in the list. @return The Iterator */ |
---|
| 84 | inline static ObjectListElement<T>* rend() |
---|
[7271] | 85 | { |
---|
| 86 | ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects(); |
---|
| 87 | return static_cast<ObjectListElement<T>*>(list->rend().element_); |
---|
| 88 | } |
---|
[1505] | 89 | }; |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | #endif /* _ObjectList_H__ */ |
---|