Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 4, 2015, 9:12:21 PM (9 years ago)
Author:
landauf
Message:

merged branch core7 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/object/ObjectList.h

    r9667 r10624  
    4747#include "core/CorePrereqs.h"
    4848
     49#include <boost/static_assert.hpp>
     50#include <boost/type_traits/is_base_of.hpp>
     51
    4952#include "ObjectListBase.h"
    5053#include "ObjectListIterator.h"
     
    6669    class ObjectList
    6770    {
     71        BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value));
     72
    6873        public:
    6974            typedef ObjectListIterator<T> iterator;
    7075
     76            /// Returns the size of the list (for the root context)
     77            inline static size_t size()
     78            {   return size(Context::getRootContext());   }
    7179            /// Returns the size of the list
    72             inline static size_t size()
     80            inline static size_t size(Context* context)
    7381            {
    74                 return Context::getRootContext()->getObjectList<T>()->size();
     82                return context->getObjectList<T>()->size();
    7583            }
    7684
     85            /// Returns an Iterator to the first element in the list (for the root context).
     86            inline static ObjectListElement<T>* begin()
     87            {   return begin(Context::getRootContext());   }
    7788            /// Returns an Iterator to the first element in the list.
    78             inline static ObjectListElement<T>* begin()
     89            inline static ObjectListElement<T>* begin(Context* context)
    7990            {
    80                 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
     91                ObjectListBase* list = context->getObjectList<T>();
    8192                return static_cast<ObjectListElement<T>*>(list->begin());
    8293            }
    8394
     95            /// Returns an Iterator to the element after the last element in the list (for the root context).
     96            inline static ObjectListElement<T>* end()
     97            {   return end(Context::getRootContext());   }
    8498            /// Returns an Iterator to the element after the last element in the list.
    85             inline static ObjectListElement<T>* end()
     99            inline static ObjectListElement<T>* end(Context* context)
    86100            {
    87                 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
     101                ObjectListBase* list = context->getObjectList<T>();
    88102                return static_cast<ObjectListElement<T>*>(list->end());
    89103            }
    90104
     105            /// Returns an Iterator to the last element in the list (for the root context).
     106            inline static ObjectListElement<T>* rbegin()
     107            {   return rbegin(Context::getRootContext());   }
    91108            /// Returns an Iterator to the last element in the list.
    92             inline static ObjectListElement<T>* rbegin()
     109            inline static ObjectListElement<T>* rbegin(Context* context)
    93110            {
    94                 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
     111                ObjectListBase* list = context->getObjectList<T>();
    95112                return static_cast<ObjectListElement<T>*>(list->rbegin());
    96113            }
    97114
     115            /// Returns an Iterator to the element before the first element in the list (for the root context).
     116            inline static ObjectListElement<T>* rend()
     117            {   return rend(Context::getRootContext());   }
    98118            /// Returns an Iterator to the element before the first element in the list.
    99             inline static ObjectListElement<T>* rend()
     119            inline static ObjectListElement<T>* rend(Context* context)
    100120            {
    101                 ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
     121                ObjectListBase* list = context->getObjectList<T>();
    102122                return static_cast<ObjectListElement<T>*>(list->rend());
    103123            }
Note: See TracChangeset for help on using the changeset viewer.