b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
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. |
7 | // |
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. |
10 | // |
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. |
17 | |
7fd59977 |
18 | #include <StepData_PDescr.ixx> |
19 | |
20 | #define KindInteger 1 |
21 | #define KindBoolean 2 |
22 | #define KindLogical 3 |
23 | #define KindEnum 4 |
24 | #define KindReal 5 |
25 | #define KindString 6 |
26 | #define KindEntity 7 |
27 | |
b311480e |
28 | StepData_PDescr::StepData_PDescr () |
7fd59977 |
29 | : thesel (0), thekind (0), thearit (0), |
30 | theopt (Standard_False), theder (Standard_False), thefnum (0) |
31 | { } |
32 | |
33 | void StepData_PDescr::SetName (const Standard_CString name) |
34 | { thename.Clear(); thename.AssignCat (name); } |
35 | |
36 | Standard_CString StepData_PDescr::Name () const |
37 | { return thename.ToCString(); } |
38 | |
39 | Standard_Integer StepData_PDescr::Kind () const |
40 | { return thekind; } |
41 | |
42 | void StepData_PDescr::SetSelect () |
43 | { thesel = 4; } |
44 | |
45 | void StepData_PDescr::AddMember (const Handle(StepData_PDescr)& member) |
46 | { |
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; |
54 | } |
55 | |
56 | void StepData_PDescr::SetMemberName (const Standard_CString memname) |
57 | { thesnam.Clear(); thesnam.AssignCat (memname); } |
58 | |
59 | void StepData_PDescr::SetInteger () |
60 | { thekind = KindInteger; } |
61 | |
62 | void StepData_PDescr::SetReal () |
63 | { thekind = KindReal; } |
64 | |
65 | void StepData_PDescr::SetString () |
66 | { thekind = KindString; } |
67 | |
68 | void StepData_PDescr::SetBoolean () |
69 | { thekind = KindBoolean; } |
70 | |
71 | void StepData_PDescr::SetLogical () |
72 | { thekind = KindLogical; } |
73 | |
74 | void StepData_PDescr::SetEnum () |
75 | { thekind = KindEnum; } |
76 | |
77 | void StepData_PDescr::AddEnumDef (const Standard_CString enumdef) |
78 | { theenum.AddDefinition (enumdef); } |
79 | |
80 | void StepData_PDescr::SetType (const Handle(Standard_Type)& atype) |
81 | { thekind = KindEntity; thetype = atype; thednam.Clear(); } |
82 | |
83 | void StepData_PDescr::SetDescr (const Standard_CString dscnam) |
84 | { thekind = KindEntity; thetype.Nullify(); |
85 | thednam.Clear(); thednam.AssignCat(dscnam); } |
86 | |
87 | void StepData_PDescr::AddArity (const Standard_Integer arity) |
88 | { thearit += arity; } |
89 | |
90 | void StepData_PDescr::SetArity (const Standard_Integer arity) |
91 | { thearit = arity; } |
92 | |
93 | |
94 | void StepData_PDescr::SetFrom (const Handle(StepData_PDescr)& other) |
95 | { |
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(); |
103 | thefrom = other; |
104 | theopt = other->IsOptional (); |
105 | theder = other->IsDerived (); |
106 | thefnam.Clear(); thefnam.AssignCat (other->FieldName()); |
107 | thefnum = other->FieldRank (); |
108 | } |
109 | |
110 | void StepData_PDescr::SetOptional (const Standard_Boolean opt) |
111 | { theopt = opt; } |
112 | |
113 | void StepData_PDescr::SetDerived (const Standard_Boolean der) |
114 | { theder = der; } |
115 | |
116 | void StepData_PDescr::SetField |
117 | (const Standard_CString name, const Standard_Integer rank) |
118 | { |
119 | thefnam.Clear(); thefnam.AssignCat (name); |
120 | thefnum = rank; |
121 | } |
122 | |
123 | // ###### INTERRO ###### |
124 | |
125 | Standard_Boolean StepData_PDescr::IsSelect () const |
126 | { |
127 | if (!thefrom.IsNull()) return thefrom->IsSelect(); |
128 | return (thesel > 0); |
129 | } |
130 | |
131 | Handle(StepData_PDescr) StepData_PDescr::Member (const Standard_CString name) const |
132 | { |
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); |
138 | } |
139 | |
140 | Standard_Boolean StepData_PDescr::IsInteger () const |
141 | { return (thekind == KindInteger); } |
142 | |
143 | Standard_Boolean StepData_PDescr::IsReal () const |
144 | { return (thekind == KindReal); } |
145 | |
146 | Standard_Boolean StepData_PDescr::IsString () const |
147 | { return (thekind == KindString); } |
148 | |
149 | Standard_Boolean StepData_PDescr::IsBoolean () const |
150 | { return (thekind == KindBoolean || thekind == KindLogical); } |
151 | |
152 | Standard_Boolean StepData_PDescr::IsLogical () const |
153 | { return (thekind == KindLogical); } |
154 | |
155 | Standard_Boolean StepData_PDescr::IsEnum () const |
156 | { return (thekind == KindEnum); } |
157 | |
158 | Standard_Integer StepData_PDescr::EnumMax () const |
159 | { return theenum.MaxValue(); } |
160 | |
161 | Standard_Integer StepData_PDescr::EnumValue (const Standard_CString name) const |
162 | { return theenum.Value (name); } |
163 | |
164 | Standard_CString StepData_PDescr::EnumText (const Standard_Integer val) const |
165 | { return theenum.Text (val).ToCString(); } |
166 | |
167 | Standard_Boolean StepData_PDescr::IsEntity () const |
168 | { return (thekind == KindEntity); } |
169 | |
170 | Standard_Boolean StepData_PDescr::IsType (const Handle(Standard_Type)& atype) const |
171 | { |
172 | if (atype.IsNull()) return Standard_False; |
173 | if (!thetype.IsNull()) { |
174 | if (atype->SubType(thetype)) return Standard_True; |
175 | } |
176 | if (!thenext.IsNull()) return thenext->IsType(atype); |
177 | if (!thefrom.IsNull()) return thefrom->IsType(atype); |
178 | return Standard_False; |
179 | } |
180 | |
181 | Handle(Standard_Type) StepData_PDescr::Type () const |
182 | { return thetype; } |
183 | |
184 | Standard_Boolean StepData_PDescr::IsDescr |
185 | (const Handle(StepData_EDescr)& descr) const |
186 | { |
187 | if (descr.IsNull()) return Standard_False; |
188 | if (thednam.Length() > 0) { |
189 | if (descr->Matches (thednam.ToCString())) return Standard_True; |
190 | } |
191 | if (!thenext.IsNull()) return thenext->IsDescr (descr); |
192 | if (!thefrom.IsNull()) return thefrom->IsDescr (descr); |
193 | return Standard_False; |
194 | } |
195 | |
196 | Standard_CString StepData_PDescr::DescrName () const |
197 | { return thednam.ToCString(); } |
198 | |
199 | |
200 | Standard_Integer StepData_PDescr::Arity () const |
201 | { return thearit; } |
202 | |
203 | Handle(StepData_PDescr) StepData_PDescr::Simple () const |
204 | { |
205 | if (thearit == 0) return this; |
206 | if (thefrom.IsNull()) return this; |
207 | return thefrom; |
208 | } |
209 | |
210 | Standard_Boolean StepData_PDescr::IsOptional () const |
211 | { return theopt; } |
212 | |
213 | Standard_Boolean StepData_PDescr::IsDerived () const |
214 | { return theder; } |
215 | |
216 | Standard_Boolean StepData_PDescr::IsField () const |
217 | { return (thefnum > 0); } |
218 | |
219 | Standard_CString StepData_PDescr::FieldName () const |
220 | { return thefnam.ToCString (); } |
221 | |
222 | Standard_Integer StepData_PDescr::FieldRank () const |
223 | { return thefnum; } |
224 | |
225 | |
226 | void StepData_PDescr::Check(const StepData_Field& afild, |
227 | Handle(Interface_Check)& ach) const |
228 | { |
229 | // pour l instant ... |
230 | } |