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