1 -- Created on: 1993-03-26
2 -- Created by: Christian CAILLET
3 -- Copyright (c) 1993-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
6 -- The content of this file is subject to the Open CASCADE Technology Public
7 -- License Version 6.5 (the "License"). You may not use the content of this file
8 -- except in compliance with the License. Please obtain a copy of the License
9 -- at http://www.opencascade.org and read it completely before using this file.
11 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 -- The Original Code and all software distributed under the License is
15 -- distributed on an "AS IS" basis, without warranty of any kind, and the
16 -- Initial Developer hereby disclaims all such warranties, including without
17 -- limitation, any warranties of merchantability, fitness for a particular
18 -- purpose or non-infringement. Please see the License for the specific terms
19 -- and conditions governing the rights and limitations under the License.
23 deferred class SelectType from StepData -- inherits Storable
25 ---Purpose : SelectType is the basis used for SELECT_TYPE definitions from
26 -- the EXPRESS form. A SELECT_TYPE in EXPRESS is an enumeration
27 -- of Types, it corresponds in a way to a Super-Type, but with
28 -- no specific Methods, and no exclusivity (a given Type can be
29 -- member of several SELECT_TYPES, plus be itself a SUB_TYPE).
31 -- A SelectType can be field of a Transient Entity (it is itself
32 -- Storable) or only used to control an input Argument
34 -- This class implies to designate each member Type by a Case
35 -- Number which is a positive Integer value (this allows a faster
38 -- With this class, a specific SelectType can :
39 -- - recognize an Entity as complying or not with its definition,
40 -- - storing it, with the garanty that the stored Entity complies
41 -- with the definition of the SelectType
42 -- - and (if judged useful) give the stored Entity under the good
43 -- Type rather than simply "Transient".
45 uses CString, Transient, Type, Logical, SelectMember, PDescr
51 CaseNum (me; ent : Transient) returns Integer is deferred;
52 ---Purpose : Recognizes the Type of an Entity. Returns a positive Number
53 -- which identifies the Type in the definition List of the
54 -- SelectType. Returns Zero if its Type in not in this List.
56 Matches (me; ent : Transient) returns Boolean;
57 ---Purpose : Returns True if the Type of an Entity complies with the
58 -- definition list of the SelectType.
59 -- Also checks for a SelectMember
60 -- Default Implementation looks for CaseNum or CaseMem positive
62 SetValue (me : in out; ent : any Transient)
63 ---Purpose : Stores an Entity. This allows to define a specific SelectType
64 -- class with one read method per member Type, which returns the
65 -- Value casted with the good Type.
66 raises TypeMismatch is static;
67 -- Error if <ent> does not match the definition List of Types.
69 Nullify (me : in out) is static;
70 ---Purpose : Nullifies the Stored Entity
72 Value (me) returns any Transient is static;
73 ---Purpose : Returns the Stored Entity. Can be used to define specific
74 -- read methods (see above)
75 ---C++ : return const &
77 IsNull (me) returns Boolean is static;
78 ---Purpose : Returns True if there is no Stored Entity (i.e. it is Null)
80 -- Entity (plain Transient)
82 Type (me) returns Type is static;
83 ---Purpose : Returns the Effective (Dynamic) Type of the Stored Entity
84 -- If it is Null, returns TYPE(Transient)
86 CaseNumber (me) returns Integer is static;
87 ---Purpose : Recognizes the Type of the stored Entity, or zero if it is
88 -- Null or SelectMember. Calls the first method CaseNum on Value
90 -- Others (through a SelectMember)
92 Description (me) returns PDescr is virtual;
93 ---Purpose : Returns the Description which corresponds to <me>
94 -- Null if no specific description to give. This description is
95 -- used to control reading an check validity.
96 -- Default returns a Null Handle, i.e. undefined description
97 -- It can suffice if CaseNum and CaseMem give enough control
99 NewMember (me) returns SelectMember is virtual;
100 ---Purpose : Returns a preferred SelectMember. Default returns a Null
101 -- By default, a SelectMember can be set according to data type
102 -- and Name : it is a SelectNamed if Name is defined
104 -- This method allows to define, for a specific SelectType, a
105 -- specific SelectMember than SelectNamed. For instance for a
106 -- Real plus a Name, a SelectReal plus a case number is a good
107 -- solution, lighter than SelectNamed which is very multipurpose
109 CaseMem (me; ent : SelectMember) returns Integer is virtual;
110 ---Purpose : Recognize a SelectMember (kind, name). Returns a positive
111 -- value which identifies the case in the List of immediate cases
112 -- (distinct from the List of Entity Types). Zero if not
114 -- Default returns 0, saying that no immediate value is allowed
116 CaseMember (me) returns Integer;
117 ---Purpose : Returns the Type of the stored SelectMember, or zero if it is
118 -- Null or Entity. Calls the method CaseMem on Value
120 Member (me) returns SelectMember;
121 ---Purpose : Returns Value as a SelectMember. Null if not a SelectMember
123 SelectName (me) returns CString;
124 ---Purpose : Returns the type name of SelectMember. If no SelectMember or
125 -- with no type name, returns an empty string
126 -- To change it, pass through the SelectMember itself
128 Int (me) returns Integer;
129 ---Purpose : This internal method gives access to a value implemented by an
130 -- Integer (to read it)
132 SetInt (me : in out; val : Integer)
133 ---Purpose : This internal method gives access to a value implemented by an
134 -- Integer (to set it) : a SelectMember MUST ALREADY BE THERE !
135 raises TypeMismatch is static;
137 Integer (me) returns Integer;
138 ---Purpose : Gets the value as an Integer
140 SetInteger (me : in out; val : Integer; name : CString = "")
141 ---Purpose : Sets a new Integer value, with an optional type name
142 -- Warning : If a SelectMember is already set, works on it : value and
143 -- name must then be accepted by this SelectMember
144 raises TypeMismatch is static;
145 -- Error if no Integer value is accepted (see CaseMem)
147 Boolean (me) returns Boolean;
149 SetBoolean (me : in out; val : Boolean; name : CString = "")
150 raises TypeMismatch is static;
152 Logical (me) returns Logical;
154 SetLogical (me : in out; val : Logical; name : CString = "")
155 raises TypeMismatch is static;
157 Real (me) returns Real;
159 SetReal (me : in out; val : Real; name : CString = "")
160 raises TypeMismatch is static;
162 Destroy (me: in out) is virtual;
163 ---C++ : alias "Standard_EXPORT virtual ~StepData_SelectType() { Destroy(); }"
167 thevalue : Transient;