Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 12, 2008, 4:28:06 PM (17 years ago)
Author:
landauf
Message:

added a variadic macro to ConfigValueIncludes.h:
ModifyConfigValue(varname, modifier, …) calls 'modifier' (which is a function like set, tset, update, reset, add, remove) and … are the possible arguments (or nothing). i'm not sure if this works on all compilers.
http://en.wikipedia.org/wiki/Variadic_macro

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/core/ConfigValueIncludes.h

    r1031 r1033  
    8383    else \
    8484    { \
    85         COUT(2) << "Warning: Couldn't reset variable " << #varname << ", corresponding container doesn't exist." << std::endl; \
     85        COUT(2) << "Warning: Couldn't reset config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
     86    }
     87
     88/**
     89    @brief Modifies a config-value by using a modifier and some arguments.
     90    @param varname The name of the config-value
     91    @param modifier The name of the modifier: set, tset, add, remove, reset, update
     92*/
     93#define ModifyConfigValue(varname, modifier, ...) \
     94    orxonox::ConfigValueContainer* container##varname##modify##modifier = this->getIdentifier()->getConfigValueContainer(#varname); \
     95    if (container##varname##modify##modifier) \
     96    { \
     97        container##varname##modify##modifier->modifier(__VA_ARGS__); \
     98        container##varname##modify##modifier->getValue(&varname); \
     99    } \
     100    else \
     101    { \
     102        COUT(2) << "Warning: Couln't modify config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
    86103    }
    87104
Note: See TracChangeset for help on using the changeset viewer.