Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 12, 2008, 10:53:51 PM (16 years ago)
Author:
landauf
Message:
  • added feature to add a callback function to configvalues. they get called if the value changes. an examples is in Core.cc.
  • changed the SetConfigValue macro and the Identifier::updateConfigValues() function to work properly with inherited classes in both possible cases: 1) they overwrite the config-value or 2) they don't. an example is ParticleProjectile that defines it's own speed_ configvalue.
File:
1 edited

Legend:

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

    r1592 r1596  
    6161
    6262#include "MetaObjectList.h"
    63 #include "ObjectListBase.h"
     63#include "Iterator.h"
    6464#include "util/Debug.h"
    6565#include "util/String.h"
     
    112112            void setName(const std::string& name);
    113113
    114             void updateConfigValues() const;
     114            virtual void updateConfigValues(bool updateChildren = true) const = 0;
    115115
    116116            /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */
     
    301301            static bool isFirstCall();
    302302            void addObject(T* object);
     303
     304            void updateConfigValues(bool updateChildren = true) const;
    303305
    304306            XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
     
    417419        COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
    418420        object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
     421    }
     422
     423    /**
     424        @brief Updates the config-values of all existing objects of this class by calling their setConfigValues() function.
     425    */
     426    template <class T>
     427    void ClassIdentifier<T>::updateConfigValues(bool updateChildren) const
     428    {
     429        if (!this->hasConfigValues())
     430            return;
     431
     432        for (ObjectListIterator<T> it = ObjectList<T>::begin(); it; ++it)
     433            it->setConfigValues();
     434
     435        if (updateChildren)
     436            for (std::set<const Identifier*>::const_iterator it = this->getChildrenBegin(); it != this->getChildrenEnd(); ++it)
     437                (*it)->updateConfigValues(false);
    419438    }
    420439
Note: See TracChangeset for help on using the changeset viewer.