Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 19, 2008, 5:02:45 AM (16 years ago)
Author:
landauf
Message:
  • fixed bug #2 in ConfigValueContainer (callback not being called if the configured value is the same as default value)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/ConfigValueContainer.cc

    r1610 r1611  
    4747{
    4848    /**
    49         @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
    50         @param type The type of the corresponding config-file
    51         @param identifier The identifier of the class the variable belongs to
    52         @param varname The name of the variable
    53         @param defvalue The default-value
    54     */
    55     ConfigValueContainer::ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const MultiTypeMath& defvalue)
     49        @brief Initializes the ConfigValueContainer with defaultvalues.
     50    */
     51    void ConfigValueContainer::init(ConfigFileType type, Identifier* identifier, const std::string& varname)
    5652    {
    5753        this->type_ = type;
     
    6359        this->bDoInitialCallback_ = false;
    6460        this->bAddedDescription_ = false;
    65 
     61    }
     62
     63    /**
     64        @brief Does some special initialization for single config-values.
     65    */
     66    void ConfigValueContainer::initValue(const MultiTypeMath& defvalue)
     67    {
    6668        this->value_ = defvalue;
    6769        this->bIsVector_ = false;
    6870
    69         this->defvalueString_ = defvalue.toString();
     71        this->defvalueString_ = this->value_.toString();
    7072        this->update();
    7173    }
    7274
    7375    /**
    74         @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
    75         @param type The type of the corresponding config-file
    76         @param identifier The identifier of the class the variable belongs to
    77         @param varname The name of the variable
    78         @param defvalue The default-value
    79     */
    80     ConfigValueContainer::ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<MultiTypeMath>& defvalue)
    81     {
    82         this->type_ = type;
    83         this->identifier_ = identifier;
    84         this->sectionname_ = identifier->getName();
    85         this->varname_ = varname;
    86         this->callback_ = 0;
    87         this->bContainerIsNew_ = true;
    88         this->bDoInitialCallback_ = false;
    89         this->bAddedDescription_ = false;
    90 
    91         this->valueVector_ = defvalue;
     76        @brief Does some special initialization for vector config-values.
     77    */
     78    void ConfigValueContainer::initVector()
     79    {
    9280        this->bIsVector_ = true;
    9381
    94         if (defvalue.size() > 0)
    95         {
    96                 this->value_ = defvalue[0];
    97 
    98             for (unsigned int i = 0; i < defvalue.size(); i++)
    99             {
    100                 ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, defvalue[i].toString(), this->value_.isA(MT_string));
    101                 this->defvalueStringVector_.push_back(defvalue[i].toString());
    102             }
    103 
    104             this->update();
    105         }
     82        for (unsigned int i = 0; i < this->valueVector_.size(); i++)
     83        {
     84            ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i].toString(), this->value_.isA(MT_string));
     85            this->defvalueStringVector_.push_back(this->valueVector_[i].toString());
     86        }
     87
     88        this->update();
    10689    }
    10790
Note: See TracChangeset for help on using the changeset viewer.