0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / StepData / StepData_PDescr.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
42cf5bc1 14
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>
7fd59977 20
21#define KindInteger 1
22#define KindBoolean 2
23#define KindLogical 3
24#define KindEnum 4
25#define KindReal 5
26#define KindString 6
27#define KindEntity 7
28
b311480e 29StepData_PDescr::StepData_PDescr ()
7fd59977 30 : thesel (0), thekind (0), thearit (0),
31 theopt (Standard_False), theder (Standard_False), thefnum (0)
32 { }
33
34 void StepData_PDescr::SetName (const Standard_CString name)
35 { thename.Clear(); thename.AssignCat (name); }
36
37 Standard_CString StepData_PDescr::Name () const
38 { return thename.ToCString(); }
39
40 Standard_Integer StepData_PDescr::Kind () const
41 { return thekind; }
42
43 void StepData_PDescr::SetSelect ()
44 { thesel = 4; }
45
46 void StepData_PDescr::AddMember (const Handle(StepData_PDescr)& member)
47{
48 if (member.IsNull()) return;
49 if (thenext.IsNull()) thenext = member;
50 else thenext->AddMember (member);
51 if (thesel == 3) return;
52 if (thekind < KindEntity && thenext->Kind() >= KindEntity) thesel = 3;
53 else if (thekind < KindEntity && (thesel == 2 || thesel == 4)) thesel = 3;
54 else if (thekind >= KindEntity && (thesel == 1 || thesel == 4)) thesel = 2;
55}
56
57 void StepData_PDescr::SetMemberName (const Standard_CString memname)
58 { thesnam.Clear(); thesnam.AssignCat (memname); }
59
60 void StepData_PDescr::SetInteger ()
61 { thekind = KindInteger; }
62
63 void StepData_PDescr::SetReal ()
64 { thekind = KindReal; }
65
66 void StepData_PDescr::SetString ()
67 { thekind = KindString; }
68
69 void StepData_PDescr::SetBoolean ()
70 { thekind = KindBoolean; }
71
72 void StepData_PDescr::SetLogical ()
73 { thekind = KindLogical; }
74
75 void StepData_PDescr::SetEnum ()
76 { thekind = KindEnum; }
77
78 void StepData_PDescr::AddEnumDef (const Standard_CString enumdef)
79 { theenum.AddDefinition (enumdef); }
80
81 void StepData_PDescr::SetType (const Handle(Standard_Type)& atype)
82 { thekind = KindEntity; thetype = atype; thednam.Clear(); }
83
84 void StepData_PDescr::SetDescr (const Standard_CString dscnam)
85 { thekind = KindEntity; thetype.Nullify();
86 thednam.Clear(); thednam.AssignCat(dscnam); }
87
88 void StepData_PDescr::AddArity (const Standard_Integer arity)
89 { thearit += arity; }
90
91 void StepData_PDescr::SetArity (const Standard_Integer arity)
92 { thearit = arity; }
93
94
95 void StepData_PDescr::SetFrom (const Handle(StepData_PDescr)& other)
96{
97 if (other.IsNull()) return;
98 thekind = other->Kind();
99 Standard_Integer i, maxenum = other->EnumMax ();
100 for (i = 0; i <= maxenum; i ++) AddEnumDef (other->EnumText(i));
101// ne sont pas reprises : les SELECT
102 thetype = other->Type();
103 thearit = other->Arity();
104 thefrom = other;
105 theopt = other->IsOptional ();
106 theder = other->IsDerived ();
107 thefnam.Clear(); thefnam.AssignCat (other->FieldName());
108 thefnum = other->FieldRank ();
109}
110
111 void StepData_PDescr::SetOptional (const Standard_Boolean opt)
112 { theopt = opt; }
113
114 void StepData_PDescr::SetDerived (const Standard_Boolean der)
115 { theder = der; }
116
117 void StepData_PDescr::SetField
118 (const Standard_CString name, const Standard_Integer rank)
119{
120 thefnam.Clear(); thefnam.AssignCat (name);
121 thefnum = rank;
122}
123
124// ###### INTERRO ######
125
126 Standard_Boolean StepData_PDescr::IsSelect () const
127{
128 if (!thefrom.IsNull()) return thefrom->IsSelect();
129 return (thesel > 0);
130}
131
132 Handle(StepData_PDescr) StepData_PDescr::Member (const Standard_CString name) const
133{
134 if (!thefrom.IsNull()) return thefrom->Member (name);
135 Handle(StepData_PDescr) descr;
136 if (thesnam.IsEqual (name)) return this;
137 if (thenext.IsNull()) return descr; // null
138 return thenext->Member (name);
139}
140
141 Standard_Boolean StepData_PDescr::IsInteger () const
142 { return (thekind == KindInteger); }
143
144 Standard_Boolean StepData_PDescr::IsReal () const
145 { return (thekind == KindReal); }
146
147 Standard_Boolean StepData_PDescr::IsString () const
148 { return (thekind == KindString); }
149
150 Standard_Boolean StepData_PDescr::IsBoolean () const
151 { return (thekind == KindBoolean || thekind == KindLogical); }
152
153 Standard_Boolean StepData_PDescr::IsLogical () const
154 { return (thekind == KindLogical); }
155
156 Standard_Boolean StepData_PDescr::IsEnum () const
157 { return (thekind == KindEnum); }
158
159 Standard_Integer StepData_PDescr::EnumMax () const
160 { return theenum.MaxValue(); }
161
162 Standard_Integer StepData_PDescr::EnumValue (const Standard_CString name) const
163 { return theenum.Value (name); }
164
165 Standard_CString StepData_PDescr::EnumText (const Standard_Integer val) const
166 { return theenum.Text (val).ToCString(); }
167
168 Standard_Boolean StepData_PDescr::IsEntity () const
169 { return (thekind == KindEntity); }
170
171 Standard_Boolean StepData_PDescr::IsType (const Handle(Standard_Type)& atype) const
172{
173 if (atype.IsNull()) return Standard_False;
174 if (!thetype.IsNull()) {
175 if (atype->SubType(thetype)) return Standard_True;
176 }
177 if (!thenext.IsNull()) return thenext->IsType(atype);
178 if (!thefrom.IsNull()) return thefrom->IsType(atype);
179 return Standard_False;
180}
181
182 Handle(Standard_Type) StepData_PDescr::Type () const
183 { return thetype; }
184
185 Standard_Boolean StepData_PDescr::IsDescr
186 (const Handle(StepData_EDescr)& descr) const
187{
188 if (descr.IsNull()) return Standard_False;
189 if (thednam.Length() > 0) {
190 if (descr->Matches (thednam.ToCString())) return Standard_True;
191 }
192 if (!thenext.IsNull()) return thenext->IsDescr (descr);
193 if (!thefrom.IsNull()) return thefrom->IsDescr (descr);
194 return Standard_False;
195}
196
197 Standard_CString StepData_PDescr::DescrName () const
198 { return thednam.ToCString(); }
199
200
201 Standard_Integer StepData_PDescr::Arity () const
202 { return thearit; }
203
204 Handle(StepData_PDescr) StepData_PDescr::Simple () const
205{
206 if (thearit == 0) return this;
207 if (thefrom.IsNull()) return this;
208 return thefrom;
209}
210
211 Standard_Boolean StepData_PDescr::IsOptional () const
212 { return theopt; }
213
214 Standard_Boolean StepData_PDescr::IsDerived () const
215 { return theder; }
216
217 Standard_Boolean StepData_PDescr::IsField () const
218 { return (thefnum > 0); }
219
220 Standard_CString StepData_PDescr::FieldName () const
221 { return thefnam.ToCString (); }
222
223 Standard_Integer StepData_PDescr::FieldRank () const
224 { return thefnum; }
225
226
35e08fe8 227void StepData_PDescr::Check(const StepData_Field& /*afild*/,
302f96fb 228 Handle(Interface_Check)& /*ach*/) const
7fd59977 229{
230// pour l instant ...
231}