/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Fabian 'x3n' Landau * Co-authors: * ... * */ /** @defgroup ObjectList Object-lists and iterators @ingroup Object */ /** @file @ingroup Object ObjectList @brief Definition of the ObjectList class, a wrapper of ObjectListBase. @ref orxonox::ObjectList "ObjectList" is a wrapper of an @ref orxonox::ObjectListBase "ObjectListBase" of class @a T. Use @ref orxonox::ObjectListIterator "ObjectListIterator" to iterate through the list. */ #ifndef _ObjectList_H__ #define _ObjectList_H__ #include "core/CorePrereqs.h" #include #include #include "ObjectListBase.h" #include "ObjectListIterator.h" #include "Context.h" namespace orxonox { // ############################### // ### ObjectList ### // ############################### /** @brief The ObjectList contains all objects of the given class. Wraps the ObjectListBase which contains all objects of type @a T. Use @ref ObjectListIterator "ObjectListIterator" or its typedef ObjectList::iterator to iterate through all objects in the list. */ template class ObjectList { BOOST_STATIC_ASSERT((boost::is_base_of::value)); public: typedef ObjectListIterator iterator; /// Returns the size of the list (for the root context) inline static size_t size() { return size(Context::getRootContext()); } /// Returns the size of the list inline static size_t size(Context* context) { return context->getObjectList()->size(); } /// Returns an Iterator to the first element in the list (for the root context). inline static ObjectListElement* begin() { return begin(Context::getRootContext()); } /// Returns an Iterator to the first element in the list. inline static ObjectListElement* begin(Context* context) { ObjectListBase* list = context->getObjectList(); return static_cast*>(list->begin()); } /// Returns an Iterator to the element after the last element in the list (for the root context). inline static ObjectListElement* end() { return end(Context::getRootContext()); } /// Returns an Iterator to the element after the last element in the list. inline static ObjectListElement* end(Context* context) { ObjectListBase* list = context->getObjectList(); return static_cast*>(list->end()); } /// Returns an Iterator to the last element in the list (for the root context). inline static ObjectListElement* rbegin() { return rbegin(Context::getRootContext()); } /// Returns an Iterator to the last element in the list. inline static ObjectListElement* rbegin(Context* context) { ObjectListBase* list = context->getObjectList(); return static_cast*>(list->rbegin()); } /// Returns an Iterator to the element before the first element in the list (for the root context). inline static ObjectListElement* rend() { return rend(Context::getRootContext()); } /// Returns an Iterator to the element before the first element in the list. inline static ObjectListElement* rend(Context* context) { ObjectListBase* list = context->getObjectList(); return static_cast*>(list->rend()); } }; } #endif /* _ObjectList_H__ */