- Timestamp:
- Dec 29, 2009, 10:30:19 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamestate/src/libraries/core/ConfigValueContainer.cc
r5738 r6432 36 36 #include "util/Convert.h" 37 37 #include "util/SubString.h" 38 #include "ConfigFileManager.h" 38 39 #include "Language.h" 39 40 … … 43 44 44 45 /** 45 @brief Initializes the ConfigValueContainer with default values.46 */ 47 void ConfigValueContainer::init(ConfigFileType type, Identifier* identifier, const std::string& sectionname, const std::string& varname)46 @brief Initializes the ConfigValueContainer with default values. 47 */ 48 void ConfigValueContainer::init(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname) 48 49 { 49 50 this->type_ = type; … … 55 56 this->bDoInitialCallback_ = false; 56 57 this->bAddedDescription_ = false; 58 59 // Register containers for general settings 60 if (this->type_ == ConfigFileType::Settings) 61 SettingsConfigFile::getInstance().addConfigValueContainer(this); 57 62 } 58 63 … … 78 83 for (unsigned int i = 0; i < this->valueVector_.size(); i++) 79 84 { 80 ConfigFileManager::getInstance().get Value(this->type_,this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));85 ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String)); 81 86 this->defvalueStringVector_.push_back(this->valueVector_[i]); 82 87 } … … 92 97 if (this->callback_) 93 98 delete this->callback_; 99 100 // Unregister general settings containers 101 if (this->type_ == ConfigFileType::Settings && SettingsConfigFile::exists()) 102 SettingsConfigFile::getInstance().removeConfigValueContainer(this); 94 103 } 95 104 … … 109 118 if (this->tset(input)) 110 119 { 111 ConfigFileManager::getInstance(). setValue(this->type_,this->sectionname_, this->varname_, input, this->value_.isType(MT_Type::String));120 ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, input, this->value_.isType(MT_Type::String)); 112 121 return true; 113 122 } … … 128 137 if (this->tset(index, input)) 129 138 { 130 ConfigFileManager::getInstance(). setValue(this->type_,this->sectionname_, this->varname_, index, input, this->value_.isType(MT_Type::String));139 ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, index, input, this->value_.isType(MT_Type::String)); 131 140 return true; 132 141 } … … 228 237 this->valueVector_.erase(this->valueVector_.begin() + index); 229 238 for (unsigned int i = index; i < this->valueVector_.size(); i++) 230 ConfigFileManager::getInstance(). setValue(this->type_,this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));231 ConfigFileManager::getInstance(). deleteVectorEntries(this->type_,this->sectionname_, this->varname_, this->valueVector_.size());239 ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String)); 240 ConfigFileManager::getInstance().getConfigFile(this->type_)->deleteVectorEntries(this->sectionname_, this->varname_, this->valueVector_.size()); 232 241 233 242 return true; … … 253 262 if (!this->set(i, this->defvalueStringVector_[i])) 254 263 success = false; 255 ConfigFileManager::getInstance(). deleteVectorEntries(this->type_,this->sectionname_, this->varname_, this->defvalueStringVector_.size());264 ConfigFileManager::getInstance().getConfigFile(this->type_)->deleteVectorEntries(this->sectionname_, this->varname_, this->defvalueStringVector_.size()); 256 265 return success; 257 266 } … … 264 273 { 265 274 if (!this->bIsVector_) 266 this->value_ = ConfigFileManager::getInstance().get Value(this->type_,this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_Type::String));275 this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_Type::String)); 267 276 else 268 277 { 269 278 this->valueVector_.clear(); 270 unsigned int vectorSize = ConfigFileManager::getInstance().get VectorSize(this->type_,this->sectionname_, this->varname_);279 unsigned int vectorSize = ConfigFileManager::getInstance().getConfigFile(this->type_)->getVectorSize(this->sectionname_, this->varname_); 271 280 for (unsigned int i = 0; i < vectorSize; i++) 272 281 { 273 282 if (i < this->defvalueStringVector_.size()) 274 283 { 275 this->value_ = ConfigFileManager::getInstance().get Value(this->type_,this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_Type::String));284 this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_Type::String)); 276 285 } 277 286 else 278 287 { 279 this->value_ = ConfigFileManager::getInstance().get Value(this->type_,this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_Type::String));288 this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_Type::String)); 280 289 } 281 290
Note: See TracChangeset
for help on using the changeset viewer.