0029269: Improvement for thread safety of the STEP translator - cleanup
[occt.git] / src / StepData / StepData_Field.hxx
1 // Created on: 1996-12-16
2 // Created by: Christian CAILLET
3 // Copyright (c) 1996-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 _StepData_Field_HeaderFile
18 #define _StepData_Field_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Integer.hxx>
25 #include <Standard_Real.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <StepData_Logical.hxx>
28 #include <Standard_CString.hxx>
29 class Standard_Transient;
30 class StepData_SelectMember;
31
32
33 //! Defines a generally defined Field for STEP data : can be used
34 //! either in any kind of entity to implement it or in free format
35 //! entities in a "late-binding" mode
36 //! A field can have : no value (or derived), a single value of
37 //! any kind, a list of value : single or double list
38 //!
39 //! When a field is set, this defines its new kind (Integer etc..)
40 //! A single value is immediately set. A list of value is, firstly
41 //! declared as for a kind (Integer String etc), then declared as
42 //! a list with its initial size, after this its items are set
43 //! Also it can be set in once if the HArray is ready
44 class StepData_Field 
45 {
46 public:
47
48   DEFINE_STANDARD_ALLOC
49
50   
51   //! Creates a Field, empty ("no value defined")
52   Standard_EXPORT StepData_Field();
53   
54   //! Creates a Field from another one. If <copy> is True, Handled
55   //! data (Select,String,List, not entities) are copied
56   Standard_EXPORT StepData_Field(const StepData_Field& other, const Standard_Boolean copy = Standard_False);
57   
58   //! Gets the copy of the values of another field
59   Standard_EXPORT void CopyFrom (const StepData_Field& other);
60   
61   //! Clears the field, to set it as "no value defined"
62   //! Just before SetList, predeclares it as "any"
63   //! A Kind can be directly set here to declare a type
64   Standard_EXPORT void Clear (const Standard_Integer kind = 0);
65   
66   //! Codes a Field as derived (no proper value)
67   Standard_EXPORT void SetDerived();
68   
69   //! Directly sets the Integer value, if its Kind matches
70   //! Integer, Boolean, Logical, or Enum (does not change Kind)
71   Standard_EXPORT void SetInt (const Standard_Integer val);
72   
73   //! Sets an Integer value (before SetList* declares it as Integer)
74   Standard_EXPORT void SetInteger (const Standard_Integer val = 0);
75   
76   //! Sets a Boolean value (or predeclares a list as boolean)
77   Standard_EXPORT void SetBoolean (const Standard_Boolean val = Standard_False);
78   
79   //! Sets a Logical Value (or predeclares a list as logical)
80   Standard_EXPORT void SetLogical (const StepData_Logical val = StepData_LFalse);
81   
82   //! Sets a Real    Value (or predeclares a list as Real);
83   Standard_EXPORT void SetReal (const Standard_Real val = 0.0);
84   
85   //! Sets a String  Value (or predeclares a list as String)
86   //! Does not redefine the Kind if it is alread String or Enum
87   Standard_EXPORT void SetString (const Standard_CString val = "");
88   
89   //! Sets an Enum Value (as its integer counterpart)
90   //! (or predeclares a list as Enum)
91   //! If <text> is given , also sets its textual expression
92   //! <val> negative means unknown (known values begin at 0)
93   Standard_EXPORT void SetEnum (const Standard_Integer val = -1, const Standard_CString text = "");
94   
95   //! Sets a SelectMember (for Integer,Boolean,Enum,Real,Logical)
96   //! Hence, the value of the field is accessed through this member
97   Standard_EXPORT void SetSelectMember (const Handle(StepData_SelectMember)& val);
98   
99   //! Sets an Entity Value
100   Standard_EXPORT void SetEntity (const Handle(Standard_Transient)& val);
101   
102   //! Predeclares a list as of entity
103   Standard_EXPORT void SetEntity();
104   
105   //! Declares a field as a list, with an initial size
106   //! Initial lower is defaulted as 1, can be defined
107   //! The list starts empty, typed by the last Set*
108   //! If no Set* before, sets it as "any" (transient/select)
109   Standard_EXPORT void SetList (const Standard_Integer size, const Standard_Integer first = 1);
110   
111   //! Declares a field as an homogeneous square list, with initial
112   //! sizes, and initial lowers
113   Standard_EXPORT void SetList2 (const Standard_Integer siz1, const Standard_Integer siz2, const Standard_Integer f1 = 1, const Standard_Integer f2 = 1);
114   
115   //! Sets an undetermined value : can be String, SelectMember,
116   //! HArray(1-2) ... else, an Entity
117   //! In case of an HArray, determines and records its size(s)
118   Standard_EXPORT void Set (const Handle(Standard_Transient)& val);
119   
120   //! Declares an item of the list as undefined
121   //! (ignored if list not defined as String,Entity or Any)
122   Standard_EXPORT void ClearItem (const Standard_Integer num);
123   
124   //! Internal access to an Integer Value for a list, plus its kind
125   Standard_EXPORT void SetInt (const Standard_Integer num, const Standard_Integer val, const Standard_Integer kind);
126   
127   //! Sets an Integer Value for a list (rank num)
128   //! (recognizes a SelectMember)
129   Standard_EXPORT void SetInteger (const Standard_Integer num, const Standard_Integer val);
130   
131   Standard_EXPORT void SetBoolean (const Standard_Integer num, const Standard_Boolean val);
132   
133   Standard_EXPORT void SetLogical (const Standard_Integer num, const StepData_Logical val);
134   
135   //! Sets an Enum Value (Integer counterpart), also its text
136   //! expression if known (if list has been set as "any")
137   Standard_EXPORT void SetEnum (const Standard_Integer num, const Standard_Integer val, const Standard_CString text = "");
138   
139   Standard_EXPORT void SetReal (const Standard_Integer num, const Standard_Real val);
140   
141   Standard_EXPORT void SetString (const Standard_Integer num, const Standard_CString val);
142   
143   Standard_EXPORT void SetEntity (const Standard_Integer num, const Handle(Standard_Transient)& val);
144   
145   Standard_EXPORT Standard_Boolean IsSet (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
146   
147   //! Returns the kind of an item in a list or double list
148   //! It is the kind of the list, except if it is "Any", in such a
149   //! case the true kind is determined and returned
150   Standard_EXPORT Standard_Integer ItemKind (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
151   
152   //! Returns the kind of the field
153   //! <type> True (D) : returns only the type itself
154   //! else, returns the complete kind
155   Standard_EXPORT Standard_Integer Kind (const Standard_Boolean type = Standard_True) const;
156   
157   Standard_EXPORT Standard_Integer Arity() const;
158   
159   Standard_EXPORT Standard_Integer Length (const Standard_Integer index = 1) const;
160   
161   Standard_EXPORT Standard_Integer Lower (const Standard_Integer index = 1) const;
162   
163   Standard_EXPORT Standard_Integer Int() const;
164   
165   Standard_EXPORT Standard_Integer Integer (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
166   
167   Standard_EXPORT Standard_Boolean Boolean (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
168   
169   Standard_EXPORT StepData_Logical Logical (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
170   
171   Standard_EXPORT Standard_Real Real (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
172   
173   Standard_EXPORT Standard_CString String (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
174   
175   Standard_EXPORT Standard_Integer Enum (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
176   
177   Standard_EXPORT Standard_CString EnumText (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
178   
179   Standard_EXPORT Handle(Standard_Transient) Entity (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
180   
181   Standard_EXPORT Handle(Standard_Transient) Transient() const;
182
183
184
185
186 protected:
187
188
189
190
191
192 private:
193
194
195
196   Standard_Integer thekind;
197   Standard_Integer theint;
198   Standard_Real thereal;
199   Handle(Standard_Transient) theany;
200
201
202 };
203
204
205
206
207
208
209
210 #endif // _StepData_Field_HeaderFile