Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 23, 2009, 8:14:46 PM (16 years ago)
Author:
rgrieder
Message:

Removed three macros: Two (ClassByString and ClassByID) by replacing them with an equivalent inline function and the other one by moving some macro-code to an actual function. Most of what RegisterObject() does can simply be done within a template function in the ClassIdentifier.
Also removed some mysterious public functions of OrxonoxClass (WorldEntity::getParents() doesn't exactly do what you would expect) that only served internal purposes. Instead the ClassIdentifier became a friend of OrxonoxClass and now does the necessary work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/core/Identifier.h

    r3223 r3224  
    349349            static ClassIdentifier<T> *getIdentifier();
    350350            static ClassIdentifier<T> *getIdentifier(const std::string& name);
    351             void addObject(T* object);
     351
     352            bool initialiseObject(T* object, const std::string& className, bool bRootClass);
    352353
    353354            void updateConfigValues(bool updateChildren = true) const;
     
    428429    */
    429430    template <class T>
    430     inline void ClassIdentifier<T>::addObject(T* object)
    431     {
    432         COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
    433         object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
    434         // Add pointer of type T to the map in the OrxonoxClass instance that enables "dynamic_casts"
    435         object->objectPointers_.push_back(std::make_pair(this->getClassID(), reinterpret_cast<void*>(object)));
     431    bool ClassIdentifier<T>::initialiseObject(T* object, const std::string& className, bool bRootClass)
     432    {
     433        if (bRootClass)
     434            COUT(5) << "*** Register Root-Object: " << className << std::endl;
     435        else
     436            COUT(5) << "*** Register Object: " << className << std::endl;
     437
     438        object->identifier_ = this;
     439        if (Identifier::isCreatingHierarchy())
     440        {
     441            if (bRootClass && !object->parents_)
     442                object->parents_ = new std::set<const Identifier*>();
     443
     444            if (object->parents_)
     445            {
     446                this->initializeClassHierarchy(object->parents_, bRootClass);
     447                object->parents_->insert(object->parents_->end(), this);
     448            }
     449
     450            object->setConfigValues();
     451            return true;
     452        }
     453        else
     454        {
     455            COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
     456            object->metaList_->add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
     457
     458            // Add pointer of type T to the map in the OrxonoxClass instance that enables "dynamic_casts"
     459            object->objectPointers_.push_back(std::make_pair(this->getClassID(), reinterpret_cast<void*>(object)));
     460            return false;
     461        }
    436462    }
    437463
Note: See TracChangeset for help on using the changeset viewer.