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
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 _StepData_Field_HeaderFile
18 #define _StepData_Field_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
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;
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
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
51 //! Creates a Field, empty ("no value defined")
52 Standard_EXPORT StepData_Field();
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);
58 //! Gets the copy of the values of another field
59 Standard_EXPORT void CopyFrom (const StepData_Field& other);
62 StepData_Field& operator= (const StepData_Field& theOther)
68 //! Clears the field, to set it as "no value defined"
69 //! Just before SetList, predeclares it as "any"
70 //! A Kind can be directly set here to declare a type
71 Standard_EXPORT void Clear (const Standard_Integer kind = 0);
73 //! Codes a Field as derived (no proper value)
74 Standard_EXPORT void SetDerived();
76 //! Directly sets the Integer value, if its Kind matches
77 //! Integer, Boolean, Logical, or Enum (does not change Kind)
78 Standard_EXPORT void SetInt (const Standard_Integer val);
80 //! Sets an Integer value (before SetList* declares it as Integer)
81 Standard_EXPORT void SetInteger (const Standard_Integer val = 0);
83 //! Sets a Boolean value (or predeclares a list as boolean)
84 Standard_EXPORT void SetBoolean (const Standard_Boolean val = Standard_False);
86 //! Sets a Logical Value (or predeclares a list as logical)
87 Standard_EXPORT void SetLogical (const StepData_Logical val = StepData_LFalse);
89 //! Sets a Real Value (or predeclares a list as Real);
90 Standard_EXPORT void SetReal (const Standard_Real val = 0.0);
92 //! Sets a String Value (or predeclares a list as String)
93 //! Does not redefine the Kind if it is alread String or Enum
94 Standard_EXPORT void SetString (const Standard_CString val = "");
96 //! Sets an Enum Value (as its integer counterpart)
97 //! (or predeclares a list as Enum)
98 //! If <text> is given , also sets its textual expression
99 //! <val> negative means unknown (known values begin at 0)
100 Standard_EXPORT void SetEnum (const Standard_Integer val = -1, const Standard_CString text = "");
102 //! Sets a SelectMember (for Integer,Boolean,Enum,Real,Logical)
103 //! Hence, the value of the field is accessed through this member
104 Standard_EXPORT void SetSelectMember (const Handle(StepData_SelectMember)& val);
106 //! Sets an Entity Value
107 Standard_EXPORT void SetEntity (const Handle(Standard_Transient)& val);
109 //! Predeclares a list as of entity
110 Standard_EXPORT void SetEntity();
112 //! Declares a field as a list, with an initial size
113 //! Initial lower is defaulted as 1, can be defined
114 //! The list starts empty, typed by the last Set*
115 //! If no Set* before, sets it as "any" (transient/select)
116 Standard_EXPORT void SetList (const Standard_Integer size, const Standard_Integer first = 1);
118 //! Declares a field as an homogeneous square list, with initial
119 //! sizes, and initial lowers
120 Standard_EXPORT void SetList2 (const Standard_Integer siz1, const Standard_Integer siz2, const Standard_Integer f1 = 1, const Standard_Integer f2 = 1);
122 //! Sets an undetermined value : can be String, SelectMember,
123 //! HArray(1-2) ... else, an Entity
124 //! In case of an HArray, determines and records its size(s)
125 Standard_EXPORT void Set (const Handle(Standard_Transient)& val);
127 //! Declares an item of the list as undefined
128 //! (ignored if list not defined as String,Entity or Any)
129 Standard_EXPORT void ClearItem (const Standard_Integer num);
131 //! Internal access to an Integer Value for a list, plus its kind
132 Standard_EXPORT void SetInt (const Standard_Integer num, const Standard_Integer val, const Standard_Integer kind);
134 //! Sets an Integer Value for a list (rank num)
135 //! (recognizes a SelectMember)
136 Standard_EXPORT void SetInteger (const Standard_Integer num, const Standard_Integer val);
138 Standard_EXPORT void SetBoolean (const Standard_Integer num, const Standard_Boolean val);
140 Standard_EXPORT void SetLogical (const Standard_Integer num, const StepData_Logical val);
142 //! Sets an Enum Value (Integer counterpart), also its text
143 //! expression if known (if list has been set as "any")
144 Standard_EXPORT void SetEnum (const Standard_Integer num, const Standard_Integer val, const Standard_CString text = "");
146 Standard_EXPORT void SetReal (const Standard_Integer num, const Standard_Real val);
148 Standard_EXPORT void SetString (const Standard_Integer num, const Standard_CString val);
150 Standard_EXPORT void SetEntity (const Standard_Integer num, const Handle(Standard_Transient)& val);
152 Standard_EXPORT Standard_Boolean IsSet (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
154 //! Returns the kind of an item in a list or double list
155 //! It is the kind of the list, except if it is "Any", in such a
156 //! case the true kind is determined and returned
157 Standard_EXPORT Standard_Integer ItemKind (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
159 //! Returns the kind of the field
160 //! <type> True (D) : returns only the type itself
161 //! else, returns the complete kind
162 Standard_EXPORT Standard_Integer Kind (const Standard_Boolean type = Standard_True) const;
164 Standard_EXPORT Standard_Integer Arity() const;
166 Standard_EXPORT Standard_Integer Length (const Standard_Integer index = 1) const;
168 Standard_EXPORT Standard_Integer Lower (const Standard_Integer index = 1) const;
170 Standard_EXPORT Standard_Integer Int() const;
172 Standard_EXPORT Standard_Integer Integer (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
174 Standard_EXPORT Standard_Boolean Boolean (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
176 Standard_EXPORT StepData_Logical Logical (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
178 Standard_EXPORT Standard_Real Real (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
180 Standard_EXPORT Standard_CString String (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
182 Standard_EXPORT Standard_Integer Enum (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
184 Standard_EXPORT Standard_CString EnumText (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
186 Standard_EXPORT Handle(Standard_Transient) Entity (const Standard_Integer n1 = 1, const Standard_Integer n2 = 1) const;
188 Standard_EXPORT Handle(Standard_Transient) Transient() const;
203 Standard_Integer thekind;
204 Standard_Integer theint;
205 Standard_Real thereal;
206 Handle(Standard_Transient) theany;
217 #endif // _StepData_Field_HeaderFile