Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r10624 r11071  
    4747#include "core/CorePrereqs.h"
    4848
    49 #include <boost/static_assert.hpp>
    50 #include <boost/type_traits/is_base_of.hpp>
    51 
    5249#include "ObjectListBase.h"
    5350#include "ObjectListIterator.h"
     
    6966    class ObjectList
    7067    {
    71         BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value));
     68        static_assert(std::is_base_of<Listable, T>::value, "ObjectList can only be used with Listables");
    7269
    7370        public:
    7471            typedef ObjectListIterator<T> iterator;
    7572
    76             /// Returns the size of the list (for the root context)
    77             inline static size_t size()
    78             {   return size(Context::getRootContext());   }
     73            ObjectList() : ObjectList(Context::getRootContext()) {}
     74            ObjectList(Context* context) : ObjectList(context->getObjectList<T>()) {}
     75            ObjectList(ObjectListBase* list) : list_(list) {}
     76
    7977            /// Returns the size of the list
    80             inline static size_t size(Context* context)
    81             {
    82                 return context->getObjectList<T>()->size();
    83             }
     78            inline size_t size()
     79            {   return this->list_->size();   }
    8480
    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());   }
    8881            /// Returns an Iterator to the first element in the list.
    89             inline static ObjectListElement<T>* begin(Context* context)
    90             {
    91                 ObjectListBase* list = context->getObjectList<T>();
    92                 return static_cast<ObjectListElement<T>*>(list->begin());
    93             }
     82            inline ObjectListIterator<T> begin()
     83            {   return static_cast<ObjectListElement<T>*>(this->list_->begin());   }
     84            /// Returns an Iterator to the element after the last element in the list.
     85            inline ObjectListIterator<T> end()
     86            {   return static_cast<ObjectListElement<T>*>(this->list_->end());   }
    9487
    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());   }
    98             /// Returns an Iterator to the element after the last element in the list.
    99             inline static ObjectListElement<T>* end(Context* context)
    100             {
    101                 ObjectListBase* list = context->getObjectList<T>();
    102                 return static_cast<ObjectListElement<T>*>(list->end());
    103             }
     88            /// Returns an Iterator to the last element in the list.
     89            inline ObjectListIterator<T> rbegin()
     90            {   return static_cast<ObjectListElement<T>*>(this->list_->rbegin());   }
     91            /// Returns an Iterator to the element before the first element in the list.
     92            inline ObjectListIterator<T> rend()
     93            {   return static_cast<ObjectListElement<T>*>(this->list_->rend());   }
    10494
    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());   }
    108             /// Returns an Iterator to the last element in the list.
    109             inline static ObjectListElement<T>* rbegin(Context* context)
    110             {
    111                 ObjectListBase* list = context->getObjectList<T>();
    112                 return static_cast<ObjectListElement<T>*>(list->rbegin());
    113             }
    114 
    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());   }
    118             /// Returns an Iterator to the element before the first element in the list.
    119             inline static ObjectListElement<T>* rend(Context* context)
    120             {
    121                 ObjectListBase* list = context->getObjectList<T>();
    122                 return static_cast<ObjectListElement<T>*>(list->rend());
    123             }
     95        private:
     96            ObjectListBase* list_;
    12497    };
    12598}
Note: See TracChangeset for help on using the changeset viewer.