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