1 // Created on: 1997-01-03
2 // Created by: Christian CAILLET
3 // Copyright (c) 1997-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_PDescr_HeaderFile
18 #define _StepData_PDescr_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <TCollection_AsciiString.hxx>
24 #include <Standard_Integer.hxx>
25 #include <StepData_EnumTool.hxx>
26 #include <Standard_Type.hxx>
27 #include <Standard_Boolean.hxx>
28 #include <MMgt_TShared.hxx>
29 #include <Standard_CString.hxx>
30 class StepData_EDescr;
32 class Interface_Check;
35 class StepData_PDescr;
36 DEFINE_STANDARD_HANDLE(StepData_PDescr, MMgt_TShared)
38 //! This class is intended to describe the authorized form for a
39 //! parameter, as a type or a value for a field
41 //! A PDescr firstly describes a type, which can be SELECT, i.e.
42 //! have several members
43 class StepData_PDescr : public MMgt_TShared
49 Standard_EXPORT StepData_PDescr();
51 Standard_EXPORT void SetName (const Standard_CString name);
53 Standard_EXPORT Standard_CString Name() const;
55 //! Declares this PDescr to be a Select, hence to have members
56 //! <me> itself can be the first member
57 Standard_EXPORT void SetSelect();
59 //! Adds a member to a SELECT description
60 Standard_EXPORT void AddMember (const Handle(StepData_PDescr)& member);
62 //! Sets a name for SELECT member. To be used if a member is for
64 Standard_EXPORT void SetMemberName (const Standard_CString memname);
66 //! Sets <me> for an Integer value
67 Standard_EXPORT void SetInteger();
69 //! Sets <me> for a Real value
70 Standard_EXPORT void SetReal();
72 //! Sets <me> for a String value
73 Standard_EXPORT void SetString();
75 //! Sets <me> for a Boolean value (false,true)
76 Standard_EXPORT void SetBoolean();
78 //! Sets <me> for a Logical value (false,true,unknown)
79 Standard_EXPORT void SetLogical();
81 //! Sets <me> for an Enum value
82 //! Then, call AddEnumDef ordered from the first one (value 0)
83 Standard_EXPORT void SetEnum();
85 //! Adds an enum value as a string
86 Standard_EXPORT void AddEnumDef (const Standard_CString enumdef);
88 //! Sets <me> for an Entity which must match a Type (early-bound)
89 Standard_EXPORT void SetType (const Handle(Standard_Type)& atype);
91 //! Sets <me> for a Described Entity, whose Description must match
92 //! the type name <dscnam>
93 Standard_EXPORT void SetDescr (const Standard_CString dscnam);
95 //! Adds an arity count to <me>, by default 1
96 //! 1 : a simple field passes to a LIST/ARRAY etc
97 //! or a LIST to a LIST OF LIST
98 //! 2 : a simple field passes to a LIST OF LIST
99 Standard_EXPORT void AddArity (const Standard_Integer arity = 1);
101 //! Directly sets the arity count
103 //! 1 : LIST or ARRAY etc
105 Standard_EXPORT void SetArity (const Standard_Integer arity = 1);
107 //! Sets <me> as <other> but duplicated
108 //! Hence, some definition may be changed
109 Standard_EXPORT void SetFrom (const Handle(StepData_PDescr)& other);
111 //! Sets/Unsets <me> to accept undefined values
112 Standard_EXPORT void SetOptional (const Standard_Boolean opt = Standard_True);
114 //! Sets/Unsets <me> to be for a derived field
115 Standard_EXPORT void SetDerived (const Standard_Boolean der = Standard_True);
117 //! Sets <me> to describe a field of an entity
118 //! With a name and a rank
119 Standard_EXPORT void SetField (const Standard_CString name, const Standard_Integer rank);
121 //! Tells if <me> is for a SELECT
122 Standard_EXPORT Standard_Boolean IsSelect() const;
124 //! For a SELECT, returns the member whose name matches <name>
125 //! To this member, the following question can then be asked
126 //! Null Handle if <name> not matched or <me> not a SELECT
128 //! Remark : not to be asked for an entity type
129 //! Hence, following IsInteger .. Enum* only apply on <me> and
131 //! While IsType applies on <me> and all Select Members
132 Standard_EXPORT Handle(StepData_PDescr) Member (const Standard_CString name) const;
134 //! Tells if <me> is for an Integer
135 Standard_EXPORT Standard_Boolean IsInteger() const;
137 //! Tells if <me> is for a Real value
138 Standard_EXPORT Standard_Boolean IsReal() const;
140 //! Tells if <me> is for a String value
141 Standard_EXPORT Standard_Boolean IsString() const;
143 //! Tells if <me> is for a Boolean value (false,true)
144 Standard_EXPORT Standard_Boolean IsBoolean() const;
146 //! Tells if <me> is for a Logical value (false,true,unknown)
147 Standard_EXPORT Standard_Boolean IsLogical() const;
149 //! Tells if <me> is for an Enum value
150 //! Then, call AddEnumDef ordered from the first one (value 0)
151 //! Managed by an EnumTool
152 Standard_EXPORT Standard_Boolean IsEnum() const;
154 //! Returns the maximum integer for a suitable value (count - 1)
155 Standard_EXPORT Standard_Integer EnumMax() const;
157 //! Returns the numeric value found for an enum text
158 //! The text must be in capitals and limited by dots
159 //! A non-suitable text gives a negative value to be returned
160 Standard_EXPORT Standard_Integer EnumValue (const Standard_CString name) const;
162 //! Returns the text which corresponds to a numeric value,
163 //! between 0 and EnumMax. It is limited by dots
164 Standard_EXPORT Standard_CString EnumText (const Standard_Integer val) const;
166 //! Tells if <me> is for an Entity, either Described or CDL Type
167 Standard_EXPORT Standard_Boolean IsEntity() const;
169 //! Tells if <me> is for an entity of a given CDL type (early-bnd)
170 //! (works for <me> + nexts if <me> is a Select)
171 Standard_EXPORT Standard_Boolean IsType (const Handle(Standard_Type)& atype) const;
173 //! Returns the type to match (IsKind), for a CDL Entity
174 //! (else, null handle)
175 Standard_EXPORT Handle(Standard_Type) Type() const;
177 //! Tells if <me> is for a Described entity of a given EDescr
178 //! (does this EDescr match description name ?). For late-bnd
179 //! (works for <me> + nexts if <me> is a Select)
180 Standard_EXPORT Standard_Boolean IsDescr (const Handle(StepData_EDescr)& descr) const;
182 //! Returns the description (type name) to match, for a Described
183 //! (else, empty string)
184 Standard_EXPORT Standard_CString DescrName() const;
186 //! Returns the arity of <me>
187 Standard_EXPORT Standard_Integer Arity() const;
189 //! For a LIST or LIST OF LIST, Returns the PDescr for the simpler
190 //! PDescr. Else, returns <me>
191 //! This allows to have different attributes for Optional for
192 //! instance, on a field, and on the parameter of a LIST :
193 //! [OPTIONAL] LIST OF [OPTIONAL] ...
194 Standard_EXPORT Handle(StepData_PDescr) Simple() const;
196 //! Tells if <me> is Optional
197 Standard_EXPORT Standard_Boolean IsOptional() const;
199 //! Tells if <me> is Derived
200 Standard_EXPORT Standard_Boolean IsDerived() const;
202 //! Tells if <me> is a Field. Else it is a Type
203 Standard_EXPORT Standard_Boolean IsField() const;
205 Standard_EXPORT Standard_CString FieldName() const;
207 Standard_EXPORT Standard_Integer FieldRank() const;
209 //! Semantic Check of a Field : does it complies with the given
211 Standard_EXPORT virtual void Check (const StepData_Field& afild, Handle(Interface_Check)& ach) const;
216 DEFINE_STANDARD_RTTI(StepData_PDescr,MMgt_TShared)
226 Standard_EXPORT Standard_Integer Kind() const;
228 TCollection_AsciiString thename;
229 Standard_Integer thesel;
230 TCollection_AsciiString thesnam;
231 Handle(StepData_PDescr) thenext;
232 Standard_Integer thekind;
233 StepData_EnumTool theenum;
234 Handle(Standard_Type) thetype;
235 TCollection_AsciiString thednam;
236 Standard_Integer thearit;
237 Handle(StepData_PDescr) thefrom;
238 Standard_Boolean theopt;
239 Standard_Boolean theder;
240 TCollection_AsciiString thefnam;
241 Standard_Integer thefnum;
252 #endif // _StepData_PDescr_HeaderFile