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