1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <Interface_Check.hxx>
16 #include <Standard_Type.hxx>
17 #include <StepData_EDescr.hxx>
18 #include <StepData_Field.hxx>
19 #include <StepData_PDescr.hxx>
21 IMPLEMENT_STANDARD_RTTIEXT(StepData_PDescr,Standard_Transient)
31 StepData_PDescr::StepData_PDescr ()
32 : thesel (0), thekind (0), thearit (0),
33 theopt (Standard_False), theder (Standard_False), thefnum (0)
36 void StepData_PDescr::SetName (const Standard_CString name)
37 { thename.Clear(); thename.AssignCat (name); }
39 Standard_CString StepData_PDescr::Name () const
40 { return thename.ToCString(); }
42 Standard_Integer StepData_PDescr::Kind () const
45 void StepData_PDescr::SetSelect ()
48 void StepData_PDescr::AddMember (const Handle(StepData_PDescr)& member)
50 if (member.IsNull()) return;
51 if (thenext.IsNull()) thenext = member;
52 else thenext->AddMember (member);
53 if (thesel == 3) return;
54 if (thekind < KindEntity && thenext->Kind() >= KindEntity) thesel = 3;
55 else if (thekind < KindEntity && (thesel == 2 || thesel == 4)) thesel = 3;
56 else if (thekind >= KindEntity && (thesel == 1 || thesel == 4)) thesel = 2;
59 void StepData_PDescr::SetMemberName (const Standard_CString memname)
60 { thesnam.Clear(); thesnam.AssignCat (memname); }
62 void StepData_PDescr::SetInteger ()
63 { thekind = KindInteger; }
65 void StepData_PDescr::SetReal ()
66 { thekind = KindReal; }
68 void StepData_PDescr::SetString ()
69 { thekind = KindString; }
71 void StepData_PDescr::SetBoolean ()
72 { thekind = KindBoolean; }
74 void StepData_PDescr::SetLogical ()
75 { thekind = KindLogical; }
77 void StepData_PDescr::SetEnum ()
78 { thekind = KindEnum; }
80 void StepData_PDescr::AddEnumDef (const Standard_CString enumdef)
81 { theenum.AddDefinition (enumdef); }
83 void StepData_PDescr::SetType (const Handle(Standard_Type)& atype)
84 { thekind = KindEntity; thetype = atype; thednam.Clear(); }
86 void StepData_PDescr::SetDescr (const Standard_CString dscnam)
87 { thekind = KindEntity; thetype.Nullify();
88 thednam.Clear(); thednam.AssignCat(dscnam); }
90 void StepData_PDescr::AddArity (const Standard_Integer arity)
93 void StepData_PDescr::SetArity (const Standard_Integer arity)
97 void StepData_PDescr::SetFrom (const Handle(StepData_PDescr)& other)
99 if (other.IsNull()) return;
100 thekind = other->Kind();
101 Standard_Integer i, maxenum = other->EnumMax ();
102 for (i = 0; i <= maxenum; i ++) AddEnumDef (other->EnumText(i));
103 // ne sont pas reprises : les SELECT
104 thetype = other->Type();
105 thearit = other->Arity();
107 theopt = other->IsOptional ();
108 theder = other->IsDerived ();
109 thefnam.Clear(); thefnam.AssignCat (other->FieldName());
110 thefnum = other->FieldRank ();
113 void StepData_PDescr::SetOptional (const Standard_Boolean opt)
116 void StepData_PDescr::SetDerived (const Standard_Boolean der)
119 void StepData_PDescr::SetField
120 (const Standard_CString name, const Standard_Integer rank)
122 thefnam.Clear(); thefnam.AssignCat (name);
126 // ###### INTERRO ######
128 Standard_Boolean StepData_PDescr::IsSelect () const
130 if (!thefrom.IsNull()) return thefrom->IsSelect();
134 Handle(StepData_PDescr) StepData_PDescr::Member (const Standard_CString name) const
136 if (!thefrom.IsNull()) return thefrom->Member (name);
137 Handle(StepData_PDescr) descr;
138 if (thesnam.IsEqual (name)) return this;
139 if (thenext.IsNull()) return descr; // null
140 return thenext->Member (name);
143 Standard_Boolean StepData_PDescr::IsInteger () const
144 { return (thekind == KindInteger); }
146 Standard_Boolean StepData_PDescr::IsReal () const
147 { return (thekind == KindReal); }
149 Standard_Boolean StepData_PDescr::IsString () const
150 { return (thekind == KindString); }
152 Standard_Boolean StepData_PDescr::IsBoolean () const
153 { return (thekind == KindBoolean || thekind == KindLogical); }
155 Standard_Boolean StepData_PDescr::IsLogical () const
156 { return (thekind == KindLogical); }
158 Standard_Boolean StepData_PDescr::IsEnum () const
159 { return (thekind == KindEnum); }
161 Standard_Integer StepData_PDescr::EnumMax () const
162 { return theenum.MaxValue(); }
164 Standard_Integer StepData_PDescr::EnumValue (const Standard_CString name) const
165 { return theenum.Value (name); }
167 Standard_CString StepData_PDescr::EnumText (const Standard_Integer val) const
168 { return theenum.Text (val).ToCString(); }
170 Standard_Boolean StepData_PDescr::IsEntity () const
171 { return (thekind == KindEntity); }
173 Standard_Boolean StepData_PDescr::IsType (const Handle(Standard_Type)& atype) const
175 if (atype.IsNull()) return Standard_False;
176 if (!thetype.IsNull()) {
177 if (atype->SubType(thetype)) return Standard_True;
179 if (!thenext.IsNull()) return thenext->IsType(atype);
180 if (!thefrom.IsNull()) return thefrom->IsType(atype);
181 return Standard_False;
184 Handle(Standard_Type) StepData_PDescr::Type () const
187 Standard_Boolean StepData_PDescr::IsDescr
188 (const Handle(StepData_EDescr)& descr) const
190 if (descr.IsNull()) return Standard_False;
191 if (thednam.Length() > 0) {
192 if (descr->Matches (thednam.ToCString())) return Standard_True;
194 if (!thenext.IsNull()) return thenext->IsDescr (descr);
195 if (!thefrom.IsNull()) return thefrom->IsDescr (descr);
196 return Standard_False;
199 Standard_CString StepData_PDescr::DescrName () const
200 { return thednam.ToCString(); }
203 Standard_Integer StepData_PDescr::Arity () const
206 Handle(StepData_PDescr) StepData_PDescr::Simple () const
208 if (thearit == 0) return this;
209 if (thefrom.IsNull()) return this;
213 Standard_Boolean StepData_PDescr::IsOptional () const
216 Standard_Boolean StepData_PDescr::IsDerived () const
219 Standard_Boolean StepData_PDescr::IsField () const
220 { return (thefnum > 0); }
222 Standard_CString StepData_PDescr::FieldName () const
223 { return thefnam.ToCString (); }
225 Standard_Integer StepData_PDescr::FieldRank () const
229 void StepData_PDescr::Check(const StepData_Field& /*afild*/,
230 Handle(Interface_Check)& /*ach*/) const
232 // pour l instant ...