Salome HOME
Update copyrights
[modules/shaper.git] / src / Config / Config_PropManager.h
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef Config_PropManager_H
21 #define Config_PropManager_H
22
23 #include "Config_def.h"
24 #include "Config_Prop.h"
25
26 #include <map>
27 #include <string>
28 #include <vector>
29
30 /**
31  * \class Config_PropManager
32  * \ingroup Config
33  * \brief Class which let to register properties
34  */
35 class Config_PropManager
36 {
37  public:
38
39   /** 
40    * Registers property parameters
41    * \param theSection - name of section (domain of using) of the property.
42    * \param theName - name (title) of the value.
43    * \param theTitle - title of the value.
44    * \param theType - type of the value.
45    * \param theDefValue - default and initial value of the property
46    * \param theMin - minimal value
47    * \param theMax - minimal value
48    * Returns True if the property succesfully registered
49    */
50   CONFIG_EXPORT static Config_Prop* registerProp(const std::string& theSection,
51     const std::string& theName,
52     const std::string& theTitle, Config_Prop::PropType theType,
53     const std::string& theDefValue = "",
54     const std::string& theMin = "",
55     const std::string& theMax = "");
56
57   //! Finds property in the given section by the given name, if property not found returns NULL
58   CONFIG_EXPORT static Config_Prop* findProp(
59     const std::string& theSection, const std::string& theName);
60
61   //! Returns std::list of all existing properies
62   CONFIG_EXPORT static Config_Properties getProperties();
63
64   //! Returns list of registered section names.
65   CONFIG_EXPORT static std::list<std::string> getSections();
66
67   //! Returns list of properties by its owner and section.
68   CONFIG_EXPORT static Config_Properties getProperties(const std::string& theSection);
69
70   //! Returns value of the property by its owner, section, and name
71   CONFIG_EXPORT static std::string string(const std::string& theSection,
72                                           const std::string& theName);
73   //! Returns color by given section and name as 3-element vector {r,g,b}.
74   CONFIG_EXPORT static std::vector<int> color(const std::string& theSection,
75                                               const std::string& theName);
76   //! Returns integer by given section and name
77   CONFIG_EXPORT static int integer(const std::string& theSection,
78                                    const std::string& theName);
79   //! Returns real by given section and name
80   CONFIG_EXPORT static double real(const std::string& theSection,
81                                    const std::string& theName);
82   //! Returns boolean by given section and name
83   CONFIG_EXPORT static bool boolean(const std::string& theSection,
84                                     const std::string& theName);
85
86   //! Returns convertion of the string to double value. Temporary changes locale to process
87   //! values contained "," or "." separator.
88   //! \param theDouble a value to be converted
89   //! \return double result or zero
90   CONFIG_EXPORT static double stringToDouble(const std::string& theDouble);
91
92  private:
93   CONFIG_EXPORT static Config_Properties& props(); ///< List of all stored properties
94 };
95
96 #endif