Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom into Dev_0.7.1
[modules/shaper.git] / src / Config / Config_PropManager.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Config_PropManager.h
4 // Created:     13 Aug 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef Config_PropManager_H
8 #define Config_PropManager_H
9
10 #include "Config_def.h"
11 #include "Config_Prop.h"
12
13 #include <map>
14 #include <string>
15 #include <vector>
16
17 /**
18  * \class Config_PropManager
19  * \ingroup Config
20  * \brief Class which let to register properties
21  */
22 class Config_PropManager
23 {
24  public:
25
26   /** 
27    * Registers property parameters
28    * \param theSection - name of section (domain of using) of the property.
29    * \param theName - name (title) of the value.
30    * \param theType - type of the value.
31    * \param theDefValue - default and initial value of the property
32    * Returns True if the property succesfully registered
33    */
34   CONFIG_EXPORT static Config_Prop* registerProp(const std::string& theSection, const std::string& theName,
35     const std::string& theTitle, Config_Prop::PropType theType, const std::string& theDefValue = "");
36   //! Finds property in the given section by the given name, if property not found returns NULL
37   CONFIG_EXPORT static Config_Prop* findProp(
38     const std::string& theSection, const std::string& theName);
39   //! Returns std::list of all existing properies
40   CONFIG_EXPORT static Config_Properties getProperties();
41   //! Returns list of registered section names.
42   CONFIG_EXPORT static std::list<std::string> getSections();
43   //! Returns list of properties by its owner and section.
44   CONFIG_EXPORT static Config_Properties getProperties(const std::string& theSection);
45
46   //! Returns value of the property by its owner, section, and name
47   CONFIG_EXPORT static std::string string(const std::string& theSection,
48                                           const std::string& theName,
49                                           const std::string& theDefault);
50   //! Returns color by given section and name as 3-element vector {r,g,b}.
51   CONFIG_EXPORT static std::vector<int> color(const std::string& theSection,
52                                               const std::string& theName,
53                                               const std::string& theDefault);
54   //! Returns integer by given section and name
55   CONFIG_EXPORT static int integer(const std::string& theSection,
56                                    const std::string& theName,
57                                    const std::string& theDefault);
58   //! Returns real by given section and name
59   CONFIG_EXPORT static double real(const std::string& theSection,
60                                    const std::string& theName,
61                                    const std::string& theDefault);
62
63  private:
64   CONFIG_EXPORT static Config_Properties myProps; ///< List of all stored properties
65 };
66
67 #endif