0031004: Coding - eliminate warnings issued by gcc 9.1.0
[occt.git] / src / StepData / StepData_SelectType.hxx
1 // Created on: 1993-03-26
2 // Created by: Christian CAILLET
3 // Copyright (c) 1993-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_SelectType_HeaderFile
18 #define _StepData_SelectType_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_Boolean.hxx>
26 #include <Standard_Type.hxx>
27 #include <Standard_CString.hxx>
28 #include <StepData_Logical.hxx>
29 #include <Standard_Real.hxx>
30 class Standard_Transient;
31 class Standard_TypeMismatch;
32 class StepData_PDescr;
33 class StepData_SelectMember;
34
35
36 //! SelectType is the basis used for SELECT_TYPE definitions from
37 //! the EXPRESS form. A SELECT_TYPE in EXPRESS is an enumeration
38 //! of Types, it corresponds in a way to a Super-Type, but with
39 //! no specific Methods, and no exclusivity (a given Type can be
40 //! member of several SELECT_TYPES, plus be itself a SUB_TYPE).
41 //!
42 //! A SelectType can be field of a Transient Entity or only used
43 //! to control an input Argument
44 //!
45 //! This class implies to designate each member Type by a Case
46 //! Number which is a positive Integer value (this allows a faster
47 //! treatement).
48 //!
49 //! With this class, a specific SelectType can :
50 //! - recognize an Entity as complying or not with its definition,
51 //! - storing it, with the garanty that the stored Entity complies
52 //! with the definition of the SelectType
53 //! - and (if judged useful) give the stored Entity under the good
54 //! Type rather than simply "Transient".
55 class StepData_SelectType 
56 {
57 public:
58
59   DEFINE_STANDARD_ALLOC
60
61   
62   //! Recognizes the Type of an Entity. Returns a positive Number
63   //! which identifies the Type in the definition List of the
64   //! SelectType. Returns Zero if its Type in not in this List.
65   Standard_EXPORT virtual Standard_Integer CaseNum (const Handle(Standard_Transient)& ent) const = 0;
66   
67   //! Returns True if the Type of an Entity complies with the
68   //! definition list of the SelectType.
69   //! Also checks for a SelectMember
70   //! Default Implementation looks for CaseNum  or CaseMem positive
71   Standard_EXPORT Standard_Boolean Matches (const Handle(Standard_Transient)& ent) const;
72   
73   //! Stores an Entity. This allows to define a specific SelectType
74   //! class with one read method per member Type, which returns the
75   //! Value casted with the good Type.
76   Standard_EXPORT void SetValue (const Handle(Standard_Transient)& ent);
77   
78   //! Nullifies the Stored Entity
79   Standard_EXPORT void Nullify();
80   
81   //! Returns the Stored Entity. Can be used to define specific
82   //! read methods (see above)
83   Standard_EXPORT const Handle(Standard_Transient)& Value() const;
84   
85   //! Returns True if there is no Stored Entity (i.e. it is Null)
86   Standard_EXPORT Standard_Boolean IsNull() const;
87   
88   //! Returns the Effective (Dynamic) Type of the Stored Entity
89   //! If it is Null, returns TYPE(Transient)
90   Standard_EXPORT Handle(Standard_Type) Type() const;
91   
92   //! Recognizes the Type of the stored Entity, or zero if it is
93   //! Null or SelectMember. Calls the first method CaseNum on Value
94   Standard_EXPORT Standard_Integer CaseNumber() const;
95   
96   //! Returns the Description which corresponds to <me>
97   //! Null if no specific description to give. This description is
98   //! used to control reading an check validity.
99   //! Default returns a Null Handle, i.e. undefined description
100   //! It can suffice if CaseNum and CaseMem give enough control
101   Standard_EXPORT virtual Handle(StepData_PDescr) Description() const;
102   
103   //! Returns a preferred SelectMember. Default returns a Null
104   //! By default, a SelectMember can be set according to data type
105   //! and Name : it is a SelectNamed if Name is defined
106   //!
107   //! This method allows to define, for a specific SelectType, a
108   //! specific SelectMember than SelectNamed. For instance for a
109   //! Real plus a Name, a SelectReal plus a case number is a good
110   //! solution, lighter than SelectNamed which is very multipurpose
111   Standard_EXPORT virtual Handle(StepData_SelectMember) NewMember() const;
112   
113   //! Recognize a SelectMember (kind, name). Returns a positive
114   //! value which identifies the case in the List of immediate cases
115   //! (distinct from the List of Entity Types). Zero if not
116   //! recognizes
117   //! Default returns 0, saying that no immediate value is allowed
118   Standard_EXPORT virtual Standard_Integer CaseMem (const Handle(StepData_SelectMember)& ent) const;
119   
120   //! Returns the Type of the stored SelectMember, or zero if it is
121   //! Null or Entity. Calls the method CaseMem on Value
122   Standard_EXPORT Standard_Integer CaseMember() const;
123   
124   //! Returns Value as a SelectMember. Null if not a SelectMember
125   Standard_EXPORT Handle(StepData_SelectMember) Member() const;
126   
127   //! Returns the type name of SelectMember. If no SelectMember or
128   //! with no type name, returns an empty string
129   //! To change it, pass through the SelectMember itself
130   Standard_EXPORT Standard_CString SelectName() const;
131   
132   //! This internal method gives access to a value implemented by an
133   //! Integer (to read it)
134   Standard_EXPORT Standard_Integer Int() const;
135   
136   //! This internal method gives access to a value implemented by an
137   //! Integer (to set it) : a SelectMember MUST ALREADY BE THERE !
138   Standard_EXPORT void SetInt (const Standard_Integer val);
139   
140   //! Gets the value as an Integer
141   Standard_EXPORT Standard_Integer Integer() const;
142   
143   //! Sets a new Integer value, with an optional type name
144   //! Warning : If a SelectMember is already set, works on it : value and
145   //! name must then be accepted by this SelectMember
146   Standard_EXPORT void SetInteger (const Standard_Integer val, const Standard_CString name = "");
147   
148   Standard_EXPORT Standard_Boolean Boolean() const;
149   
150   Standard_EXPORT void SetBoolean (const Standard_Boolean val, const Standard_CString name = "");
151   
152   Standard_EXPORT StepData_Logical Logical() const;
153   
154   Standard_EXPORT void SetLogical (const StepData_Logical val, const Standard_CString name = "");
155   
156   Standard_EXPORT Standard_Real Real() const;
157   
158   Standard_EXPORT void SetReal (const Standard_Real val, const Standard_CString name = "");
159   
160   Standard_EXPORT virtual ~StepData_SelectType();
161
162 private:
163
164
165
166   Handle(Standard_Transient) thevalue;
167
168
169 };
170
171
172
173
174
175
176
177 #endif // _StepData_SelectType_HeaderFile