Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[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 email : webmaster.salome@opencascade.com<mailto: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 const static 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, const std::string& theDefaultValue)
76   {
77     mySection = theSection;
78     myName = theName;
79     myTitle = theTitle;
80     myType = theType;
81     myValue = theDefaultValue;
82     myDefaultValue = theDefaultValue;
83   }
84
85   /// Get name of section
86   std::string section() const
87   {
88     return mySection;
89   }
90   /// Get name of property
91   std::string name() const
92   {
93     return myName;
94   }
95   /// Get title of property
96   std::string title() const
97   {
98     return myTitle;
99   }
100   /// Set title of property
101   void setTitle(const std::string& theTitle)
102   {
103     myTitle = theTitle;
104   }
105   /// Get type of property
106   PropType type() const
107   {
108     return myType;
109   }
110   /// Set type of property
111   void setType(PropType theType)
112   {
113     myType = theType;
114   }
115   /// Get property's value in string format
116   std::string value() const
117   {
118     return myValue;
119   }
120   /// Set property's value in string format
121   CONFIG_EXPORT void setValue(const std::string& theValue);
122   /// Get default value of property
123   std::string defaultValue() const
124   {
125     return myDefaultValue;
126   }
127   /// Set default value of property
128   CONFIG_EXPORT void setDefaultValue(const std::string& theValue);
129   /// Alows to compare Config_Prop with each other
130   bool operator==(const Config_Prop* theProp) const
131   {
132     return (mySection == theProp->section()) && (myName == theProp->name());
133   }
134
135  private:
136   std::string mySection; ///< Name of section
137   std::string myName; ///< Name of property
138   std::string myTitle; ///< Title of property
139   PropType myType; ///< Type of property
140   std::string myValue; // Value in string format
141   std::string myDefaultValue; // Default value
142 };
143
144 typedef std::list<Config_Prop*> Config_Properties;
145
146 #endif