Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 29, 2013, 12:42:24 AM (11 years ago)
Author:
landauf
Message:

ObjectListBaseElement now stores a pointer to the object list it belongs to. Removed ObjectListBase::Export. Iterator will now always use the list from the element.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core6/src/libraries/core/object/ObjectListBase.h

    r9593 r9596  
    5656                @param objectBase The object to store
    5757            */
    58             ObjectListBaseElement(Listable* objectBase) : next_(0), prev_(0), objectBase_(objectBase) {}
     58            ObjectListBaseElement(Listable* object, ObjectListBase* list) : next_(0), prev_(0), objectBase_(object), list_(list) {}
     59            ~ObjectListBaseElement();
    5960
    6061            ObjectListBaseElement* next_;       //!< The next element in the list
    6162            ObjectListBaseElement* prev_;       //!< The previous element in the list
    62             Listable* objectBase_;
     63            Listable* objectBase_;              //!< The object
     64            ObjectListBase* list_;              //!< The list
    6365    };
    6466
     
    7274    {
    7375        public:
    74             ObjectListElement(T* object) : ObjectListBaseElement(static_cast<Listable*>(object)), object_(object) {}
     76            ObjectListElement(T* object, ObjectListBase* list) : ObjectListBaseElement(static_cast<Listable*>(object), list), object_(object) {}
    7577            T* object_;              //!< The object
    7678    };
     
    99101            template <class T>
    100102            inline ObjectListBaseElement* add(T* object)
    101                 { return this->addElement(new ObjectListElement<T>(object)); }
     103                { return this->addElement(new ObjectListElement<T>(object, this)); }
    102104
    103105            ObjectListBaseElement* addElement(ObjectListBaseElement* element);
    104106            void removeElement(ObjectListBaseElement* element);
    105107
    106             /// Helper struct, used to export an element and the list to an instance of Iterator.
    107             struct Export
    108             {
    109                 Export(ObjectListBase* list, ObjectListBaseElement* element) : list_(list), element_(element) {}
    110                 ObjectListBase* list_;
    111                 ObjectListBaseElement* element_;
    112             };
    113 
    114108            /// Returns a pointer to the first element in the list. Works only with Iterator.
    115             inline Export begin() { return ObjectListBase::Export(this, this->first_); }
     109            inline ObjectListBaseElement* begin() { return this->first_; }
    116110            /// Returns a pointer to the element after the last element in the list. Works only with Iterator.
    117             inline Export end() { return ObjectListBase::Export(this, 0); }
     111            inline ObjectListBaseElement* end() { return 0; }
    118112            /// Returns a pointer to the last element in the list. Works only with Iterator.
    119             inline Export rbegin() { return ObjectListBase::Export(this, this->last_); }
     113            inline ObjectListBaseElement* rbegin() { return this->last_; }
    120114            /// Returns a pointer to the element in front of the first element in the list. Works only with Iterator.
    121             inline Export rend() { return ObjectListBase::Export(this, 0); }
     115            inline ObjectListBaseElement* rend() { return 0; }
    122116
    123117            inline void registerIterator(void* iterator) { this->iterators_.push_back(iterator); }
Note: See TracChangeset for help on using the changeset viewer.