Orxonox  0.0.5 Codename: Arcturus
ObjectList.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 
44 #ifndef _ObjectList_H__
45 #define _ObjectList_H__
46 
47 #include "core/CorePrereqs.h"
48 
49 #include "ObjectListBase.h"
50 #include "ObjectListIterator.h"
51 #include "Context.h"
52 
53 namespace orxonox
54 {
55  // ###############################
56  // ### ObjectList ###
57  // ###############################
65  template <class T>
66  class ObjectList
67  {
68  static_assert(std::is_base_of<Listable, T>::value, "ObjectList can only be used with Listables");
69 
70  public:
72 
73  ObjectList() : ObjectList(Context::getRootContext()) {}
74  ObjectList(Context* context) : ObjectList(context->getObjectList<T>()) {}
75  ObjectList(ObjectListBase* list) : list_(list) {}
76 
78  inline size_t size()
79  { return this->list_->size(); }
80 
83  { return static_cast<ObjectListElement<T>*>(this->list_->begin()); }
86  { return static_cast<ObjectListElement<T>*>(this->list_->end()); }
87 
90  { return static_cast<ObjectListElement<T>*>(this->list_->rbegin()); }
93  { return static_cast<ObjectListElement<T>*>(this->list_->rend()); }
94 
95  private:
97  };
98 }
99 
100 #endif /* _ObjectList_H__ */
ObjectListBaseElement * rbegin() const
Returns a pointer to the last element in the list. Works only with Iterator.
Definition: ObjectListBase.h:141
The list-element that actually contains the object.
Definition: CorePrereqs.h:208
ObjectList(Context *context)
Definition: ObjectList.h:74
ObjectListIterator< T > begin()
Returns an Iterator to the first element in the list.
Definition: ObjectList.h:82
Declaration of the ObjectListBase class which stores all objects of each class.
Shared library macros, enums, constants and forward declarations for the core library ...
ObjectListBaseElement * end() const
Returns a pointer to the element after the last element in the list. Works only with Iterator...
Definition: ObjectListBase.h:139
The ObjectListBase contains all objects of a given class.
Definition: ObjectListBase.h:125
ObjectListBaseElement * begin() const
Returns a pointer to the first element in the list. Works only with Iterator.
Definition: ObjectListBase.h:137
Definition of the ObjectListIterator class, used to iterate through object-lists. ...
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
ObjectListBase * list_
Definition: ObjectList.h:96
ObjectList(ObjectListBase *list)
Definition: ObjectList.h:75
ObjectListIterator< T > end()
Returns an Iterator to the element after the last element in the list.
Definition: ObjectList.h:85
Definition: InputPrereqs.h:78
ObjectListIterator< T > iterator
Definition: ObjectList.h:68
The ObjectList contains all objects of the given class.
Definition: CorePrereqs.h:204
Definition: Context.h:45
size_t size() const
Definition: ObjectListBase.h:134
ObjectList()
Definition: ObjectList.h:73
ObjectListBaseElement * rend() const
Returns a pointer to the element in front of the first element in the list. Works only with Iterator...
Definition: ObjectListBase.h:143
ObjectListIterator< T > rend()
Returns an Iterator to the element before the first element in the list.
Definition: ObjectList.h:92
ObjectListIterator< T > rbegin()
Returns an Iterator to the last element in the list.
Definition: ObjectList.h:89
ObjectListIterator<T> allows to iterate through the ObjectList of class T.
Definition: CorePrereqs.h:210
size_t size()
Returns the size of the list.
Definition: ObjectList.h:78