Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / Config / Config_PropManager.h
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef Config_PropManager_H
22 #define Config_PropManager_H
23
24 #include "Config_def.h"
25 #include "Config_Prop.h"
26
27 #include <map>
28 #include <string>
29 #include <vector>
30
31 /**
32  * \class Config_PropManager
33  * \ingroup Config
34  * \brief Class which let to register properties
35  */
36 class Config_PropManager
37 {
38  public:
39
40   /** 
41    * Registers property parameters
42    * \param theSection - name of section (domain of using) of the property.
43    * \param theName - name (title) of the value.
44    * \param theTitle - title of the value.
45    * \param theType - type of the value.
46    * \param theDefValue - default and initial value of the property
47    * Returns True if the property succesfully registered
48    */
49   CONFIG_EXPORT static Config_Prop* registerProp(const std::string& theSection,
50     const std::string& theName,
51     const std::string& theTitle, Config_Prop::PropType theType,
52     const std::string& theDefValue = "");
53   //! Finds property in the given section by the given name, if property not found returns NULL
54   CONFIG_EXPORT static Config_Prop* findProp(
55     const std::string& theSection, const std::string& theName);
56   //! Returns std::list of all existing properies
57   CONFIG_EXPORT static Config_Properties getProperties();
58   //! Returns list of registered section names.
59   CONFIG_EXPORT static std::list<std::string> getSections();
60   //! Returns list of properties by its owner and section.
61   CONFIG_EXPORT static Config_Properties getProperties(const std::string& theSection);
62
63   //! Returns value of the property by its owner, section, and name
64   CONFIG_EXPORT static std::string string(const std::string& theSection,
65                                           const std::string& theName);
66   //! Returns color by given section and name as 3-element vector {r,g,b}.
67   CONFIG_EXPORT static std::vector<int> color(const std::string& theSection,
68                                               const std::string& theName);
69   //! Returns integer by given section and name
70   CONFIG_EXPORT static int integer(const std::string& theSection,
71                                    const std::string& theName);
72   //! Returns real by given section and name
73   CONFIG_EXPORT static double real(const std::string& theSection,
74                                    const std::string& theName);
75   //! Returns boolean by given section and name
76   CONFIG_EXPORT static bool boolean(const std::string& theSection,
77                                    const std::string& theName);
78   //! Returns convertion of the string to double value. Temporary changes locale to process
79   //! values contained "," or "." separator.
80   //! \param theDouble a value to be converted
81   //! \return double result or zero
82   CONFIG_EXPORT static double stringToDouble(const std::string& theDouble);
83
84  private:
85   CONFIG_EXPORT static Config_Properties myProps; ///< List of all stored properties
86 };
87
88 #endif