Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/doc/src/libraries/core/ObjectList.h @ 7363

Last change on this file since 7363 was 7363, checked in by landauf, 14 years ago

assigned a group to each header file in the core library

  • 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 and implementation of the ObjectList class.
38
39    The ObjectList is a wrapper of an ObjectListBase of a given class.
40    Use Iterator<class> to iterate through all objects of the class.
41*/
42
43#ifndef _ObjectList_H__
44#define _ObjectList_H__
45
46#include "CorePrereqs.h"
47
48#include "Identifier.h"
49#include "ObjectListBase.h"
50#include "ObjectListIterator.h"
51
52namespace orxonox
53{
54    // ###############################
55    // ###       ObjectList        ###
56    // ###############################
57    //! The ObjectList contains all objects of the given class.
58    /**
59        Wraps the ObjectListBase of the corresponding Identifier.
60        Use ObjectListIterator<class> to iterate through all objects in the list.
61    */
62    template <class T>
63    class ObjectList
64    {
65        public:
66            typedef ObjectListIterator<T> iterator;
67
68            /** @brief Returns an Iterator to the first element in the list. @return The Iterator */
69            inline static ObjectListElement<T>* begin()
70            {
71                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
72                return static_cast<ObjectListElement<T>*>(list->begin().element_);
73            }
74
75            /** @brief Returns an Iterator to the element after the last element in the list. @return The Iterator */
76            inline static ObjectListElement<T>* end()
77            {
78                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
79                return static_cast<ObjectListElement<T>*>(list->end().element_);
80            }
81
82            /** @brief Returns an Iterator to the last element in the list. @return The Iterator */
83            inline static ObjectListElement<T>* rbegin()
84            {
85                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
86                return static_cast<ObjectListElement<T>*>(list->rbegin().element_);
87            }
88
89            /** @brief Returns an Iterator to the element before the first element in the list. @return The Iterator */
90            inline static ObjectListElement<T>* rend()
91            {
92                ObjectListBase* list = ClassIdentifier<T>::getIdentifier()->getObjects();
93                return static_cast<ObjectListElement<T>*>(list->rend().element_);
94            }
95    };
96}
97
98#endif /* _ObjectList_H__ */
Note: See TracBrowser for help on using the repository browser.