Salome HOME
Update copyrights
[modules/shaper.git] / src / Config / Config_Prop.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_PROP_H
21 #define CONFIG_PROP_H
22
23 #include "Config_def.h"
24
25 #include <string>
26 #include <list>
27
28 static const char SKETCH_TAB_NAME[] = "Sketch";
29
30 /*!
31  * \class Config_Prop
32  * \brief Class which describes a one property
33  * \ingroup Config
34  */
35 class Config_Prop
36 {
37  public:
38
39   /// Type of stored property
40   enum PropType
41   {
42     Disabled,
43     Space,
44     Boolean,
45     Color,
46     String,
47     Selector,
48     DblSpin,
49     IntSpin,
50     Double,
51     Integer,
52     GroupBox,
53     Tab,
54     Frame,
55     Font,
56     DirList,
57     File,
58     Slider,
59     Shortcut,
60     ShortcutTree,
61     BiColor,
62     Background,
63     Directory
64   };
65
66   /** 
67    * Creates a one property
68    * \param theSection - name of section (domain of using) of the property.
69    * \param theName - name (title) of the value.
70    * \param theTitle - title of the value
71    * \param theType - type of the value.
72    * \param theDefaultValue - default value of the property. This is an initial property value
73    */
74   Config_Prop(const std::string& theSection, const std::string& theName,
75               const std::string& theTitle, PropType theType,
76               const std::string& theDefaultValue,
77               const std::string& theMin, const std::string& theMax)
78   {
79     mySection = theSection;
80     myName = theName;
81     myTitle = theTitle;
82     myType = theType;
83     myValue = theDefaultValue;
84     myDefaultValue = theDefaultValue;
85     myMin = theMin;
86     myMax = theMax;
87   }
88
89   /// Get name of section
90   std::string section() const
91   {
92     return mySection;
93   }
94   /// Get name of property
95   std::string name() const
96   {
97     return myName;
98   }
99   /// Get title of property
100   std::string title() const
101   {
102     return myTitle;
103   }
104   /// Set title of property
105   void setTitle(const std::string& theTitle)
106   {
107     myTitle = theTitle;
108   }
109   /// Get type of property
110   PropType type() const
111   {
112     return myType;
113   }
114   /// Set type of property
115   void setType(PropType theType)
116   {
117     myType = theType;
118   }
119   /// Get property's value in string format
120   std::string value() const
121   {
122     return myValue;
123   }
124   /// Set property's value in string format
125   CONFIG_EXPORT void setValue(const std::string& theValue);
126   /// Get default value of property
127   std::string defaultValue() const
128   {
129     return myDefaultValue;
130   }
131   /// Set default value of property
132   CONFIG_EXPORT void setDefaultValue(const std::string& theValue);
133   /// Alows to compare Config_Prop with each other
134   bool operator==(const Config_Prop* theProp) const
135   {
136     return (mySection == theProp->section()) && (myName == theProp->name());
137   }
138
139   /// Returns minimal value
140   std::string min() const { return myMin; }
141
142   void setMin(const std::string& theMin) {
143     myMin = theMin;
144   }
145
146   /// Returns maximal value
147   std::string max() const { return myMax; }
148
149   void setMax(const std::string& theMax) {
150     myMax = theMax;
151   }
152
153  private:
154   std::string mySection; ///< Name of section
155   std::string myName; ///< Name of property
156   std::string myTitle; ///< Title of property
157   PropType myType; ///< Type of property
158   std::string myValue; // Value in string format
159   std::string myDefaultValue; // Default value
160   std::string myMin; // Minimal value
161   std::string myMax; // Maximal value
162 };
163
164 typedef std::list<Config_Prop*> Config_Properties;
165
166 #endif