Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 6, 2015, 2:51:14 PM (9 years ago)
Author:
landauf
Message:

no static functions anymore in ObjectList. you need to instantiate an ObjectList to use it.
this allows for prettier for-loop syntax when iterating over an ObjectList of a specific context: for (T* object : ObjectList<T>(context)) { … }

Location:
code/branches/cpp11_v2/src/libraries/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/core/ClassTreeMask.cc

    r10919 r10920  
    851851            this->objectIterator_ = Context::getRootContext()->getObjectList(this->subclassIterator_->first)->begin();
    852852        else
    853             this->objectIterator_ = ObjectList<BaseObject>::end();
     853            this->objectIterator_ = ObjectList<BaseObject>().end();
    854854
    855855        // Check if the iterator points on a valid object. If not, go to the next object by calling ++
  • code/branches/cpp11_v2/src/libraries/core/Loader.cc

    r10917 r10920  
    207207        if (!file)
    208208            return;
    209         for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; )
     209        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>().begin(); it; )
    210210        {
    211211            if ((it->getFile() == file) && mask.isIncluded(it->getIdentifier()))
  • code/branches/cpp11_v2/src/libraries/core/class/Identifier.h

    r10919 r10920  
    415415    void ClassIdentifier<T>::destroyObjects(Listable*)
    416416    {
    417         ObjectListBase* objectList = Context::getRootContext()->getObjectList(this);
    418         ObjectListElement<T>* begin = static_cast<ObjectListElement<T>*>(objectList->begin());
    419         ObjectListElement<T>* end = static_cast<ObjectListElement<T>*>(objectList->end());
    420         for (typename ObjectList<T>::iterator it = begin; it != end; )
     417        ObjectList<T> list(Context::getRootContext()->getObjectList(this));
     418        for (typename ObjectList<T>::iterator it = list.begin(); it != list.end(); )
    421419            this->destroyObject(*(it++));
    422420    }
  • code/branches/cpp11_v2/src/libraries/core/object/ObjectList.h

    r10774 r10920  
    7171            typedef ObjectListIterator<T> iterator;
    7272
    73             /// Returns the size of the list (for the root context)
    74             inline static size_t size()
    75             {   return size(Context::getRootContext());   }
     73            ObjectList() : ObjectList(Context::getRootContext()) {}
     74            ObjectList(Context* context) : ObjectList(context->getObjectList<T>()) {}
     75            ObjectList(ObjectListBase* list) : list_(list) {}
     76
    7677            /// Returns the size of the list
    77             inline static size_t size(Context* context)
    78             {
    79                 return context->getObjectList<T>()->size();
    80             }
     78            inline size_t size()
     79            {   return this->list_->size();   }
    8180
    82             /// Returns an Iterator to the first element in the list (for the root context).
    83             inline static ObjectListIterator<T> begin()
    84             {   return begin(Context::getRootContext());   }
    8581            /// Returns an Iterator to the first element in the list.
    86             inline static ObjectListIterator<T> begin(Context* context)
    87             {
    88                 ObjectListBase* list = context->getObjectList<T>();
    89                 return static_cast<ObjectListElement<T>*>(list->begin());
    90             }
     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());   }
    9187
    92             /// Returns an Iterator to the element after the last element in the list (for the root context).
    93             inline static ObjectListIterator<T> end()
    94             {   return end(Context::getRootContext());   }
    95             /// Returns an Iterator to the element after the last element in the list.
    96             inline static ObjectListIterator<T> end(Context* context)
    97             {
    98                 ObjectListBase* list = context->getObjectList<T>();
    99                 return static_cast<ObjectListElement<T>*>(list->end());
    100             }
     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());   }
    10194
    102             /// Returns an Iterator to the last element in the list (for the root context).
    103             inline static ObjectListIterator<T> rbegin()
    104             {   return rbegin(Context::getRootContext());   }
    105             /// Returns an Iterator to the last element in the list.
    106             inline static ObjectListIterator<T> rbegin(Context* context)
    107             {
    108                 ObjectListBase* list = context->getObjectList<T>();
    109                 return static_cast<ObjectListElement<T>*>(list->rbegin());
    110             }
    111 
    112             /// Returns an Iterator to the element before the first element in the list (for the root context).
    113             inline static ObjectListIterator<T> rend()
    114             {   return rend(Context::getRootContext());   }
    115             /// Returns an Iterator to the element before the first element in the list.
    116             inline static ObjectListIterator<T> rend(Context* context)
    117             {
    118                 ObjectListBase* list = context->getObjectList<T>();
    119                 return static_cast<ObjectListElement<T>*>(list->rend());
    120             }
     95        private:
     96            ObjectListBase* list_;
    12197    };
    12298}
  • code/branches/cpp11_v2/src/libraries/core/object/ObjectListIterator.h

    r10769 r10920  
    4141    Usage:
    4242    @code
    43     for (ObjectListIterator<myClass> it = ObjectList<myClass>::begin(); it != ObjectList<myClass>::end(); ++it)
     43    ObjectList<myClass> list;
     44    for (ObjectListIterator<myClass> it = list.begin(); it != list.end(); ++it)
    4445    {
    4546        it->someFunction(...);
Note: See TracChangeset for help on using the changeset viewer.