Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core6/src/libraries/core/object/ObjectList.h @ 9557

Last change on this file since 9557 was 9557, checked in by landauf, 11 years ago

moved all files in core which are used for object management to a new subdirectory (core/object/)

  • Property svn:eol-style set to native
File size: 3.4 KB
Line 
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/**
30    @defgroup ObjectList Object-lists and iterators
31    @ingroup Object
32*/
33
34/**
35    @file
36    @ingroup Object ObjectList
37    @brief Definition of the ObjectList class, a wrapper of ObjectListBase.
38
39    @ref orxonox::ObjectList "ObjectList<T>" is a wrapper of an @ref orxonox::ObjectListBase
40    "ObjectListBase" of class @a T. Use @ref orxonox::ObjectListIterator "ObjectListIterator<T>"
41    to iterate through the list.
42*/
43
44#ifndef _ObjectList_H__
45#define _ObjectList_H__
46
47#include "core/CorePrereqs.h"
48
49#include "ObjectListBase.h"
50#include "ObjectListIterator.h"
51
52namespace orxonox
53{
54    // ###############################
55    // ###       ObjectList        ###
56    // ###############################
57    /**
58        @brief The ObjectList contains all objects of the given class.
59
60        Wraps the ObjectListBase which contains all objects of type @a T. Use @ref ObjectListIterator
61        "ObjectListIterator<T>" or its typedef ObjectList<T>::iterator to iterate through all objects
62        in the list.
63    */
64    template <class T>
65    class ObjectList
66    {
67        public:
68            typedef ObjectListIterator<T> iterator;
69
70            /// Returns an Iterator to the first element in the list.
71            inline static ObjectListElement<T>* begin()
72            {
73                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
74                return static_cast<ObjectListElement<T>*>(list->begin().element_);
75            }
76
77            /// Returns an Iterator to the element after the last element in the list.
78            inline static ObjectListElement<T>* end()
79            {
80                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
81                return static_cast<ObjectListElement<T>*>(list->end().element_);
82            }
83
84            /// Returns an Iterator to the last element in the list.
85            inline static ObjectListElement<T>* rbegin()
86            {
87                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
88                return static_cast<ObjectListElement<T>*>(list->rbegin().element_);
89            }
90
91            /// Returns an Iterator to the element before the first element in the list.
92            inline static ObjectListElement<T>* rend()
93            {
94                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
95                return static_cast<ObjectListElement<T>*>(list->rend().element_);
96            }
97    };
98}
99
100#endif /* _ObjectList_H__ */
Note: See TracBrowser for help on using the repository browser.