Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6423 for code/trunk


Ignore:
Timestamp:
Dec 27, 2009, 12:09:08 AM (15 years ago)
Author:
rgrieder
Message:

Fixed bug that caused derived classes to list the base class's config values as well.
Introduced a new "ClassByObjecType" function that accepts a 'this' pointer and returns the correct identifier (not this→getIdentifier()!).

Location:
code/trunk/src/libraries/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/core/ConfigValueIncludes.h

    r6417 r6423  
    6363    inline ConfigValueContainer& setConfigValueGeneric(T* object, V* variable, ConfigFileType type, const std::string& sectionName, const std::string& entryName, const D& defaultValue)
    6464    {
    65         ConfigValueContainer* container = object->getIdentifier()->getConfigValueContainer(entryName);
     65        ConfigValueContainer* container = ClassIdentifier<T>::getIdentifier()->getConfigValueContainer(entryName);
    6666        if (!container)
    6767        {
    68             container = new ConfigValueContainer(type, object->getIdentifier(), sectionName, entryName, defaultValue, *variable);
    69             object->getIdentifier()->addConfigValueContainer(entryName, container);
     68            container = new ConfigValueContainer(type, ClassIdentifier<T>::getIdentifier(), sectionName, entryName, defaultValue, *variable);
     69            ClassIdentifier<T>::getIdentifier()->addConfigValueContainer(entryName, container);
    7070        }
    7171        return container->getValue(variable, object);
     
    113113    inline void resetConfigValueGeneric(T* object, V* variable, const std::string& entryName)
    114114    {
    115         ConfigValueContainer* container = object->getIdentifier()->getConfigValueContainer(entryName);
     115        ConfigValueContainer* container = ClassIdentifier<T>::getIdentifier()->getConfigValueContainer(entryName);
    116116        if (container)
    117117        {
     
    122122        {
    123123            COUT(2) << "Warning: Couldn't reset config-value '" << entryName << "' in class '"
    124                     << object->getIdentifier()->getName() << "', corresponding container doesn't exist." << std::endl;
     124                    << ClassIdentifier<T>::getIdentifier()->getName() << "', corresponding container doesn't exist." << std::endl;
    125125        }
    126126    }
     
    152152*/
    153153#define ModifyConfigValueGeneric(object, variable, entryName, modifier, ...) \
    154     if (orxonox::ConfigValueContainer* container = object->getIdentifier()->getConfigValueContainer(entryName)) \
     154    if (orxonox::ConfigValueContainer* container = ClassByObjectType(object)->getConfigValueContainer(entryName)) \
    155155    { \
    156156        container->modifier(__VA_ARGS__); \
     
    160160    { \
    161161        COUT(2) << "Warning: Couln't modify config-value '" << entryName << "' in class '" \
    162                 << object->getIdentifier()->getName() << "', corresponding container doesn't exist." << std::endl; \
     162                << ClassByObjectType(object)->getName() << "', corresponding container doesn't exist." << std::endl; \
    163163    }
    164164
  • code/trunk/src/libraries/core/CoreIncludes.h

    r5929 r6423  
    125125        return Identifier::getIdentifierByID(id);
    126126    }
     127
     128    /**
     129        @brief Returns the Identifier with a given 'this' pointer.
     130        @note This of course only works with OrxonoxClasses.
     131              The only use is in conjunction with macros that don't know the class type.
     132        @param Pointer to an OrxonoxClass
     133    */
     134    template <class T>
     135    inline Identifier* ClassByObjectType(const T* object)
     136    {
     137        return ClassIdentifier<T>::getIdentifier();
     138    }
    127139}
    128140
Note: See TracChangeset for help on using the changeset viewer.