Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 25, 2007, 7:19:54 PM (16 years ago)
Author:
landauf
Message:

added "MetaObjectList", containing the list-element of the ObjectList of all classes an object is registered in. this allowes much faster deleting of objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchie/src/Identifier.h

    r244 r246  
    88#include "Factory.h"
    99
    10 #define HIERARCHY_VERBOSE true
     10#define HIERARCHY_VERBOSE false
    1111
    1212
     
    3030
    3131        public:
    32             virtual void removeObject(OrxonoxClass* object) const = 0;
    33             virtual void removeObjectIntern(OrxonoxClass* object, bool bIterateForwards) const = 0;
    34 
    3532            inline void addFactory(BaseFactory* factory) { this->factory_ = factory; }
    3633            BaseObject* fabricate();
     
    9390            static ClassIdentifier<T>* getIdentifier();
    9491            static void addObject(T* object);
    95             void removeObject(OrxonoxClass* object) const;
    96             void removeObjectIntern(OrxonoxClass* object, bool bIterateForwards) const;
    9792
    9893        private:
     
    172167        std::cout << "*** Added object to " << ClassIdentifier<T>::getIdentifier()->getName() << "-list.\n";
    173168#endif
    174         ClassIdentifier<T>::getIdentifier()->objects_->add(object);
    175     }
    176 
    177     template <class T>
    178     void ClassIdentifier<T>::removeObject(OrxonoxClass* object) const
    179     {
    180         bool bIterateForwards = !Identifier::isCreatingHierarchy();
    181 
    182         this->removeObjectIntern(object, bIterateForwards);
    183 
    184         IdentifierListElement* temp = this->parents_.first_;
    185         while (temp)
    186         {
    187             temp->identifier_->removeObjectIntern(object, bIterateForwards);
    188             temp = temp->next_;
    189         }
    190     }
    191 
    192     template <class T>
    193     void ClassIdentifier<T>::removeObjectIntern(OrxonoxClass* object, bool bIterateForwards) const
    194     {
    195 #if HIERARCHY_VERBOSE
    196         if (bIterateForwards)
    197             std::cout << "*** Removed object from " << this->name_ << "-list, iterating forwards.\n";
    198         else
    199             std::cout << "*** Removed object from " << this->name_ << "-list, iterating backwards.\n";
    200 #endif
    201 
    202         this->objects_->remove(object, bIterateForwards);
     169        object->getMetaList()->add(ClassIdentifier<T>::getIdentifier()->objects_, ClassIdentifier<T>::getIdentifier()->objects_->add(object));
    203170    }
    204171
Note: See TracChangeset for help on using the changeset viewer.