1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <StepData_PDescr.ixx>
28 StepData_PDescr::StepData_PDescr ()
29 : thesel (0), thekind (0), thearit (0),
30 theopt (Standard_False), theder (Standard_False), thefnum (0)
33 void StepData_PDescr::SetName (const Standard_CString name)
34 { thename.Clear(); thename.AssignCat (name); }
36 Standard_CString StepData_PDescr::Name () const
37 { return thename.ToCString(); }
39 Standard_Integer StepData_PDescr::Kind () const
42 void StepData_PDescr::SetSelect ()
45 void StepData_PDescr::AddMember (const Handle(StepData_PDescr)& member)
47 if (member.IsNull()) return;
48 if (thenext.IsNull()) thenext = member;
49 else thenext->AddMember (member);
50 if (thesel == 3) return;
51 if (thekind < KindEntity && thenext->Kind() >= KindEntity) thesel = 3;
52 else if (thekind < KindEntity && (thesel == 2 || thesel == 4)) thesel = 3;
53 else if (thekind >= KindEntity && (thesel == 1 || thesel == 4)) thesel = 2;
56 void StepData_PDescr::SetMemberName (const Standard_CString memname)
57 { thesnam.Clear(); thesnam.AssignCat (memname); }
59 void StepData_PDescr::SetInteger ()
60 { thekind = KindInteger; }
62 void StepData_PDescr::SetReal ()
63 { thekind = KindReal; }
65 void StepData_PDescr::SetString ()
66 { thekind = KindString; }
68 void StepData_PDescr::SetBoolean ()
69 { thekind = KindBoolean; }
71 void StepData_PDescr::SetLogical ()
72 { thekind = KindLogical; }
74 void StepData_PDescr::SetEnum ()
75 { thekind = KindEnum; }
77 void StepData_PDescr::AddEnumDef (const Standard_CString enumdef)
78 { theenum.AddDefinition (enumdef); }
80 void StepData_PDescr::SetType (const Handle(Standard_Type)& atype)
81 { thekind = KindEntity; thetype = atype; thednam.Clear(); }
83 void StepData_PDescr::SetDescr (const Standard_CString dscnam)
84 { thekind = KindEntity; thetype.Nullify();
85 thednam.Clear(); thednam.AssignCat(dscnam); }
87 void StepData_PDescr::AddArity (const Standard_Integer arity)
90 void StepData_PDescr::SetArity (const Standard_Integer arity)
94 void StepData_PDescr::SetFrom (const Handle(StepData_PDescr)& other)
96 if (other.IsNull()) return;
97 thekind = other->Kind();
98 Standard_Integer i, maxenum = other->EnumMax ();
99 for (i = 0; i <= maxenum; i ++) AddEnumDef (other->EnumText(i));
100 // ne sont pas reprises : les SELECT
101 thetype = other->Type();
102 thearit = other->Arity();
104 theopt = other->IsOptional ();
105 theder = other->IsDerived ();
106 thefnam.Clear(); thefnam.AssignCat (other->FieldName());
107 thefnum = other->FieldRank ();
110 void StepData_PDescr::SetOptional (const Standard_Boolean opt)
113 void StepData_PDescr::SetDerived (const Standard_Boolean der)
116 void StepData_PDescr::SetField
117 (const Standard_CString name, const Standard_Integer rank)
119 thefnam.Clear(); thefnam.AssignCat (name);
123 // ###### INTERRO ######
125 Standard_Boolean StepData_PDescr::IsSelect () const
127 if (!thefrom.IsNull()) return thefrom->IsSelect();
131 Handle(StepData_PDescr) StepData_PDescr::Member (const Standard_CString name) const
133 if (!thefrom.IsNull()) return thefrom->Member (name);
134 Handle(StepData_PDescr) descr;
135 if (thesnam.IsEqual (name)) return this;
136 if (thenext.IsNull()) return descr; // null
137 return thenext->Member (name);
140 Standard_Boolean StepData_PDescr::IsInteger () const
141 { return (thekind == KindInteger); }
143 Standard_Boolean StepData_PDescr::IsReal () const
144 { return (thekind == KindReal); }
146 Standard_Boolean StepData_PDescr::IsString () const
147 { return (thekind == KindString); }
149 Standard_Boolean StepData_PDescr::IsBoolean () const
150 { return (thekind == KindBoolean || thekind == KindLogical); }
152 Standard_Boolean StepData_PDescr::IsLogical () const
153 { return (thekind == KindLogical); }
155 Standard_Boolean StepData_PDescr::IsEnum () const
156 { return (thekind == KindEnum); }
158 Standard_Integer StepData_PDescr::EnumMax () const
159 { return theenum.MaxValue(); }
161 Standard_Integer StepData_PDescr::EnumValue (const Standard_CString name) const
162 { return theenum.Value (name); }
164 Standard_CString StepData_PDescr::EnumText (const Standard_Integer val) const
165 { return theenum.Text (val).ToCString(); }
167 Standard_Boolean StepData_PDescr::IsEntity () const
168 { return (thekind == KindEntity); }
170 Standard_Boolean StepData_PDescr::IsType (const Handle(Standard_Type)& atype) const
172 if (atype.IsNull()) return Standard_False;
173 if (!thetype.IsNull()) {
174 if (atype->SubType(thetype)) return Standard_True;
176 if (!thenext.IsNull()) return thenext->IsType(atype);
177 if (!thefrom.IsNull()) return thefrom->IsType(atype);
178 return Standard_False;
181 Handle(Standard_Type) StepData_PDescr::Type () const
184 Standard_Boolean StepData_PDescr::IsDescr
185 (const Handle(StepData_EDescr)& descr) const
187 if (descr.IsNull()) return Standard_False;
188 if (thednam.Length() > 0) {
189 if (descr->Matches (thednam.ToCString())) return Standard_True;
191 if (!thenext.IsNull()) return thenext->IsDescr (descr);
192 if (!thefrom.IsNull()) return thefrom->IsDescr (descr);
193 return Standard_False;
196 Standard_CString StepData_PDescr::DescrName () const
197 { return thednam.ToCString(); }
200 Standard_Integer StepData_PDescr::Arity () const
203 Handle(StepData_PDescr) StepData_PDescr::Simple () const
205 if (thearit == 0) return this;
206 if (thefrom.IsNull()) return this;
210 Standard_Boolean StepData_PDescr::IsOptional () const
213 Standard_Boolean StepData_PDescr::IsDerived () const
216 Standard_Boolean StepData_PDescr::IsField () const
217 { return (thefnum > 0); }
219 Standard_CString StepData_PDescr::FieldName () const
220 { return thefnam.ToCString (); }
222 Standard_Integer StepData_PDescr::FieldRank () const
226 void StepData_PDescr::Check(const StepData_Field& afild,
227 Handle(Interface_Check)& /*ach*/) const
229 // pour l instant ...