0024186: Eliminate remaining compiler warnings in MSVC++ 2010 64 bit with warning...
[occt.git] / src / StepData / StepData_Protocol.cxx
CommitLineData
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_Protocol.ixx>
19#include <StepData_StepModel.hxx>
20#include <StepData_UndefinedEntity.hxx>
21#include <StepData_Described.hxx>
22#include <Interface_DataMapIteratorOfDataMapOfTransientInteger.hxx>
23#include <stdio.h>
24
25
26// Le Protocol de base reconnait UnknownEntity
27
28//static TCollection_AsciiString thename("(DEFAULT)");
29static Standard_CString thename = "(DEFAULT)";
30
31StepData_Protocol::StepData_Protocol ()
32{
33}
34
35Standard_Integer StepData_Protocol::NbResources () const
36{
37 return 0;
38}
39
40
41Handle(Interface_Protocol) StepData_Protocol::Resource
42 (const Standard_Integer /*num*/) const
43{
44 Handle(Interface_Protocol) nulproto;
45 return nulproto;
46}
47
48
49Standard_Integer StepData_Protocol::CaseNumber
50 (const Handle(Standard_Transient)& obj) const
51{
52 if (obj.IsNull()) return 0;
53 Standard_Integer num = TypeNumber (obj->DynamicType());
54 if (num > 0) return num;
55 Handle(StepData_Described) dc = Handle(StepData_Described)::DownCast(obj);
56 if (dc.IsNull()) return 0;
57 return DescrNumber (dc->Description());
58}
59
60
61Standard_Integer StepData_Protocol::TypeNumber
62 (const Handle(Standard_Type)& atype) const
63{
64 if (atype == STANDARD_TYPE(StepData_UndefinedEntity)) return 1;
65 return 0;
66}
67
68
69Standard_CString StepData_Protocol::SchemaName () const
70{
71 return thename;
72}
73
74
75Handle(Interface_InterfaceModel) StepData_Protocol::NewModel () const
76{
77 return new StepData_StepModel;
78}
79
80
81Standard_Boolean StepData_Protocol::IsSuitableModel
82 (const Handle(Interface_InterfaceModel)& model) const
83{
84 return model->IsKind(STANDARD_TYPE(StepData_StepModel));
85}
86
87
88Handle(Standard_Transient) StepData_Protocol::UnknownEntity () const
89{
90 return new StepData_UndefinedEntity;
91}
92
93
94Standard_Boolean StepData_Protocol::IsUnknownEntity
95 (const Handle(Standard_Transient)& ent) const
96{
97 if (!ent.IsNull())
98 return ent->IsKind(STANDARD_TYPE(StepData_UndefinedEntity));
99 return Standard_False;
100}
101
102
103// #### Description pour LateBinding
104
105Standard_Integer StepData_Protocol::DescrNumber
106 (const Handle(StepData_EDescr)& adescr) const
107{
108 if (thedscnum.IsBound(adescr)) return thedscnum.Find(adescr);
109 return 0;
110}
111
112
113void StepData_Protocol::AddDescr
114 (const Handle(StepData_EDescr)& adescr, const Standard_Integer CN)
115{
116 Handle(StepData_ESDescr) sd = Handle(StepData_ESDescr)::DownCast(adescr);
117 thedscnum.Bind (adescr,CN);
118
119// Simple : memorisee selon son nom
120// sinon que faire ? on memorise selon le numero passe en alpha-num ...
121// (temporaire)
122 if (thedscnam.IsNull()) thedscnam = new Dico_DictionaryOfTransient;
123 if (!sd.IsNull()) thedscnam->SetItem (sd->TypeName(),sd);
124 char fonom[10];
125 sprintf(fonom,"%d",CN);
126 thedscnam->SetItem (fonom,adescr);
127}
128
129
130Standard_Boolean StepData_Protocol::HasDescr () const
131{
132 return !thedscnam.IsNull();
133}
134
135
136Handle(StepData_EDescr) StepData_Protocol::Descr
137 (const Standard_Integer num) const
138{
139 Handle(StepData_EDescr) dsc;
140 if (thedscnam.IsNull()) return dsc;
141 char fonom[10];
142 sprintf(fonom,"%d",num);
143 if (!thedscnam->GetItem (fonom,dsc)) dsc.Nullify();
144 return dsc;
145}
146
147
148Handle(StepData_EDescr) StepData_Protocol::Descr
149 (const Standard_CString name, const Standard_Boolean anylevel) const
150{
151 Handle(StepData_EDescr) sd;
152 if (!thedscnam.IsNull()) {
153 if (thedscnam->GetItem (name,sd)) return sd;
154 }
155 if (!anylevel) return sd;
156
157 Standard_Integer i, nb = NbResources();
158 for (i = 1; i <= nb; i ++) {
159 Handle(StepData_Protocol) sp = Handle(StepData_Protocol)::DownCast(Resource(i));
160 if (sp.IsNull()) continue;
161 sd = sp->Descr (name,anylevel);
162 if (!sd.IsNull()) return sd;
163 }
164 return sd;
165}
166
167
168Handle(StepData_ESDescr) StepData_Protocol::ESDescr
169 (const Standard_CString name, const Standard_Boolean anylevel) const
170{
171 return Handle(StepData_ESDescr)::DownCast(Descr(name,anylevel));
172}
173
174
175Handle(StepData_ECDescr) StepData_Protocol::ECDescr
176 (const TColStd_SequenceOfAsciiString& names, const Standard_Boolean anylevel) const
177{
178 Standard_Integer i, nb = names.Length();
179 Handle(StepData_ECDescr) cd;
180 Interface_DataMapIteratorOfDataMapOfTransientInteger iter(thedscnum);
181 for (; iter.More(); iter.Next()) {
182 cd = Handle(StepData_ECDescr)::DownCast (iter.Key());
183 if (cd.IsNull()) continue;
184 if (cd->NbMembers() != nb) continue;
185 Standard_Boolean ok = Standard_True;
186 for (i = 1; i <= nb; i ++) {
187 if (!names(i).IsEqual (cd->Member(i)->TypeName())) { ok = Standard_False; break; }
188 }
189 if (ok) return cd;
190 }
191 cd.Nullify();
192 if (!anylevel) return cd;
193
194 nb = NbResources();
195 for (i = 1; i <= nb; i ++) {
196 Handle(StepData_Protocol) sp = Handle(StepData_Protocol)::DownCast(Resource(i));
197 if (sp.IsNull()) continue;
198 cd = sp->ECDescr (names,anylevel);
199 if (!cd.IsNull()) return cd;
200 }
201 return cd;
202}
203
204
205void StepData_Protocol::AddPDescr
206 (const Handle(StepData_PDescr)& pdescr)
207{
208 if (thepdescr.IsNull()) thepdescr = new Dico_DictionaryOfTransient;
209 thepdescr->SetItem (pdescr->Name(),pdescr);
210}
211
212
213Handle(StepData_PDescr) StepData_Protocol::PDescr
214 (const Standard_CString name, const Standard_Boolean anylevel) const
215{
216 Handle(StepData_PDescr) sd;
217 if (!thepdescr.IsNull()) {
218 if (thepdescr->GetItem (name,sd)) return sd;
219 }
220 if (!anylevel) return sd;
221
222 Standard_Integer i, nb = NbResources();
223 for (i = 1; i <= nb; i ++) {
224 Handle(StepData_Protocol) sp = Handle(StepData_Protocol)::DownCast(Resource(i));
225 if (sp.IsNull()) continue;
226 sd = sp->PDescr (name,anylevel);
227 if (!sd.IsNull()) return sd;
228 }
229 return sd;
230}
231
232
233void StepData_Protocol::AddBasicDescr
234 (const Handle(StepData_ESDescr)& esdescr)
235{
236 if (thedscbas.IsNull()) thedscbas = new Dico_DictionaryOfTransient;
237 thedscbas->SetItem (esdescr->TypeName(),esdescr);
238}
239
240
241Handle(StepData_EDescr) StepData_Protocol::BasicDescr
242 (const Standard_CString name, const Standard_Boolean anylevel) const
243{
244 Handle(StepData_EDescr) sd;
245 if (!thedscbas.IsNull()) {
246 if (thedscbas->GetItem (name,sd)) return sd;
247 }
248 if (!anylevel) return sd;
249
250 Standard_Integer i, nb = NbResources();
251 for (i = 1; i <= nb; i ++) {
252 Handle(StepData_Protocol) sp = Handle(StepData_Protocol)::DownCast(Resource(i));
253 if (sp.IsNull()) continue;
254 sd = sp->BasicDescr (name,anylevel);
255 if (!sd.IsNull()) return sd;
256 }
257 return sd;
258}