X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_PropManager.cpp;h=82ec43f5871c82fba052e124ee830189943d53ef;hb=b52164791e6cc6cdc2c009c7ef6667d9f476d3aa;hp=4fa3d7090043cbf73b7200b3069ccae48c02fd97;hpb=57c61908ce2c9d9386762d76c7606eeaa7f8a48c;p=modules%2Fshaper.git diff --git a/src/Config/Config_PropManager.cpp b/src/Config/Config_PropManager.cpp index 4fa3d7090..82ec43f58 100644 --- a/src/Config/Config_PropManager.cpp +++ b/src/Config/Config_PropManager.cpp @@ -1,42 +1,43 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: Config_PropManager.cpp // Created: 13 Aug 2014 // Author: Vitaly SMETANNIKOV #include "Config_PropManager.h" - - std::vector stringToRGB(const std::string& theColor); int stringToInteger(const std::string& theInt); double stringToDouble(const std::string& theDouble); - Config_Properties Config_PropManager::myProps; - - -bool Config_PropManager::registerProp(const std::string& theSection, - const std::string& theName, - const std::string& theTitle, - Config_Prop::PropType theType, - const std::string& theValue) +Config_Prop* Config_PropManager::registerProp(const std::string& theSection, const std::string& theName, + const std::string& theTitle, Config_Prop::PropType theType, + const std::string& theDefaultValue) { Config_Prop* aProp = findProp(theSection, theName); + if (aProp) { + if (aProp->value() == "") { + aProp->setValue(theDefaultValue); + } + if (aProp->defaultValue() == "") { + aProp->setDefaultValue(theDefaultValue); + } if (aProp->type() == Config_Prop::Disabled) { aProp->setType(theType); aProp->setTitle(theTitle); - return true; } - return false; } - aProp = new Config_Prop(theSection, theName, theTitle, theType, theValue); - myProps.push_back(aProp); - return true; + else { + aProp = new Config_Prop(theSection, theName, theTitle, theType, theDefaultValue); + myProps.push_back(aProp); + } + return aProp; } -Config_Prop* Config_PropManager::findProp(const std::string& theSection, - const std::string& theName) +Config_Prop* Config_PropManager::findProp(const std::string& theSection, const std::string& theName) { Config_Properties::const_iterator aIt; for (aIt = myProps.cbegin(); aIt != myProps.cend(); ++aIt) { @@ -47,7 +48,6 @@ Config_Prop* Config_PropManager::findProp(const std::string& theSection, return NULL; } - Config_Properties Config_PropManager::getProperties() { Config_Properties aRes; @@ -86,10 +86,8 @@ Config_Properties Config_PropManager::getProperties(const std::string& theSectio return aRes; } - -std::string Config_PropManager::string(const std::string& theSection, - const std::string& theName, - const std::string& theDefault) +std::string Config_PropManager::string(const std::string& theSection, const std::string& theName, + const std::string& theDefault) { Config_Properties aProps = getProperties(theSection); Config_Properties::const_iterator aIt; @@ -101,8 +99,7 @@ std::string Config_PropManager::string(const std::string& theSection, return theDefault; } - -std::vector Config_PropManager::color(const std::string& theSection, +std::vector Config_PropManager::color(const std::string& theSection, const std::string& theName, const std::string& theDefault) { @@ -110,24 +107,20 @@ std::vector Config_PropManager::color(const std::string& theSection, return stringToRGB(aStr); } -int Config_PropManager::integer(const std::string& theSection, - const std::string& theName, - const std::string& theDefault) +int Config_PropManager::integer(const std::string& theSection, const std::string& theName, + const std::string& theDefault) { std::string aStr = string(theSection, theName, theDefault); return stringToInteger(aStr); } -double Config_PropManager::real(const std::string& theSection, - const std::string& theName, - const std::string& theDefault) +double Config_PropManager::real(const std::string& theSection, const std::string& theName, + const std::string& theDefault) { std::string aStr = string(theSection, theName, theDefault); return stringToDouble(aStr); } - - std::vector stringToRGB(const std::string& theColor) { std::vector aRes(3);