Salome HOME
1cf0c0c53b19e5b0e9ce9462a7c3363d3d06345b
[modules/shaper.git] / src / Config / Config_Prop.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Config_Prop.h
4 // Created:     12 Aug 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef Config_Prop_H
8 #define Config_Prop_H
9
10 #include "Config_def.h"
11
12 #include <string>
13 #include <list>
14
15 /// Class which describes a one property
16 class Config_Prop
17 {
18  public:
19
20   /// Type of stored property
21   enum PropType
22   {
23     Disabled,
24     Space,
25     Bool,
26     Color,
27     String,
28     Selector,
29     DblSpin,
30     IntSpin,
31     Double,
32     Integer,
33     GroupBox,
34     Tab,
35     Frame,
36     Font,
37     DirList,
38     File,
39     Slider,
40     Shortcut,
41     ShortcutTree,
42     BiColor,
43     Background,
44     Directory
45   };
46
47   /** 
48    * Creates a one property
49    * \param theSection - name of section (domain of using) of the property.
50    * \param theName - name (title) of the value.
51    * \param theType - type of the value.
52    * \param theDefaultValue - default value of the property. This is an initial property value
53    */
54   Config_Prop(const std::string& theSection, const std::string& theName,
55               const std::string& theTitle, PropType theType, const std::string& theDefaultValue)
56   {
57     mySection = theSection;
58     myName = theName;
59     myTitle = theTitle;
60     myType = theType;
61     myValue = theDefaultValue;
62     myDefaultValue = theDefaultValue;
63   }
64
65   /// Get name of section
66   std::string section() const
67   {
68     return mySection;
69   }
70   /// Get name of property
71   std::string name() const
72   {
73     return myName;
74   }
75   /// Get title of property
76   std::string title() const
77   {
78     return myTitle;
79   }
80   /// Set title of property
81   void setTitle(const std::string& theTitle)
82   {
83     myTitle = theTitle;
84   }
85   /// Get type of property
86   PropType type() const
87   {
88     return myType;
89   }
90   /// Set type of property
91   void setType(PropType theType)
92   {
93     myType = theType;
94   }
95   /// Get property's value in string format
96   std::string value() const
97   {
98     return myValue;
99   }
100   /// Set property's value in string format
101   CONFIG_EXPORT void setValue(const std::string& theValue);
102   /// Get default value of property
103   std::string defaultValue() const
104   {
105     return myDefaultValue;
106   }
107   /// Set default value of property
108   CONFIG_EXPORT void setDefaultValue(const std::string& theValue);
109   /// Alows to compare Config_Prop with each other
110   bool operator==(const Config_Prop* theProp) const
111   {
112     return (mySection == theProp->section()) && (myName == theProp->name());
113   }
114
115  private:
116   std::string mySection; ///< Name of section
117   std::string myName; ///< Name of property
118   std::string myTitle; ///< Title of property
119   PropType myType; ///< Type of property
120   std::string myValue; // Value in string format
121   std::string myDefaultValue; // Default value
122 };
123
124 typedef std::list<Config_Prop*> Config_Properties;
125
126 #endif