Salome HOME
Copyright update 2022
[modules/gui.git] / src / DDS / DDS_KeyWords.cxx
1 // Copyright (C) 2007-2022  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, or (at your option) any later version.
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_RTTIEXT(DDS_KeyWords, Standard_Transient)
26
27 /*!
28   \class DDS_KeyWords
29   \brief This class defines the pairs of internal keys and XML tags or 
30   attributes names. 
31
32   This class allows user to define a set of XML keywords used in the datums
33   definition (XML) file.
34
35   Default keywords table:
36   - \c D_URI - dictionary
37   - \c COMPONENT - component
38   - \c COMPONENT_NAME - name
39   - \c UNIT_SYSTEMS - unitSystems
40   - \c UNIT_SYSTEM - system
41   - \c UNIT_SYSTEM_NAME - name
42   - \c UNIT_SYSTEM_LABEL - label
43   - \c DATUM - datum
44   - \c DATUM_ID - id
45   - \c DATUM_LABEL - label
46   - \c DATUM_UNITS - units
47   - \c DATUM_FORMAT - format
48   - \c DATUM_FILTER - filter
49   - \c DATUM_REQUIRED - required
50   - \c VALUE_LIST - valueList
51   - \c VALUE_LIST_ID - listid
52   - \c VALUE_LIST_NAME - name
53   - \c VALUE_LIST_TYPE - type
54   - \c VALUE_LIST_VALUE - value
55   - \c VALUE_LIST_VALUEID - id
56   - \c VALUE_LIST_VALUEICON - icon
57   - \c DY_DOMAIN - domain
58   - \c WARNING_LEVEL - warningLevel
59   - \c WRONG_VALUE - wrongValue
60   - \c VALUE_DESCR - valueDescr
61   - \c VALUE_LIST_REF - listRef
62   - \c DESCR - description
63   - \c LONG_D - longDescr
64   - \c SHORT_D - shortDescr
65   - \c VD_TYPE - type
66   - \c VD_DEFV - default
67   - \c VD_MAXV - max
68   - \c VD_MINV - min
69   - \c VD_SPEC - specVal
70   - \c VLR_LIST - list
71   - \c PRS - presentation
72   - \c LATERAL_ZOOM - lateralZoom
73   - \c LZ_MINV - min
74   - \c LZ_MAXV - max
75   - \c LZ_ORDER - order
76   - \c OPTIONS - options
77   - \c OPTION - option
78   - \c OPTION_NAME - name
79
80   There is the only instance of the class DDS_KeyWords in the application
81   which can be retrieved by method Get().
82 */
83
84 /*!
85   \brief Constructor. 
86   Create an instance of the object. Can not be used directly.
87   Use Get() method instead.
88 */
89 DDS_KeyWords::DDS_KeyWords()
90 : Standard_Transient()
91 {
92   SetKeyWord( "D_URI",                "dictionary" );
93
94   SetKeyWord( "COMPONENT",            "component" );
95   SetKeyWord( "COMPONENT_NAME",       "name" );
96
97   SetKeyWord( "UNIT_SYSTEMS",         "unitSystems" );
98   SetKeyWord( "UNIT_SYSTEM",          "system" );
99   SetKeyWord( "UNIT_SYSTEM_NAME",     "name" );
100   SetKeyWord( "UNIT_SYSTEM_LABEL",    "label" );
101
102   SetKeyWord( "DATUM",                "datum" );
103   SetKeyWord( "DATUM_ID",             "id" );
104   SetKeyWord( "DATUM_LABEL",          "label" );
105   SetKeyWord( "DATUM_UNITS",          "units" );
106   SetKeyWord( "DATUM_FORMAT",         "format" );
107   SetKeyWord( "DATUM_FILTER",         "filter" );
108   SetKeyWord( "DATUM_REQUIRED",       "required" );
109
110   SetKeyWord( "VALUE_LIST",           "valueList" );
111   SetKeyWord( "VALUE_LIST_ID",        "listid" );
112   SetKeyWord( "VALUE_LIST_NAME",      "name" );
113   SetKeyWord( "VALUE_LIST_TYPE",      "type" );
114   SetKeyWord( "VALUE_LIST_VALUE",     "value" );
115   SetKeyWord( "VALUE_LIST_VALUEID",   "id" );
116   SetKeyWord( "VALUE_LIST_VALUEICON", "icon" );
117
118   SetKeyWord( "DY_DOMAIN",            "domain" );
119   SetKeyWord( "WARNING_LEVEL",        "warningLevel" );
120   SetKeyWord( "WRONG_VALUE",          "wrongValue" );
121   SetKeyWord( "VALUE_DESCR",          "valueDescr" );
122   SetKeyWord( "VALUE_LIST_REF",       "listRef" );
123
124   SetKeyWord( "DESCR",                "description" );
125   SetKeyWord( "LONG_D",               "longDescr" );
126   SetKeyWord( "SHORT_D",              "shortDescr" );
127
128   SetKeyWord( "VD_TYPE",              "type" );
129   SetKeyWord( "VD_DEFV",              "default" );
130   SetKeyWord( "VD_MAXV",              "max" );
131   SetKeyWord( "VD_MINV",              "min" );
132   SetKeyWord( "VD_SPEC",              "specVal" );
133   SetKeyWord( "VLR_LIST",             "list" );
134   SetKeyWord( "PRS",                  "presentation" );
135   SetKeyWord( "LATERAL_ZOOM",         "lateralZoom" );
136   SetKeyWord( "LZ_MINV",              "min" );
137   SetKeyWord( "LZ_MAXV",              "max" );
138   SetKeyWord( "LZ_ORDER",             "order" );
139
140   SetKeyWord( "OPTIONS",              "options" );
141   SetKeyWord( "OPTION",               "option" );
142   SetKeyWord( "OPTION_NAME",          "name" );
143 }
144
145 /*!
146   \brief Get the only instance of the class DDS_KeyWords.
147   \return the only instance of the class
148 */
149 Handle(DDS_KeyWords) DDS_KeyWords::Get()
150 {
151   static Handle(DDS_KeyWords) keyWords;
152
153   if ( keyWords.IsNull() )
154     keyWords = new DDS_KeyWords();
155
156   return keyWords;
157 }
158
159 /*!
160   \brief Get the XML keyword by specified internal key \a key.
161
162   If the internal key is not registered, empty string is returned.
163   \param key internal key
164   \return XML keyword 
165 */
166 TCollection_AsciiString DDS_KeyWords::GetKeyWord( const TCollection_AsciiString& key ) const
167 {
168   TCollection_AsciiString keyWord;
169   if ( myKeyWord.IsBound( key ) )
170     keyWord = myKeyWord.Find( key );
171   return keyWord;
172 }
173
174 /*!
175   \brief Register the pair of the internal key \a key and XML keyword \a keyWord.
176   \param key internal key
177   \param keyWord XML keyword
178 */
179 void DDS_KeyWords::SetKeyWord( const TCollection_AsciiString& key,
180                                const TCollection_AsciiString& keyWord )
181 {
182   if ( myKeyWord.IsBound( key ) )
183     myKeyWord.UnBind( key );
184
185   myKeyWord.Bind( key, keyWord );
186 }