Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9593


Ignore:
Timestamp:
Mar 27, 2013, 11:17:45 PM (12 years ago)
Author:
landauf
Message:

moved logic to remove an element from an ObjectListBase from MetaObjectList to ObjectListBase

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

Legend:

Unmodified
Added
Removed
  • code/branches/core6/src/libraries/core/class/Identifier.cc

    r9564 r9593  
    5252        : classID_(IdentifierManager::classIDCounter_s++)
    5353    {
    54         this->objects_ = new ObjectListBase(this);
     54        this->objects_ = new ObjectListBase();
    5555
    5656        this->bCreatedOneObject_ = false;
  • code/branches/core6/src/libraries/core/class/Identifier.h

    r9586 r9593  
    428428    {
    429429        orxout(verbose, context::object_list) << "Added object to " << this->getName() << "-list." << endl;
    430         object->metaList_->add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
     430        object->metaList_->add(this->objects_, this->objects_->add(object));
    431431    }
    432432
  • code/branches/core6/src/libraries/core/object/MetaObjectList.cc

    r9563 r9593  
    4848    MetaObjectListElement::~MetaObjectListElement()
    4949    {
    50         orxout(verbose, context::object_list) << "Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << endl;
    51         this->list_->notifyIterators(this->element_->objectBase_);
    52 
    53         if (this->element_->next_)
    54             this->element_->next_->prev_ = this->element_->prev_;
    55         else
    56             this->list_->last_ = this->element_->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list
    57 
    58         if (this->element_->prev_)
    59             this->element_->prev_->next_ = this->element_->next_;
    60         else
    61             this->list_->first_ = this->element_->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list
    62 
     50        this->list_->removeElement(this->element_);
    6351        delete this->element_;
    6452    }
  • code/branches/core6/src/libraries/core/object/ObjectListBase.cc

    r9573 r9593  
    3636#include <set>
    3737#include "Iterator.h"
     38#include "Listable.h"
    3839#include "ObjectListIterator.h"
    3940
     
    4344        @brief Constructor: Sets default values.
    4445    */
    45     ObjectListBase::ObjectListBase(Identifier* identifier)
     46    ObjectListBase::ObjectListBase()
    4647    {
    47         this->identifier_ = identifier;
    4848        this->first_ = 0;
    4949        this->last_ = 0;
     
    8181        @return The pointer to the new ObjectListBaseElement, needed by the MetaObjectList of the added object
    8282    */
    83     ObjectListBaseElement* ObjectListBase::add(ObjectListBaseElement* element)
     83    ObjectListBaseElement* ObjectListBase::addElement(ObjectListBaseElement* element)
    8484    {
    8585        if (!this->last_)
     
    100100        return this->last_;
    101101    }
     102
     103    void ObjectListBase::removeElement(ObjectListBaseElement* element)
     104    {
     105        orxout(verbose, context::object_list) << "Removing Object from " << element->objectBase_->getIdentifier()->getName() << "-list." << endl;
     106        this->notifyIterators(element->objectBase_);
     107
     108        if (element->next_)
     109            element->next_->prev_ = element->prev_;
     110        else
     111            this->last_ = element->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list
     112
     113        if (element->prev_)
     114            element->prev_->next_ = element->next_;
     115        else
     116            this->first_ = element->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list
     117    }
    102118}
  • code/branches/core6/src/libraries/core/object/ObjectListBase.h

    r9573 r9593  
    9393    class _CoreExport ObjectListBase
    9494    {
    95         friend class MetaObjectListElement;
    96 
    9795        public:
    98             ObjectListBase(Identifier* identifier);
     96            ObjectListBase();
    9997            ~ObjectListBase();
    10098
    101             ObjectListBaseElement* add(ObjectListBaseElement* element);
     99            template <class T>
     100            inline ObjectListBaseElement* add(T* object)
     101                { return this->addElement(new ObjectListElement<T>(object)); }
     102
     103            ObjectListBaseElement* addElement(ObjectListBaseElement* element);
     104            void removeElement(ObjectListBaseElement* element);
    102105
    103106            /// Helper struct, used to export an element and the list to an instance of Iterator.
     
    144147            void notifyIterators(Listable* object) const;
    145148
    146             inline Identifier* getIdentifier() const { return this->identifier_; }
    147 
    148149        private:
    149             Identifier* identifier_;                 //!< The Iterator owning this list
    150150            ObjectListBaseElement* first_;           //!< The first element in the list
    151151            ObjectListBaseElement* last_;            //!< The last element in the list
Note: See TracChangeset for help on using the changeset viewer.