Salome HOME
Merge from V6_main 01/04/2013
[modules/gui.git] / src / DDS / DDS_KeyWords.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "DDS_KeyWords.h"
24
25 IMPLEMENT_STANDARD_HANDLE(DDS_KeyWords, MMgt_TShared)
26 IMPLEMENT_STANDARD_RTTIEXT(DDS_KeyWords, MMgt_TShared)
27
28 /*!
29   \class DDS_KeyWords
30   \brief This class defines the pairs of internal keys and XML tags or 
31   attributes names. 
32
33   This class allows user to define a set of XML keywords used in the datums
34   definition (XML) file.
35
36   Default keywords table:
37   - \c D_URI - dictionary
38   - \c COMPONENT - component
39   - \c COMPONENT_NAME - name
40   - \c UNIT_SYSTEMS - unitSystems
41   - \c UNIT_SYSTEM - system
42   - \c UNIT_SYSTEM_NAME - name
43   - \c UNIT_SYSTEM_LABEL - label
44   - \c DATUM - datum
45   - \c DATUM_ID - id
46   - \c DATUM_LABEL - label
47   - \c DATUM_UNITS - units
48   - \c DATUM_FORMAT - format
49   - \c DATUM_FILTER - filter
50   - \c DATUM_REQUIRED - required
51   - \c VALUE_LIST - valueList
52   - \c VALUE_LIST_ID - listid
53   - \c VALUE_LIST_NAME - name
54   - \c VALUE_LIST_TYPE - type
55   - \c VALUE_LIST_VALUE - value
56   - \c VALUE_LIST_VALUEID - id
57   - \c VALUE_LIST_VALUEICON - icon
58   - \c DY_DOMAIN - domain
59   - \c WARNING_LEVEL - warningLevel
60   - \c WRONG_VALUE - wrongValue
61   - \c VALUE_DESCR - valueDescr
62   - \c VALUE_LIST_REF - listRef
63   - \c DESCR - description
64   - \c LONG_D - longDescr
65   - \c SHORT_D - shortDescr
66   - \c VD_TYPE - type
67   - \c VD_DEFV - default
68   - \c VD_MAXV - max
69   - \c VD_MINV - min
70   - \c VD_SPEC - specVal
71   - \c VLR_LIST - list
72   - \c PRS - presentation
73   - \c LATERAL_ZOOM - lateralZoom
74   - \c LZ_MINV - min
75   - \c LZ_MAXV - max
76   - \c LZ_ORDER - order
77   - \c OPTIONS - options
78   - \c OPTION - option
79   - \c OPTION_NAME - name
80
81   There is the only instance of the class DDS_KeyWords in the application
82   which can be retrieved by method Get().
83 */
84
85 /*!
86   \brief Constructor. 
87   Create an instance of the object. Can not be used directly.
88   Use Get() method instead.
89 */
90 DDS_KeyWords::DDS_KeyWords()
91 : MMgt_TShared()
92 {
93   SetKeyWord( "D_URI",                "dictionary" );
94
95   SetKeyWord( "COMPONENT",            "component" );
96   SetKeyWord( "COMPONENT_NAME",       "name" );
97
98   SetKeyWord( "UNIT_SYSTEMS",         "unitSystems" );
99   SetKeyWord( "UNIT_SYSTEM",          "system" );
100   SetKeyWord( "UNIT_SYSTEM_NAME",     "name" );
101   SetKeyWord( "UNIT_SYSTEM_LABEL",    "label" );
102
103   SetKeyWord( "DATUM",                "datum" );
104   SetKeyWord( "DATUM_ID",             "id" );
105   SetKeyWord( "DATUM_LABEL",          "label" );
106   SetKeyWord( "DATUM_UNITS",          "units" );
107   SetKeyWord( "DATUM_FORMAT",         "format" );
108   SetKeyWord( "DATUM_FILTER",         "filter" );
109   SetKeyWord( "DATUM_REQUIRED",       "required" );
110
111   SetKeyWord( "VALUE_LIST",           "valueList" );
112   SetKeyWord( "VALUE_LIST_ID",        "listid" );
113   SetKeyWord( "VALUE_LIST_NAME",      "name" );
114   SetKeyWord( "VALUE_LIST_TYPE",      "type" );
115   SetKeyWord( "VALUE_LIST_VALUE",     "value" );
116   SetKeyWord( "VALUE_LIST_VALUEID",   "id" );
117   SetKeyWord( "VALUE_LIST_VALUEICON", "icon" );
118
119   SetKeyWord( "DY_DOMAIN",            "domain" );
120   SetKeyWord( "WARNING_LEVEL",        "warningLevel" );
121   SetKeyWord( "WRONG_VALUE",          "wrongValue" );
122   SetKeyWord( "VALUE_DESCR",          "valueDescr" );
123   SetKeyWord( "VALUE_LIST_REF",       "listRef" );
124
125   SetKeyWord( "DESCR",                "description" );
126   SetKeyWord( "LONG_D",               "longDescr" );
127   SetKeyWord( "SHORT_D",              "shortDescr" );
128
129   SetKeyWord( "VD_TYPE",              "type" );
130   SetKeyWord( "VD_DEFV",              "default" );
131   SetKeyWord( "VD_MAXV",              "max" );
132   SetKeyWord( "VD_MINV",              "min" );
133   SetKeyWord( "VD_SPEC",              "specVal" );
134   SetKeyWord( "VLR_LIST",             "list" );
135   SetKeyWord( "PRS",                  "presentation" );
136   SetKeyWord( "LATERAL_ZOOM",         "lateralZoom" );
137   SetKeyWord( "LZ_MINV",              "min" );
138   SetKeyWord( "LZ_MAXV",              "max" );
139   SetKeyWord( "LZ_ORDER",             "order" );
140
141   SetKeyWord( "OPTIONS",              "options" );
142   SetKeyWord( "OPTION",               "option" );
143   SetKeyWord( "OPTION_NAME",          "name" );
144 }
145
146 /*!
147   \brief Get the only instance of the class DDS_KeyWords.
148   \return the only instance of the class
149 */
150 Handle_DDS_KeyWords DDS_KeyWords::Get()
151 {
152   static Handle(DDS_KeyWords) keyWords;
153
154   if ( keyWords.IsNull() )
155     keyWords = new DDS_KeyWords();
156
157   return keyWords;
158 }
159
160 /*!
161   \brief Get the XML keyword by specified internal key \a key.
162
163   If the internal key is not registered, empty string is returned.
164   \param key internal key
165   \return XML keyword 
166 */
167 TCollection_AsciiString DDS_KeyWords::GetKeyWord( const TCollection_AsciiString& key ) const
168 {
169   TCollection_AsciiString keyWord;
170   if ( myKeyWord.IsBound( key ) )
171     keyWord = myKeyWord.Find( key );
172   return keyWord;
173 }
174
175 /*!
176   \brief Register the pair of the internal key \a key and XML keyword \a keyWord.
177   \param key internal key
178   \param keyWord XML keyword
179 */
180 void DDS_KeyWords::SetKeyWord( const TCollection_AsciiString& key,
181                                const TCollection_AsciiString& keyWord )
182 {
183   if ( myKeyWord.IsBound( key ) )
184     myKeyWord.UnBind( key );
185
186   myKeyWord.Bind( key, keyWord );
187 }