Salome HOME
Merge commit 'refs/tags/V9_2_0^{}'
[modules/shaper.git] / src / Config / Config_PropManager.cpp
index 25745a01d1131d66652c825e451639467f5a7fde..e754039e3a01436c45455057987d3431a17fa962 100644 (file)
@@ -24,14 +24,19 @@ std::vector<int> stringToRGB(const std::string& theColor);
 int stringToInteger(const std::string& theInt);
 bool stringToBoolean(const std::string& theInt);
 
-Config_Properties Config_PropManager::myProps;
+Config_Properties& Config_PropManager::props() {
+  static Config_Properties* confProps = new Config_Properties();
+  return *confProps;
+}
 
 
 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)
+                                              const std::string& theDefaultValue,
+                                              const std::string& theMin,
+                                              const std::string& theMax)
 {
   Config_Prop* aProp = findProp(theSection, theName);
 
@@ -46,10 +51,13 @@ Config_Prop* Config_PropManager::registerProp(const std::string& theSection,
       aProp->setType(theType);
       aProp->setTitle(theTitle);
     }
+    aProp->setMin(theMin);
+    aProp->setMax(theMax);
   }
   else {
-    aProp = new Config_Prop(theSection, theName, theTitle, theType, theDefaultValue);
-    myProps.push_back(aProp);
+    aProp =
+      new Config_Prop(theSection, theName, theTitle, theType, theDefaultValue, theMin, theMax);
+    props().push_back(aProp);
   }
   return aProp;
 }
@@ -57,7 +65,8 @@ Config_Prop* Config_PropManager::registerProp(const std::string& theSection,
 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) {
+  Config_Properties aProps = props();
+  for (aIt = aProps.cbegin(); aIt != aProps.cend(); ++aIt) {
     Config_Prop* aProp = (*aIt);
     if ((aProp->section() == theSection) && (aProp->name() == theName))
       return aProp;
@@ -69,7 +78,8 @@ Config_Properties Config_PropManager::getProperties()
 {
   Config_Properties aRes;
   Config_Properties::const_iterator aIt;
-  for (aIt = myProps.cbegin(); aIt != myProps.cend(); aIt++) {
+  Config_Properties aProps = props();
+  for (aIt = aProps.cbegin(); aIt != aProps.cend(); aIt++) {
     Config_Prop* aProp = (*aIt);
     if (aProp->type() != Config_Prop::Disabled)
       aRes.push_back(aProp);
@@ -82,7 +92,8 @@ std::list<std::string> Config_PropManager::getSections()
   // Return only non disabled sections
   std::list<std::string> aSections;
   Config_Properties::const_iterator aIt;
-  for (aIt = myProps.cbegin(); aIt != myProps.cend(); aIt++) {
+  Config_Properties aProps = props();
+  for (aIt = aProps.cbegin(); aIt != aProps.cend(); aIt++) {
     const Config_Prop* aProp = (*aIt);
     if (aProp->type() != Config_Prop::Disabled)
       aSections.push_back(aProp->section());
@@ -95,7 +106,8 @@ Config_Properties Config_PropManager::getProperties(const std::string& theSectio
 {
   Config_Properties aRes;
   Config_Properties::iterator aIt;
-  for (aIt = myProps.begin(); aIt != myProps.end(); aIt++) {
+  Config_Properties aProps = props();
+  for (aIt = aProps.begin(); aIt != aProps.end(); aIt++) {
     Config_Prop* aProp = (*aIt);
     if ((aProp->section() == theSection) && (aProp->type() != Config_Prop::Disabled))
       aRes.push_back(aProp);