1 -- File: Interface_Static.cdl
2 -- Created: Fri Dec 8 08:36:26 1995
3 -- Author: Christian CAILLET
5 ---Copyright: Matra Datavision 1995
8 class Static from Interface inherits TypedValue from Interface
10 ---Purpose : This class gives a way to manage meaningfull static variables,
11 -- used as "global" parameters in various procedures.
13 -- A Static brings a specification (its type, constraints if any)
14 -- and a value. Its basic form is a string, it can be specified
15 -- as integer or real or enumerative string, and queried as such.
16 -- Its string content, which is a Handle(HAsciiString) can be
17 -- shared by other data structures, hence gives a direct on line
18 -- access to its value.
20 -- All this description is inherited from TypedValue
22 -- A Static can be given an initial value, it can be filled from,
23 -- either a set of Resources (an applicative feature which
24 -- accesses and manages parameter files), or environment or
25 -- internal definition : these define families of Static.
26 -- In addition, it supports a status for reinitialisation : an
27 -- initialisation procedure can ask if the value of the Static
28 -- has changed from its last call, in this case does something
29 -- then marks the Status "uptodate", else it does nothing.
31 -- Statics are named and recorded then accessed in an alphabetic
34 uses CString, Type from Standard,
35 Messenger from Message,
36 AsciiString from TCollection, HAsciiString from TCollection,
37 HSequenceOfAsciiString from TColStd, HArray1OfAsciiString from TColStd,
38 HSequenceOfHAsciiString from TColStd,
39 DictionaryOfInteger from Dico,
40 ParamType from Interface , StaticSatisfies from Interface
46 Create (family, name : CString;
47 type : ParamType from Interface = Interface_ParamText;
48 init : CString = "") returns mutable Static
49 ---Purpose : Creates and records a Static, with a family and a name
50 -- family can report to a name of ressource or to a system or
51 -- internal definition. The name must be unique.
53 -- type gives the type of the parameter, default is free text
54 -- Also available : Integer, Real, Enum, Entity (i.e. Object)
55 -- More precise specifications, titles, can be given to the
56 -- Static once created
58 -- init gives an initial value. If it is not given, the Static
59 -- begin as "not set", its value is empty
60 raises InterfaceError;
61 -- Error if <name> is already recorded, or <type> not supported
62 -- See also class method Init
64 Create (family, name : CString; other : Static) returns mutable Static;
65 ---Purpose : Creates a new Static with same definition as another one
66 -- (value is copied, except for Entity : it remains null)
68 PrintStatic (me; S : Messenger from Message);
69 ---Purpose : Writes the properties of a
70 -- parameter in the diagnostic file. These include:
73 -- - Wildcard (if it has one)
74 -- - Current status (empty string if it was updated or
75 -- if it is the original one)
78 Family (me) returns CString;
79 ---Purpose : Returns the family. It can be : a resource name for applis,
80 -- an internal name between : $e (environment variables),
81 -- $l (other, purely local)
83 SetWild (me : mutable; wildcard : Static);
84 ---Purpose : Sets a "wild-card" static : its value will be considered
85 -- if <me> is not properly set. (reset by set a null one)
87 Wild (me) returns Static;
88 ---Purpose : Returns the wildcard static, which can be (is most often) null
90 -- -- Update Status -- --
92 SetUptodate (me : mutable);
93 ---Purpose : Records a Static has "uptodate", i.e. its value has been taken
94 -- into account by a reinitialisation procedure
95 -- This flag is reset at each successful SetValue
97 UpdatedStatus (me) returns Boolean;
98 ---Purpose : Returns the status "uptodate"
101 -- -- Class methods : dictionary of statics -- --
104 Init (myclass; family, name : CString;
105 type : ParamType from Interface;
106 init : CString = "") returns Boolean;
107 ---Purpose : Declares a new Static (by calling its constructor)
108 -- If this name is already taken, does nothing and returns False
109 -- Else, creates it and returns True
110 -- For additional definitions, get the Static then edit it
112 Init (myclass; family, name : CString;
114 init : CString = "") returns Boolean;
115 ---Purpose : As Init with ParamType, but type is given as a character
116 -- This allows a simpler call
117 -- Types : 'i' Integer, 'r' Real, 't' Text, 'e' Enum, 'o' Object
118 -- '=' for same definition as, <init> gives the initial Static
119 -- Returns False if <type> does not match this list
121 Static (myclass; name : CString) returns mutable Static;
122 ---Purpose : Returns a Static from its name. Null Handle if not present
124 IsPresent (myclass; name : CString) returns Boolean;
125 ---Purpose : Returns True if a Static named <name> is present, False else
127 CDef (myclass; name : CString; part : CString) returns CString;
128 ---Purpose : Returns a part of the definition of a Static, as a CString
129 -- The part is designated by its name, as a CString
130 -- If the required value is not a string, it is converted to a
131 -- CString then returned
132 -- If <name> is not present, or <part> not defined for <name>,
133 -- this function returns an empty string
135 -- Allowed parts for CDef :
136 -- family : the family
137 -- type : the type ("integer","real","text","enum")
139 -- satis : satisfy function name if any
140 -- rmin : minimum real value
141 -- rmax : maximum real value
142 -- imin : minimum integer value
143 -- imax : maximum integer value
144 -- enum nn (nn : value of an integer) : enum value for nn
145 -- unit : unit definition for a real
147 IDef (myclass; name : CString; part : CString) returns Integer;
148 ---Purpose : Returns a part of the definition of a Static, as an Integer
149 -- The part is designated by its name, as a CString
150 -- If the required value is not a string, returns zero
151 -- For a Boolean, 0 for false, 1 for true
152 -- If <name> is not present, or <part> not defined for <name>,
153 -- this function returns zero
155 -- Allowed parts for IDef :
156 -- imin, imax : minimum or maximum integer value
157 -- estart : starting number for enum
158 -- ecount : count of enum values (starting from estart)
159 -- ematch : exact match status
160 -- eval val : case determined from a string
162 -- Querying and Setting --
163 -- (must useful ones; for other, see methods of instance above)
165 IsSet (myclass; name : CString; proper : Boolean = Standard_True)
167 ---Purpose : Returns True if <name> is present AND set
168 -- <proper> True (D) : considers this item only
169 -- <proper> False : if not set and attached to a wild-card,
170 -- considers this wild-card
172 CVal (myclass; name : CString) returns CString;
173 ---Purpose : Returns the value of the
174 -- parameter identified by the string name.
175 -- If the specified parameter does not exist, an empty
176 -- string is returned.
178 -- Interface_Static::CVal("write.step.schema");
179 -- which could return:
182 IVal (myclass; name : CString) returns Integer;
183 ---Purpose : Returns the integer value of
184 -- the translation parameter identified by the string name.
185 -- Returns the value 0 if the parameter does not exist.
187 -- Interface_Static::IVal("write.step.schema");
188 -- which could return: 3
189 RVal (myclass; name : CString) returns Real;
190 ---Purpose : Returns the value of a static
191 -- translation parameter identified by the string name.
192 -- Returns the value 0.0 if the parameter does not exist.
193 SetCVal (myclass; name : CString; val : CString) returns Boolean;
194 ---Purpose : Modifies the value of the
195 -- parameter identified by name. The modification is specified
196 -- by the string val. false is returned if the parameter does not exist.
198 -- Interface_Static::SetCVal
199 -- ("write.step.schema","AP203")
200 -- This syntax specifies a switch from the default STEP 214 mode to STEP 203 mode.
202 SetIVal (myclass; name : CString; val : Integer) returns Boolean;
203 ---Purpose : Modifies the value of the
204 -- parameter identified by name. The modification is specified
205 -- by the integer value val. false is returned if the
206 -- parameter does not exist.
208 -- Interface_Static::SetIVal
209 -- ("write.step.schema", 3)
210 -- This syntax specifies a switch from the default STEP 214 mode to STEP 203 mode.S
212 SetRVal (myclass; name : CString; val : Real) returns Boolean;
213 ---Purpose : Modifies the value of a
214 -- translation parameter. false is returned if the
215 -- parameter does not exist. The modification is specified
216 -- by the real number value val.
218 Update (myclass; name : CString) returns Boolean;
219 ---Purpose : Sets a Static to be "uptodate"
220 -- Returns False if <name> is not present
221 -- This status can be used by a reinitialisation procedure to
222 -- rerun if a value has been changed
224 IsUpdated (myclass; name : CString) returns Boolean;
225 ---Purpose : Returns the status "uptodate" from a Static
226 -- Returns False if <name> is not present
228 Items (myclass; mode : Integer = 0; criter : CString = "") returns HSequenceOfHAsciiString;
229 ---Purpose : Returns a list of names of statics :
230 -- <mode> = 0 (D) : criter is for family
231 -- <mode> = 1 : criter is regexp on names, takes final items
232 -- (ignore wild cards)
233 -- <mode> = 2 : idem but take only wilded, not final items
234 -- <mode> = 3 : idem, take all items matching criter
235 -- idem + 100 : takes only non-updated items
236 -- idem + 200 : takes only updated items
237 -- criter empty (D) : returns all names
238 -- else returns names which match the given criter
239 -- Remark : families beginning by '$' are not listed by criter ""
240 -- they are listed only by criter "$"
242 -- This allows for instance to set new values after having loaded
243 -- or reloaded a resource, then to update them as required
245 -- A special class method : initialisation of standard statics
248 ---Purpose : Initializes all standard static parameters, which can be used
249 -- by every function. statics specific of a norm or a function
250 -- must be defined around it
254 thefamily : AsciiString;
255 thename : AsciiString;
256 thelabel : AsciiString;
257 thetype : ParamType from Interface;
258 theotyp : Type from Standard; -- for object
261 thelims : Integer; -- status for integer/enum/real limits
266 theunidef : AsciiString;
268 theenums : HArray1OfAsciiString from TColStd;
269 theeadds : DictionaryOfInteger;
271 thesatisf : StaticSatisfies;
272 thesatisn : AsciiString;
276 thehval : HAsciiString from TCollection;