42cf5bc1 |
1 | // Created on: 1995-12-08 |
2 | // Created by: Christian CAILLET |
3 | // Copyright (c) 1995-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Interface_Static_HeaderFile |
18 | #define _Interface_Static_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <TCollection_AsciiString.hxx> |
24 | #include <Interface_ParamType.hxx> |
25 | #include <Standard_Type.hxx> |
26 | #include <Standard_Integer.hxx> |
27 | #include <Standard_Real.hxx> |
28 | #include <TColStd_HArray1OfAsciiString.hxx> |
29 | #include <Interface_StaticSatisfies.hxx> |
30 | #include <Standard_Boolean.hxx> |
31 | #include <Interface_TypedValue.hxx> |
32 | #include <Standard_CString.hxx> |
33 | #include <Standard_Character.hxx> |
34 | #include <TColStd_HSequenceOfHAsciiString.hxx> |
42cf5bc1 |
35 | class TCollection_HAsciiString; |
36 | class Standard_Transient; |
37 | class Interface_InterfaceError; |
38 | class Message_Messenger; |
39 | |
40 | |
41 | class Interface_Static; |
42 | DEFINE_STANDARD_HANDLE(Interface_Static, Interface_TypedValue) |
43 | |
44 | //! This class gives a way to manage meaningfull static variables, |
45 | //! used as "global" parameters in various procedures. |
46 | //! |
47 | //! A Static brings a specification (its type, constraints if any) |
48 | //! and a value. Its basic form is a string, it can be specified |
49 | //! as integer or real or enumerative string, and queried as such. |
50 | //! Its string content, which is a Handle(HAsciiString) can be |
51 | //! shared by other data structures, hence gives a direct on line |
52 | //! access to its value. |
53 | //! |
54 | //! All this description is inherited from TypedValue |
55 | //! |
56 | //! A Static can be given an initial value, it can be filled from, |
57 | //! either a set of Resources (an applicative feature which |
58 | //! accesses and manages parameter files), or environment or |
59 | //! internal definition : these define families of Static. |
60 | //! In addition, it supports a status for reinitialisation : an |
61 | //! initialisation procedure can ask if the value of the Static |
62 | //! has changed from its last call, in this case does something |
63 | //! then marks the Status "uptodate", else it does nothing. |
64 | //! |
65 | //! Statics are named and recorded then accessed in an alphabetic |
66 | //! dictionary |
67 | class Interface_Static : public Interface_TypedValue |
68 | { |
69 | |
70 | public: |
71 | |
72 | |
73 | //! Creates and records a Static, with a family and a name |
74 | //! family can report to a name of ressource or to a system or |
75 | //! internal definition. The name must be unique. |
76 | //! |
77 | //! type gives the type of the parameter, default is free text |
78 | //! Also available : Integer, Real, Enum, Entity (i.e. Object) |
79 | //! More precise specifications, titles, can be given to the |
80 | //! Static once created |
81 | //! |
82 | //! init gives an initial value. If it is not given, the Static |
83 | //! begin as "not set", its value is empty |
84 | Standard_EXPORT Interface_Static(const Standard_CString family, const Standard_CString name, const Interface_ParamType type = Interface_ParamText, const Standard_CString init = ""); |
85 | |
86 | //! Creates a new Static with same definition as another one |
87 | //! (value is copied, except for Entity : it remains null) |
88 | Standard_EXPORT Interface_Static(const Standard_CString family, const Standard_CString name, const Handle(Interface_Static)& other); |
89 | |
90 | //! Writes the properties of a |
91 | //! parameter in the diagnostic file. These include: |
92 | //! - Name |
93 | //! - Family, |
94 | //! - Wildcard (if it has one) |
95 | //! - Current status (empty string if it was updated or |
96 | //! if it is the original one) |
97 | //! - Value |
98 | Standard_EXPORT void PrintStatic (const Handle(Message_Messenger)& S) const; |
99 | |
100 | //! Returns the family. It can be : a resource name for applis, |
101 | //! an internal name between : $e (environment variables), |
102 | //! $l (other, purely local) |
103 | Standard_EXPORT Standard_CString Family() const; |
104 | |
105 | //! Sets a "wild-card" static : its value will be considered |
106 | //! if <me> is not properly set. (reset by set a null one) |
107 | Standard_EXPORT void SetWild (const Handle(Interface_Static)& wildcard); |
108 | |
109 | //! Returns the wildcard static, which can be (is most often) null |
110 | Standard_EXPORT Handle(Interface_Static) Wild() const; |
111 | |
112 | //! Records a Static has "uptodate", i.e. its value has been taken |
113 | //! into account by a reinitialisation procedure |
114 | //! This flag is reset at each successful SetValue |
115 | Standard_EXPORT void SetUptodate(); |
116 | |
117 | //! Returns the status "uptodate" |
118 | Standard_EXPORT Standard_Boolean UpdatedStatus() const; |
119 | |
120 | //! Declares a new Static (by calling its constructor) |
121 | //! If this name is already taken, does nothing and returns False |
122 | //! Else, creates it and returns True |
123 | //! For additional definitions, get the Static then edit it |
124 | Standard_EXPORT static Standard_Boolean Init (const Standard_CString family, const Standard_CString name, const Interface_ParamType type, const Standard_CString init = ""); |
125 | |
126 | //! As Init with ParamType, but type is given as a character |
127 | //! This allows a simpler call |
128 | //! Types : 'i' Integer, 'r' Real, 't' Text, 'e' Enum, 'o' Object |
129 | //! '=' for same definition as, <init> gives the initial Static |
130 | //! Returns False if <type> does not match this list |
131 | Standard_EXPORT static Standard_Boolean Init (const Standard_CString family, const Standard_CString name, const Standard_Character type, const Standard_CString init = ""); |
132 | |
133 | //! Returns a Static from its name. Null Handle if not present |
134 | Standard_EXPORT static Handle(Interface_Static) Static (const Standard_CString name); |
135 | |
136 | //! Returns True if a Static named <name> is present, False else |
137 | Standard_EXPORT static Standard_Boolean IsPresent (const Standard_CString name); |
138 | |
139 | //! Returns a part of the definition of a Static, as a CString |
140 | //! The part is designated by its name, as a CString |
141 | //! If the required value is not a string, it is converted to a |
142 | //! CString then returned |
143 | //! If <name> is not present, or <part> not defined for <name>, |
144 | //! this function returns an empty string |
145 | //! |
146 | //! Allowed parts for CDef : |
147 | //! family : the family |
148 | //! type : the type ("integer","real","text","enum") |
149 | //! label : the label |
150 | //! satis : satisfy function name if any |
151 | //! rmin : minimum real value |
152 | //! rmax : maximum real value |
153 | //! imin : minimum integer value |
154 | //! imax : maximum integer value |
155 | //! enum nn (nn : value of an integer) : enum value for nn |
156 | //! unit : unit definition for a real |
157 | Standard_EXPORT static Standard_CString CDef (const Standard_CString name, const Standard_CString part); |
158 | |
159 | //! Returns a part of the definition of a Static, as an Integer |
160 | //! The part is designated by its name, as a CString |
161 | //! If the required value is not a string, returns zero |
162 | //! For a Boolean, 0 for false, 1 for true |
163 | //! If <name> is not present, or <part> not defined for <name>, |
164 | //! this function returns zero |
165 | //! |
166 | //! Allowed parts for IDef : |
167 | //! imin, imax : minimum or maximum integer value |
168 | //! estart : starting number for enum |
169 | //! ecount : count of enum values (starting from estart) |
170 | //! ematch : exact match status |
171 | //! eval val : case determined from a string |
172 | Standard_EXPORT static Standard_Integer IDef (const Standard_CString name, const Standard_CString part); |
173 | |
174 | //! Returns True if <name> is present AND set |
175 | //! <proper> True (D) : considers this item only |
176 | //! <proper> False : if not set and attached to a wild-card, |
177 | //! considers this wild-card |
178 | Standard_EXPORT static Standard_Boolean IsSet (const Standard_CString name, const Standard_Boolean proper = Standard_True); |
179 | |
180 | //! Returns the value of the |
181 | //! parameter identified by the string name. |
182 | //! If the specified parameter does not exist, an empty |
183 | //! string is returned. |
184 | //! Example |
185 | //! Interface_Static::CVal("write.step.schema"); |
186 | //! which could return: |
187 | //! "AP214" |
188 | Standard_EXPORT static Standard_CString CVal (const Standard_CString name); |
189 | |
190 | //! Returns the integer value of |
191 | //! the translation parameter identified by the string name. |
192 | //! Returns the value 0 if the parameter does not exist. |
193 | //! Example |
194 | //! Interface_Static::IVal("write.step.schema"); |
195 | //! which could return: 3 |
196 | Standard_EXPORT static Standard_Integer IVal (const Standard_CString name); |
197 | |
198 | //! Returns the value of a static |
199 | //! translation parameter identified by the string name. |
200 | //! Returns the value 0.0 if the parameter does not exist. |
201 | Standard_EXPORT static Standard_Real RVal (const Standard_CString name); |
202 | |
203 | //! Modifies the value of the |
204 | //! parameter identified by name. The modification is specified |
205 | //! by the string val. false is returned if the parameter does not exist. |
206 | //! Example |
207 | //! Interface_Static::SetCVal |
208 | //! ("write.step.schema","AP203") |
209 | //! This syntax specifies a switch from the default STEP 214 mode to STEP 203 mode. |
210 | Standard_EXPORT static Standard_Boolean SetCVal (const Standard_CString name, const Standard_CString val); |
211 | |
212 | //! Modifies the value of the |
213 | //! parameter identified by name. The modification is specified |
214 | //! by the integer value val. false is returned if the |
215 | //! parameter does not exist. |
216 | //! Example |
217 | //! Interface_Static::SetIVal |
218 | //! ("write.step.schema", 3) |
219 | //! This syntax specifies a switch from the default STEP 214 mode to STEP 203 mode.S |
220 | Standard_EXPORT static Standard_Boolean SetIVal (const Standard_CString name, const Standard_Integer val); |
221 | |
222 | //! Modifies the value of a |
223 | //! translation parameter. false is returned if the |
224 | //! parameter does not exist. The modification is specified |
225 | //! by the real number value val. |
226 | Standard_EXPORT static Standard_Boolean SetRVal (const Standard_CString name, const Standard_Real val); |
227 | |
228 | //! Sets a Static to be "uptodate" |
229 | //! Returns False if <name> is not present |
230 | //! This status can be used by a reinitialisation procedure to |
231 | //! rerun if a value has been changed |
232 | Standard_EXPORT static Standard_Boolean Update (const Standard_CString name); |
233 | |
234 | //! Returns the status "uptodate" from a Static |
235 | //! Returns False if <name> is not present |
236 | Standard_EXPORT static Standard_Boolean IsUpdated (const Standard_CString name); |
237 | |
238 | //! Returns a list of names of statics : |
239 | //! <mode> = 0 (D) : criter is for family |
240 | //! <mode> = 1 : criter is regexp on names, takes final items |
241 | //! (ignore wild cards) |
242 | //! <mode> = 2 : idem but take only wilded, not final items |
243 | //! <mode> = 3 : idem, take all items matching criter |
244 | //! idem + 100 : takes only non-updated items |
245 | //! idem + 200 : takes only updated items |
246 | //! criter empty (D) : returns all names |
247 | //! else returns names which match the given criter |
248 | //! Remark : families beginning by '$' are not listed by criter "" |
249 | //! they are listed only by criter "$" |
250 | //! |
251 | //! This allows for instance to set new values after having loaded |
252 | //! or reloaded a resource, then to update them as required |
253 | Standard_EXPORT static Handle(TColStd_HSequenceOfHAsciiString) Items (const Standard_Integer mode = 0, const Standard_CString criter = ""); |
254 | |
255 | //! Initializes all standard static parameters, which can be used |
256 | //! by every function. statics specific of a norm or a function |
257 | //! must be defined around it |
258 | Standard_EXPORT static void Standards(); |
259 | |
260 | |
261 | |
262 | |
92efcf78 |
263 | DEFINE_STANDARD_RTTIEXT(Interface_Static,Interface_TypedValue) |
42cf5bc1 |
264 | |
265 | protected: |
266 | |
267 | |
268 | |
269 | |
270 | private: |
271 | |
272 | |
273 | TCollection_AsciiString thefamily; |
274 | TCollection_AsciiString thename; |
275 | TCollection_AsciiString thelabel; |
276 | Interface_ParamType thetype; |
277 | Handle(Standard_Type) theotyp; |
278 | Handle(Interface_Static) thewild; |
279 | Standard_Integer thelims; |
280 | Standard_Integer theintlow; |
281 | Standard_Integer theintup; |
282 | Standard_Real therealow; |
283 | Standard_Real therealup; |
284 | TCollection_AsciiString theunidef; |
285 | Handle(TColStd_HArray1OfAsciiString) theenums; |
997e128f |
286 | NCollection_DataMap<TCollection_AsciiString, Standard_Integer> theeadds; |
42cf5bc1 |
287 | Interface_StaticSatisfies thesatisf; |
288 | TCollection_AsciiString thesatisn; |
289 | Standard_Boolean theupdate; |
290 | Standard_Integer theival; |
291 | Handle(TCollection_HAsciiString) thehval; |
292 | Handle(Standard_Transient) theoval; |
293 | |
294 | |
295 | }; |
296 | |
297 | |
298 | |
299 | |
300 | |
301 | |
302 | |
303 | #endif // _Interface_Static_HeaderFile |