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 | |
7fd59977 |
14 | // DCE 21.01.99 S3767 Display original messages only |
15 | // if the level is greater than 2 |
16 | |
17 | //#include <Transfer_TransferProcess.ixx> |
18 | // Class generique |
19 | |
20 | // TheStart est suppose Handle(Standard_Transient) ou (Transfer_Finder) |
21 | // Il doit offrir : "==" , .IsNull() , ->DynamicType() |
22 | |
23 | #include <Standard_ErrorHandler.hxx> |
24 | #include <Standard_Failure.hxx> |
25 | |
26 | #include <Message_Messenger.hxx> |
27 | #include <Message_Msg.hxx> |
28 | #include <Message.hxx> |
29 | |
30 | #include <Transfer_VoidBinder.hxx> |
31 | #include <Transfer_SimpleBinderOfTransient.hxx> |
32 | #include <Transfer_MultipleBinder.hxx> |
33 | #include <Transfer_StatusResult.hxx> |
34 | #include <Transfer_TransferFailure.hxx> |
35 | #include <Transfer_TransferDeadLoop.hxx> |
36 | |
37 | #include <TCollection_HAsciiString.hxx> |
7fd59977 |
38 | #include <TColStd_MapIteratorOfMapOfInteger.hxx> |
39 | #include <TColStd_Array1OfInteger.hxx> |
40 | #include <TColStd_HArray1OfInteger.hxx> |
41 | |
42 | |
43 | //#define TRANSLOG // debug |
44 | |
45 | static Handle(Standard_Transient) nultrans; // pour retour const&(Null) ... |
46 | static Handle(Transfer_Binder) nulbinder; |
47 | |
48 | |
49 | //======================================================================= |
50 | //function : Transfer_TransferProcess |
51 | //purpose : |
52 | //======================================================================= |
53 | |
54 | Transfer_TransferProcess::Transfer_TransferProcess (const Standard_Integer nb) |
55 | : themap (nb) |
56 | { |
57 | theerrh = Standard_True; |
58 | therootm = Standard_False; |
59 | thelevel = 0; therootl = 0; |
60 | themessenger = Message::DefaultMessenger(); |
61 | thetrace = 0; |
62 | // theroots = new TColStd_HSequenceOfInteger (); |
63 | theindex = 0; |
64 | } |
65 | |
66 | |
67 | //======================================================================= |
68 | //function : Transfer_TransferProcess |
69 | //purpose : |
70 | //======================================================================= |
71 | |
72 | Transfer_TransferProcess::Transfer_TransferProcess(const Handle(Message_Messenger)& messenger, |
73 | const Standard_Integer nb) |
74 | : themap (nb) |
75 | { |
76 | theerrh = Standard_True; |
77 | therootm = Standard_False; |
78 | thelevel = 0; therootl = 0; |
79 | SetMessenger (messenger); |
80 | thetrace = 1; |
81 | // theroots = new TColStd_HSequenceOfInteger (); |
82 | theindex = 0; |
83 | } |
84 | |
85 | void Transfer_TransferProcess::Clear () |
86 | { |
87 | thelevel = 0; therootl = 0; |
88 | theroots.Clear(); |
89 | themap.Clear(); |
90 | theindex = 0; thelastobj.Nullify(); thelastbnd.Nullify(); |
91 | } |
92 | |
93 | void Transfer_TransferProcess::Clean () |
94 | { |
95 | Standard_Integer i, nb = NbMapped(); |
96 | Standard_Integer j,unb = 0; |
97 | for (i = 1; i <= nb; i ++) { |
98 | if (themap(i).IsNull()) unb ++; |
99 | } |
100 | if (unb == 0) return; |
101 | |
102 | // Refaire la map -> decalages |
103 | TColStd_Array1OfInteger unbs (1,nb); unbs.Init(0); |
104 | Transfer_TransferMap newmap (nb*2); |
105 | for (i = 1; i <= nb; i ++) { |
106 | TheStart ent = Mapped(i); |
107 | Handle(Transfer_Binder) bnd = MapItem(i); |
108 | if (bnd.IsNull()) continue; |
109 | j = newmap.Add (ent,bnd); |
110 | unbs.SetValue (i,j); |
111 | } |
112 | themap.Assign (newmap); |
113 | |
114 | // Update La liste des racines |
115 | TColStd_IndexedMapOfInteger aNewRoots; |
116 | for( i=1; i<= theroots.Extent(); i++ ) { |
117 | j = theroots.FindKey(i); |
118 | Standard_Integer k = unbs.Value(j); |
119 | if ( k ) aNewRoots.Add ( k ); |
120 | } |
121 | theroots.Clear(); |
122 | theroots = aNewRoots; |
123 | |
124 | // Le reste : nettoyage |
125 | thelastobj.Nullify(); |
126 | thelastbnd.Nullify(); |
127 | theindex = 0; |
128 | } |
129 | |
130 | |
131 | //======================================================================= |
132 | //function : Resize |
133 | //purpose : |
134 | //======================================================================= |
135 | |
136 | void Transfer_TransferProcess::Resize (const Standard_Integer nb) |
137 | { |
138 | if (nb > themap.NbBuckets()) themap.ReSize(nb); |
139 | } |
140 | |
141 | |
142 | //======================================================================= |
143 | //function : SetActor |
144 | //purpose : |
145 | //======================================================================= |
146 | |
147 | void Transfer_TransferProcess::SetActor(const Handle(Transfer_Actor)& actor) |
148 | { |
149 | if (theactor == actor) return; |
150 | if (theactor.IsNull()) theactor = actor; |
151 | else if (actor.IsNull()) theactor = actor; // declenche RAZ |
152 | else if (theactor->IsLast()) { actor->SetNext(theactor); theactor = actor; } |
153 | else theactor->SetNext(actor); |
154 | } |
155 | |
156 | |
157 | //======================================================================= |
158 | //function : Actor |
159 | //purpose : |
160 | //======================================================================= |
161 | |
162 | Handle(Transfer_Actor) Transfer_TransferProcess::Actor () const |
163 | { |
164 | return theactor; |
165 | } |
166 | |
167 | |
168 | // ######################################################################## |
169 | // .... MAPPING .... |
170 | |
171 | // ## ## ## Actions Generales sur Binders ## ## ## |
172 | // ## ## ## Consultations ## ## ## |
173 | |
174 | |
175 | // ## ## Find ## ## |
176 | |
177 | //======================================================================= |
178 | //function : Find |
179 | //purpose : |
180 | //======================================================================= |
181 | |
182 | Handle(Transfer_Binder) Transfer_TransferProcess::Find (const TheStart& start) const |
183 | // const Standard_Integer categ) const |
184 | { |
185 | if (thelastobj == start) { |
186 | //if (theindex > 0) return thelastbnd->Search(categ); //skl |
187 | if (theindex > 0) return thelastbnd; //skl |
188 | } |
189 | Standard_Integer index = themap.FindIndex (start); |
190 | if (index > 0) { |
191 | const Handle(Transfer_Binder)& binder = themap.FindFromIndex(index); |
192 | //if (binder.IsNull()) //skl |
193 | return binder; |
194 | //return binder->Search(categ); //skl |
195 | } |
196 | return nulbinder; |
197 | } |
198 | |
199 | // ## ## IsBound ## ## |
200 | |
201 | //======================================================================= |
202 | //function : IsBound |
203 | //purpose : |
204 | //======================================================================= |
205 | |
206 | Standard_Boolean Transfer_TransferProcess::IsBound(const TheStart& start) const |
207 | // const Standard_Integer categ) const |
208 | { |
209 | Handle(Transfer_Binder) binder = Find(start); //,categ); skl |
210 | if (binder.IsNull()) return Standard_False; |
211 | return binder->HasResult(); |
212 | } |
213 | |
214 | // ## ## IsAlreadyUsed ## ## |
215 | |
216 | //======================================================================= |
217 | //function : IsAlreadyUsed |
218 | //purpose : |
219 | //======================================================================= |
220 | |
221 | Standard_Boolean Transfer_TransferProcess::IsAlreadyUsed(const TheStart& start) const |
222 | // const Standard_Integer categ) const |
223 | { |
224 | Handle(Transfer_Binder) binder = Find(start); //,categ); skl |
225 | if (binder.IsNull()) { |
226 | StartTrace (binder,start,thelevel,4); |
9775fa61 |
227 | throw Transfer_TransferFailure("TransferProcess : IsAlreadyUsed, transfer not done cannot be used..."); |
7fd59977 |
228 | } |
229 | return (binder->Status() == Transfer_StatusUsed); |
230 | } |
231 | |
232 | |
233 | // ## ## FindAndMask (private) ## ## |
234 | |
235 | //======================================================================= |
236 | //function : FindAndMask |
237 | //purpose : |
238 | //======================================================================= |
239 | |
240 | Handle(Transfer_Binder) Transfer_TransferProcess::FindAndMask(const TheStart& start) |
241 | // const Standard_Integer categ) |
242 | { |
243 | if (thelastobj == start) { |
244 | if (theindex > 0) return thelastbnd; //skl ->Search(categ); |
245 | } |
246 | thelastobj = start; |
247 | theindex = themap.FindIndex (start); |
248 | if (theindex > 0) thelastbnd = themap.FindFromIndex(theindex); |
249 | else thelastbnd.Nullify(); |
250 | //if (thelastbnd.IsNull()) skl |
251 | return thelastbnd; |
252 | //return thelastbnd->Search(categ); //skl |
253 | } |
254 | |
255 | |
256 | // ## ## ## Modifications ## ## ## |
257 | |
258 | |
259 | //======================================================================= |
260 | //function : Bind |
261 | //purpose : |
262 | //======================================================================= |
263 | |
264 | void Transfer_TransferProcess::Bind (const TheStart& start, |
265 | const Handle(Transfer_Binder)& binder) |
266 | // const Standard_Integer categ) |
267 | { |
268 | if (binder.IsNull()) return; |
269 | Handle(Transfer_Binder) former = FindAndMask(start);//,categ);skl |
270 | if (!former.IsNull()) { |
271 | // On admet VoidBinder : alors on reprend son Check |
272 | if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) { |
273 | binder->Merge(former); |
274 | //binder->SetCategory(categ); //skl |
275 | themap(theindex) = binder; // Substitution |
276 | } |
277 | else if (former->Status() == Transfer_StatusUsed) { |
278 | StartTrace (former,start,thelevel,4); |
9775fa61 |
279 | throw Transfer_TransferFailure("TransferProcess : Bind, already Bound"); |
7fd59977 |
280 | } |
281 | else { |
282 | if (thetrace > 2) StartTrace (former,start,thelevel,5); |
283 | binder->CCheck()->GetMessages (former->Check()); |
284 | } |
285 | } |
286 | //binder->SetCategory(categ); //skl |
287 | if (theindex == 0 || thelastbnd.IsNull()) { |
288 | if (theindex == 0) theindex = themap.Add(start,binder); // Nouveau |
289 | else themap(theindex) = binder; // idem en fait |
290 | thelastbnd = binder; |
291 | } |
292 | else { //skl |
293 | //binder->AddResult(thelastbnd); |
294 | thelastbnd = binder; |
295 | themap(theindex) = binder; |
296 | } |
297 | /*skl else if (thelastbnd->Category() == categ) { // Substitue cette categorie |
298 | binder->Next(Standard_False)->SetNext(thelastbnd->Next(Standard_True),Standard_True); |
299 | thelastbnd = binder; |
300 | themap(theindex) = binder; |
301 | } else { |
302 | thelastbnd->AddNext (binder,categ,Standard_True); |
303 | } */ |
304 | } |
305 | |
306 | |
307 | //======================================================================= |
308 | //function : Rebind |
309 | //purpose : |
310 | //======================================================================= |
311 | |
312 | void Transfer_TransferProcess::Rebind (const TheStart& start, |
313 | const Handle(Transfer_Binder)& binder) |
314 | // const Standard_Integer categ) |
315 | { |
316 | Bind(start,binder); //,categ);skl |
317 | // entre les deux, les differences allaient s amenuisant |
318 | // au debut, on criait si pas encore Bound (idiot) |
319 | // ne restait plus comme difference que le test StatusUsed sur Rebind, |
320 | // tandis que Bind refusait des lors qu il y avait un resultat |
321 | // -> a present, Bind s aligne sur Rebind |
322 | } |
323 | |
324 | |
325 | //======================================================================= |
326 | //function : Unbind |
327 | //purpose : |
328 | //======================================================================= |
329 | |
330 | Standard_Boolean Transfer_TransferProcess::Unbind(const TheStart& start) |
331 | // const Standard_Integer categ) |
332 | { |
333 | Handle(Transfer_Binder) former = FindAndMask(start);//,categ);skl |
334 | if (theindex == 0) return Standard_False; |
335 | if (former.IsNull()) return Standard_False; |
336 | if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) return Standard_True; |
337 | //const Interface_Check& ach = thelastbnd->Check(); |
338 | //Handle(Transfer_Binder) newbinder = thelastbnd->RemoveNext(categ);skl |
339 | //if (newbinder != thelastbnd)skl |
340 | themap(theindex) = thelastbnd;// = newbinder;skl |
341 | if(theroots.Contains(theindex)) { |
342 | TColStd_IndexedMapOfInteger aNewRoots; |
343 | for(Standard_Integer i = 1; i <= theroots.Extent(); i++) |
344 | if(theindex!= theroots.FindKey(i)) |
345 | aNewRoots.Add(theroots.FindKey(i)); |
346 | |
347 | theroots.Clear(); |
348 | theroots = aNewRoots; |
349 | } |
350 | |
351 | thelastobj.Nullify(); |
352 | thelastbnd.Nullify(); |
353 | theindex = 0; |
354 | return Standard_True; |
355 | } |
356 | |
357 | |
358 | //======================================================================= |
359 | //function : FindElseBind |
360 | //purpose : |
361 | //======================================================================= |
362 | |
363 | Handle(Transfer_Binder) Transfer_TransferProcess::FindElseBind(const TheStart& start) |
364 | // const Standard_Integer categ) |
365 | { |
366 | Handle(Transfer_Binder) binder = FindAndMask (start);//,categ);skl |
367 | if (!binder.IsNull()) return binder; |
368 | binder = new Transfer_VoidBinder; |
369 | Bind(start,binder);//,categ);skl |
370 | return binder; |
371 | } |
372 | |
373 | |
374 | // ## ## ## Messages associes ## ## ## |
375 | |
376 | //======================================================================= |
377 | //function : SetMessenger |
378 | //purpose : |
379 | //======================================================================= |
380 | |
381 | void Transfer_TransferProcess::SetMessenger (const Handle(Message_Messenger)& messenger) |
382 | { |
383 | if ( messenger.IsNull() ) |
384 | themessenger = Message::DefaultMessenger(); |
385 | else |
386 | themessenger = messenger; |
387 | } |
388 | |
389 | //======================================================================= |
390 | //function : Messenger |
391 | //purpose : |
392 | //======================================================================= |
393 | |
394 | Handle(Message_Messenger) Transfer_TransferProcess::Messenger () const |
395 | { |
396 | return themessenger; |
397 | } |
398 | |
399 | //======================================================================= |
400 | //function : SetTraceLevel |
401 | //purpose : |
402 | //======================================================================= |
403 | |
404 | void Transfer_TransferProcess::SetTraceLevel (const Standard_Integer tracelev) |
405 | { |
406 | thetrace = tracelev; |
407 | } |
408 | |
409 | //======================================================================= |
410 | //function : TraceLevel |
411 | //purpose : |
412 | //======================================================================= |
413 | |
414 | Standard_Integer Transfer_TransferProcess::TraceLevel () const |
415 | { |
416 | return thetrace; |
417 | } |
418 | |
419 | //======================================================================= |
420 | //function : SendFail |
421 | //purpose : |
422 | //======================================================================= |
423 | |
424 | void Transfer_TransferProcess::SendFail(const TheStart& start, |
425 | const Message_Msg& amsg) |
426 | { |
427 | AddFail(start,amsg); |
428 | } |
429 | |
430 | |
431 | //======================================================================= |
432 | //function : SendWarning |
433 | //purpose : |
434 | //======================================================================= |
435 | |
436 | void Transfer_TransferProcess::SendWarning(const TheStart& start, |
437 | const Message_Msg& amsg) |
438 | { |
439 | AddWarning(start,amsg); |
440 | } |
441 | |
442 | |
443 | //======================================================================= |
444 | //function : SendMsg |
445 | //purpose : |
446 | //======================================================================= |
447 | |
448 | void Transfer_TransferProcess::SendMsg(const TheStart& start, |
449 | const Message_Msg& amsg) |
450 | { |
451 | Handle(Transfer_Binder) binder = FindAndMask(start); |
452 | if (binder.IsNull()) { |
453 | binder = new Transfer_VoidBinder; |
454 | Bind (start,binder); |
455 | } |
456 | // Alimente la trace : Regle causant (user messages) |
457 | if (thetrace > 0) { |
458 | StartTrace (binder,start,thelevel,6); |
0ebe5b0a |
459 | Message_Messenger::StreamBuffer aSender = themessenger->SendInfo(); |
460 | aSender << amsg.Value(); |
7fd59977 |
461 | if (amsg.IsEdited()&&thetrace>2) |
0ebe5b0a |
462 | aSender << " [from: " << amsg.Original() << "]"; |
463 | aSender << std::endl; |
7fd59977 |
464 | } |
465 | } |
466 | |
467 | |
468 | //======================================================================= |
469 | //function : AddFail |
470 | //purpose : |
471 | //======================================================================= |
472 | |
473 | void Transfer_TransferProcess::AddFail(const TheStart& start, |
474 | const Standard_CString mess, |
475 | const Standard_CString orig) |
476 | { |
477 | Handle(Transfer_Binder) binder = FindAndMask(start); |
478 | if (binder.IsNull()) { |
479 | binder = new Transfer_VoidBinder; |
480 | Bind (start,binder); |
481 | } |
482 | binder->AddFail (mess,orig); |
483 | if (thetrace > 0) { |
484 | StartTrace (binder,start,thelevel,1); |
0ebe5b0a |
485 | Message_Messenger::StreamBuffer aSender = themessenger->SendFail(); |
486 | aSender << " --> Fail : " << mess; |
487 | if (orig[0] != '\0'&&thetrace>2) aSender << " [from: " << orig << "]"; |
488 | aSender << std::endl; |
7fd59977 |
489 | } |
490 | } |
491 | |
492 | |
493 | //======================================================================= |
494 | //function : AddError |
495 | //purpose : |
496 | //======================================================================= |
497 | |
498 | void Transfer_TransferProcess::AddError(const TheStart& start, |
499 | const Standard_CString mess, |
500 | const Standard_CString orig) |
501 | { |
502 | AddFail (start,mess,orig); |
503 | } |
504 | |
505 | |
506 | //======================================================================= |
507 | //function : AddFail |
508 | //purpose : |
509 | //======================================================================= |
510 | |
511 | void Transfer_TransferProcess::AddFail(const TheStart& start, |
512 | const Message_Msg& amsg) |
513 | { |
514 | if (amsg.IsEdited()) AddFail (start,TCollection_AsciiString(amsg.Value()).ToCString(), |
515 | TCollection_AsciiString(amsg.Original()).ToCString()); |
516 | else AddFail (start,TCollection_AsciiString(amsg.Value()).ToCString()); |
517 | } |
518 | |
519 | |
520 | //======================================================================= |
521 | //function : AddWarning |
522 | //purpose : |
523 | //======================================================================= |
524 | |
525 | void Transfer_TransferProcess::AddWarning(const TheStart& start, |
526 | const Standard_CString mess, |
527 | const Standard_CString orig) |
528 | { |
529 | Handle(Transfer_Binder) binder = FindAndMask(start); |
530 | if (binder.IsNull()) { |
531 | binder = new Transfer_VoidBinder; |
532 | Bind (start,binder); |
533 | } |
534 | binder->AddWarning(mess,orig); |
535 | if (thetrace > 1) { |
536 | StartTrace (binder,start,thelevel,2); |
0ebe5b0a |
537 | Message_Messenger::StreamBuffer aSender = themessenger->SendWarning(); |
538 | aSender << " --> Warning : " << mess; |
539 | if (orig[0] != '\0'&&thetrace>2) aSender << " [from: " << orig << "]"; |
540 | aSender << std::endl; |
7fd59977 |
541 | } |
542 | } |
543 | |
544 | |
545 | //======================================================================= |
546 | //function : AddWarning |
547 | //purpose : |
548 | //======================================================================= |
549 | |
550 | void Transfer_TransferProcess::AddWarning(const TheStart& start, |
551 | const Message_Msg& amsg) |
552 | { |
553 | if (amsg.IsEdited()) AddWarning (start,TCollection_AsciiString(amsg.Value()).ToCString(), |
554 | TCollection_AsciiString(amsg.Original()).ToCString()); |
555 | else AddWarning (start,TCollection_AsciiString(amsg.Value()).ToCString()); |
556 | } |
557 | |
558 | |
559 | //======================================================================= |
560 | //function : Mend |
561 | //purpose : |
562 | //======================================================================= |
563 | |
564 | void Transfer_TransferProcess::Mend(const TheStart& start, |
565 | const Standard_CString pref) |
566 | { |
567 | Handle(Transfer_Binder) binder = FindAndMask(start); |
568 | if (binder.IsNull()) return; // rien a faire ... |
569 | Handle(Interface_Check) ach = binder->CCheck(); |
570 | ach->Mend (pref); |
571 | } |
572 | |
573 | |
574 | //======================================================================= |
575 | //function : Check |
576 | //purpose : |
577 | //======================================================================= |
578 | |
579 | Handle(Interface_Check) Transfer_TransferProcess::Check(const TheStart& start) const |
580 | { |
581 | const Handle(Transfer_Binder)& binder = Find(start); |
582 | if (binder.IsNull()) { |
583 | Handle(Interface_Check) check; |
584 | return check; |
585 | } |
586 | return binder->Check(); |
587 | } |
588 | |
589 | /*skl |
590 | void Transfer_TransferProcess::AddCaseName(const TheStart& start, |
591 | const Standard_CString casename) |
592 | { |
593 | AddCaseValue (start, new TCollection_HAsciiString (casename)); |
594 | } |
595 | |
596 | |
597 | void Transfer_TransferProcess::AddCaseValue(const TheStart& start, |
598 | const Handle(Standard_Transient)& caseval) |
599 | { |
600 | Handle(Transfer_Binder) binder = FindAndMask(start); |
601 | if (binder.IsNull()) { |
602 | binder = new Transfer_VoidBinder; |
603 | Bind (start,binder); |
604 | } |
605 | binder->AddCaseValue (caseval); |
606 | } |
607 | |
608 | |
609 | Handle(TColStd_HSequenceOfTransient) Transfer_TransferProcess::CaseList |
610 | (const TheStart& start) const |
611 | { |
612 | Handle(TColStd_HSequenceOfTransient) list; |
613 | const Handle(Transfer_Binder)& binder = Find(start); |
614 | if (binder.IsNull()) return list; |
615 | return binder->CaseList(); |
616 | } |
617 | |
618 | Standard_Integer Transfer_TransferProcess::NextItemWithAttribute |
619 | (const Standard_CString name, const Standard_Integer num0) const |
620 | { |
621 | Standard_Integer num, nb = NbMapped(); |
622 | for (num = num0+1; num <= nb; num ++) { |
623 | Handle(Transfer_Binder) bnd = MapItem (num); |
624 | if (bnd.IsNull()) continue; |
625 | if (!bnd->Attribute(name).IsNull()) return num; |
626 | } |
627 | return 0; |
628 | } |
629 | |
630 | |
631 | Interface_ParamType Transfer_TransferProcess::AttributeType |
632 | (const Standard_CString name) const |
633 | { |
634 | Interface_ParamType aty, res = Interface_ParamVoid; |
635 | Standard_Integer num, nb = NbMapped(); |
636 | for (num = 1; num <= nb; num ++) { |
637 | Handle(Transfer_Binder) bnd = MapItem (num); |
638 | if (bnd.IsNull()) continue; |
639 | aty = bnd->AttributeType(name); |
640 | if (aty == Interface_ParamVoid) continue; |
641 | if (res == Interface_ParamVoid) res = aty; |
642 | else if (res != aty) return Interface_ParamMisc; |
643 | } |
644 | return res; |
645 | } |
646 | |
647 | Handle(Dico_DictionaryOfInteger) Transfer_TransferProcess::Attributes |
648 | (const Standard_CString rootname) const |
649 | { |
650 | Handle(Dico_DictionaryOfInteger) list = new Dico_DictionaryOfInteger; |
651 | Standard_Integer num, nb = NbMapped(); |
652 | for (num = 1; num <= nb; num ++) { |
653 | Handle(Transfer_Binder) bnd = MapItem (num); |
654 | if (bnd.IsNull()) continue; |
655 | Handle(Dico_DictionaryOfTransient) atr = bnd->AttrList(); |
656 | if (atr.IsNull()) continue; |
657 | Dico_IteratorOfDictionaryOfTransient iatr(atr,rootname); |
658 | for (; iatr.More(); iatr.Next()) { |
659 | TCollection_AsciiString name = iatr.Name(); |
660 | Standard_Boolean deja; |
661 | Standard_Integer& nbval = list->NewItem (name.ToCString(),deja); |
662 | if (!deja) nbval = 0; |
663 | nbval ++; |
664 | } |
665 | |
666 | } |
667 | return list; |
668 | } |
669 | skl*/ |
670 | |
671 | |
672 | // ## ## ## Actions sur Types Privilegies ## ## ## |
673 | // ## ## ## (Transient) ## ## ## |
674 | |
675 | // Bind associe un objet a un objet resultat; or la Map associe un Objet a un |
676 | // Binder (qui designe son resultat) |
677 | // *Transient travaillent avec un SimpleBinderOfTransient |
678 | // si deja la, on considere son resultat |
679 | // sinon, on cree un Binder du bon type |
680 | |
681 | |
682 | //======================================================================= |
683 | //function : BindTransient |
684 | //purpose : |
685 | //======================================================================= |
686 | |
687 | void Transfer_TransferProcess::BindTransient(const TheStart& start, |
688 | const Handle(Standard_Transient)& res) |
689 | // const Standard_Integer categ) |
690 | { |
691 | if (res.IsNull()) return; |
692 | Handle(Transfer_Binder) former = Find(start);//,categ);skl |
693 | Handle(Transfer_SimpleBinderOfTransient) binder = |
694 | Handle(Transfer_SimpleBinderOfTransient)::DownCast(former); |
695 | // Binding sur place ? |
696 | if (!binder.IsNull()) { |
697 | if (binder->Status() == Transfer_StatusVoid) { binder->SetResult(res); return; } |
698 | } |
699 | // Sinon, refaire |
700 | binder = new Transfer_SimpleBinderOfTransient; |
701 | binder->SetResult (res); |
702 | if (former.IsNull()) Bind(start,binder);//,categ);skl |
703 | else Rebind(start,binder);//,categ);skl |
704 | } |
705 | |
706 | |
707 | //======================================================================= |
708 | //function : FindTransient |
709 | //purpose : |
710 | //======================================================================= |
711 | |
712 | const Handle(Standard_Transient)& Transfer_TransferProcess::FindTransient |
713 | (const TheStart& start) const |
714 | { |
715 | Handle(Transfer_SimpleBinderOfTransient) binder = |
716 | Handle(Transfer_SimpleBinderOfTransient)::DownCast(Find(start)); |
717 | if (binder.IsNull()) return nultrans; |
718 | if (!binder->HasResult()) return nultrans; |
719 | return binder->Result(); |
720 | } |
721 | |
722 | |
723 | // Binding Multiple : D abord le declarer par BindMultiple (si pas deja fait) |
724 | // Puis ajouter les termes par AddMultiple |
725 | |
726 | //======================================================================= |
727 | //function : BindMultiple |
728 | //purpose : |
729 | //======================================================================= |
730 | |
731 | void Transfer_TransferProcess::BindMultiple(const TheStart& start) |
732 | // const Standard_Integer categ) |
733 | { |
734 | Handle(Transfer_Binder) binder = FindAndMask (start);//,categ);skl |
735 | if (!binder.IsNull()) { |
736 | if (!binder->IsKind(STANDARD_TYPE(Transfer_MultipleBinder))) { |
737 | StartTrace (thelastbnd,start,thelevel,4); |
9775fa61 |
738 | throw Transfer_TransferFailure("TransferProcess : BindMultiple"); |
7fd59977 |
739 | } |
740 | } |
741 | else Bind(start,new Transfer_MultipleBinder);//,categ);skl |
742 | } |
743 | |
744 | |
745 | //======================================================================= |
746 | //function : AddMultiple |
747 | //purpose : |
748 | //======================================================================= |
749 | |
750 | void Transfer_TransferProcess::AddMultiple(const TheStart& start, |
751 | const Handle(Standard_Transient)& res) |
752 | // const Standard_Integer categ) |
753 | { |
754 | Handle(Transfer_Binder) binder = FindAndMask(start);//,categ);skl |
755 | Handle(Transfer_MultipleBinder) multr = |
756 | Handle(Transfer_MultipleBinder)::DownCast(binder); |
757 | if (multr.IsNull()) { |
758 | StartTrace (binder,start,thelevel,4); |
9775fa61 |
759 | if (binder.IsNull()) throw Transfer_TransferFailure("TransferProcess : AddMultiple, nothing bound"); |
760 | else throw Transfer_TransferFailure("TransferProcess : AddMultiple, Binder not a MultipleBinder"); |
7fd59977 |
761 | } |
762 | multr->AddResult(res); |
763 | } |
764 | |
765 | |
766 | //======================================================================= |
767 | //function : FindTypedTransient |
768 | //purpose : |
769 | //======================================================================= |
770 | |
771 | Standard_Boolean Transfer_TransferProcess::FindTypedTransient |
772 | (const TheStart& start, const Handle(Standard_Type)& atype, |
773 | Handle(Standard_Transient)& val) const |
774 | { |
775 | return GetTypedTransient (Find(start),atype,val); |
776 | } |
777 | |
778 | |
779 | //======================================================================= |
780 | //function : GetTypedTransient |
781 | //purpose : |
782 | //======================================================================= |
783 | |
784 | Standard_Boolean Transfer_TransferProcess::GetTypedTransient |
785 | (const Handle(Transfer_Binder)& binder, const Handle(Standard_Type)& atype, |
786 | Handle(Standard_Transient)& val) const |
787 | { |
788 | return Transfer_SimpleBinderOfTransient::GetTypedResult(binder,atype,val); |
789 | } |
790 | |
791 | |
792 | // ## ## ## ## ## Acces Atomique ## ## ## ## ## |
793 | // (ne gere pas le scope mais donne acces aux categories) |
794 | |
795 | //======================================================================= |
796 | //function : NbMapped |
797 | //purpose : |
798 | //======================================================================= |
799 | |
800 | Standard_Integer Transfer_TransferProcess::NbMapped () const |
801 | { |
802 | return themap.Extent(); |
803 | } |
804 | |
805 | |
806 | //======================================================================= |
807 | //function : Mapped |
808 | //purpose : |
809 | //======================================================================= |
810 | |
811 | const TheStart& Transfer_TransferProcess::Mapped(const Standard_Integer num) const |
812 | { |
813 | return themap.FindKey(num); |
814 | } |
815 | |
816 | |
817 | //======================================================================= |
818 | //function : MapIndex |
819 | //purpose : |
820 | //======================================================================= |
821 | |
822 | Standard_Integer Transfer_TransferProcess::MapIndex(const TheStart& start) const |
823 | { |
824 | return themap.FindIndex(start); |
825 | } |
826 | |
827 | |
828 | //======================================================================= |
829 | //function : MapItem |
830 | //purpose : |
831 | //======================================================================= |
832 | |
833 | Handle(Transfer_Binder) Transfer_TransferProcess::MapItem(const Standard_Integer num) const |
834 | // const Standard_Integer categ) const |
835 | { |
836 | Handle(Transfer_Binder) binder = themap.FindFromIndex(num); |
837 | //sklif (binder.IsNull()) |
838 | return binder; |
839 | //sklreturn binder->Search (categ); |
840 | } |
841 | |
842 | |
843 | // ######################################################################## |
844 | // .... ROOT MANAGEMENT .... |
845 | |
846 | //======================================================================= |
847 | //function : SetRoot |
848 | //purpose : |
849 | //======================================================================= |
850 | |
851 | void Transfer_TransferProcess::SetRoot (const TheStart& start) |
852 | { |
853 | Standard_Integer index = MapIndex(start); |
854 | if (index == 0) { |
855 | //StartTrace (thelastbnd,start,thelevel,4); |
9775fa61 |
856 | //throw Transfer_TransferFailure("TransferProcess : SetRoot"); |
7fd59977 |
857 | return; |
858 | } |
859 | |
860 | theroots.Add(index); |
861 | if (thetrace > 2) StartTrace (MapItem(index),start,thelevel,3); |
862 | } |
863 | |
864 | |
865 | //======================================================================= |
866 | //function : SetRootManagement |
867 | //purpose : |
868 | //======================================================================= |
869 | |
870 | void Transfer_TransferProcess::SetRootManagement(const Standard_Boolean stat) |
871 | { |
872 | therootm = stat; |
873 | } |
874 | |
875 | |
876 | //======================================================================= |
877 | //function : NbRoots |
878 | //purpose : |
879 | //======================================================================= |
880 | |
881 | Standard_Integer Transfer_TransferProcess::NbRoots () const |
882 | { |
883 | return theroots.Extent(); |
884 | } |
885 | |
886 | |
887 | //======================================================================= |
888 | //function : Root |
889 | //purpose : |
890 | //======================================================================= |
891 | |
892 | const TheStart& Transfer_TransferProcess::Root(const Standard_Integer num) const |
893 | { |
894 | Standard_Integer ind = 0; |
895 | if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num); |
896 | return themap.FindKey (ind); |
897 | } |
898 | |
899 | |
900 | //======================================================================= |
901 | //function : RootItem |
902 | //purpose : |
903 | //======================================================================= |
904 | |
905 | Handle(Transfer_Binder) Transfer_TransferProcess::RootItem(const Standard_Integer num) const |
906 | // const Standard_Integer categ) const |
907 | { |
908 | Standard_Integer ind = 0; |
909 | if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num); |
910 | return themap.FindFromIndex(ind);//->Search(categ);skl |
911 | } |
912 | |
913 | |
914 | //======================================================================= |
915 | //function : RootIndex |
916 | //purpose : |
917 | //======================================================================= |
918 | |
919 | Standard_Integer Transfer_TransferProcess::RootIndex(const TheStart& start) const |
920 | { |
921 | Standard_Integer index = MapIndex(start); |
922 | if (index == 0) return 0; |
923 | return theroots.FindIndex(index); |
924 | } |
925 | |
926 | |
927 | //======================================================================= |
928 | //function : NestingLevel |
929 | //purpose : |
930 | //======================================================================= |
931 | |
932 | Standard_Integer Transfer_TransferProcess::NestingLevel () const |
933 | { |
934 | return thelevel; |
935 | } |
936 | |
937 | |
938 | //======================================================================= |
939 | //function : ResetNestingLevel |
940 | //purpose : |
941 | //======================================================================= |
942 | |
943 | void Transfer_TransferProcess::ResetNestingLevel () |
944 | { |
945 | thelevel = 0; |
946 | } |
947 | |
948 | |
949 | // ######################################################################## |
950 | // .... SCOPE MANAGEMENT .... |
951 | |
952 | |
953 | //====================================================================== |
954 | //Purpose : gka TRJ9 for writing SDR for solid |
955 | // Check if binder has already been bound to the result binder. |
956 | //====================================================================== |
957 | |
958 | // static Standard_Boolean Contains(const Handle(Transfer_Binder)& resbinder, |
959 | // const Handle(Transfer_Binder)& addbinder) |
960 | // { |
961 | // Handle(Transfer_Binder) tmpbind = resbinder; |
962 | // for ( ; ! tmpbind.IsNull(); tmpbind = tmpbind->NextResult() ) |
963 | // if ( tmpbind == addbinder ) return Standard_True; |
964 | // return Standard_False; |
965 | // } |
966 | |
967 | // ######################################################################## |
968 | // .... AUTOMATISMES DE TRANSFERT .... |
969 | |
970 | // ## ## ## ## ## Fonctions de Base ## ## ## ## ## |
971 | |
972 | |
973 | //======================================================================= |
974 | //function : Recognize |
975 | //purpose : |
976 | //======================================================================= |
977 | |
978 | Standard_Boolean Transfer_TransferProcess::Recognize(const TheStart& start) const |
979 | { |
980 | Handle(Transfer_Actor) actor = theactor; |
981 | // On balaie les Next jusqu a avoir un Resultat |
982 | while (!actor.IsNull()) { |
983 | if (actor->Recognize (start)) return Standard_True; |
984 | actor = actor->Next(); |
985 | } |
986 | return Standard_False; |
987 | } |
988 | |
989 | |
990 | //======================================================================= |
991 | //function : Transferring |
992 | //purpose : |
993 | //======================================================================= |
994 | |
995 | Handle(Transfer_Binder) Transfer_TransferProcess::Transferring(const TheStart& start) |
996 | { |
997 | // Map deja alimentee ? |
998 | Handle(Transfer_Binder) former = FindAndMask(start); |
999 | |
1000 | // .... Transfert deja effectue avec Resultat ? .... |
1001 | |
1002 | // On considere que cette nouvelle demande de Transfert correspond donc a une |
1003 | // utilisation en plus : noter "AlreadyUsed", donc resultat non modifiable |
1004 | if (!former.IsNull()) { |
1005 | if (former->HasResult()) { |
1006 | former->SetAlreadyUsed(); |
1007 | return former; |
1008 | } |
1009 | //} |
1010 | |
1011 | // .... Etat Initial : peut-etre deja fait ... ou infaisable ! |
1012 | |
0ebe5b0a |
1013 | Message_Messenger::StreamBuffer aSender = themessenger->SendInfo(); |
7fd59977 |
1014 | //if (!former.IsNull()) { |
1015 | Transfer_StatusExec statex = former->StatusExec(); |
1016 | switch (statex) { |
1017 | case Transfer_StatusInitial : // Transfert prepare a faire |
1018 | break; |
1019 | case Transfer_StatusDone : // Transfert deja fait |
1020 | //#ifdef TRANSLOG |
0ebe5b0a |
1021 | aSender << " .. and Transfer done" << std::endl; |
7fd59977 |
1022 | //#endif |
1023 | // if (former->HasResult()) former->SetAlreadyUsed(); |
1024 | return former; |
1025 | case Transfer_StatusRun : // ca y est, on boucle |
1026 | former->SetStatusExec(Transfer_StatusLoop); |
1027 | return former; |
1028 | case Transfer_StatusError : // pas propre, ca ... |
1029 | if (thetrace) { |
0ebe5b0a |
1030 | aSender << " *** Transfer in Error Status :" << std::endl; |
7fd59977 |
1031 | StartTrace (former, start, thelevel,0); |
1032 | // (*themessenger->Out()) << flush; |
1033 | } |
1034 | else StartTrace (former, start,thelevel,4); |
9775fa61 |
1035 | throw Transfer_TransferFailure("TransferProcess : Transfer in Error Status"); |
7fd59977 |
1036 | case Transfer_StatusLoop : // la boucle est bouclee ... |
1037 | if (thetrace) { |
0ebe5b0a |
1038 | aSender << " *** Transfer Head of Dead Loop :" << std::endl; |
7fd59977 |
1039 | StartTrace (former, start, thelevel,0); |
1040 | // (*themessenger->Out()) << flush; |
1041 | } |
1042 | else StartTrace (former, start,thelevel,4); |
9775fa61 |
1043 | throw Transfer_TransferDeadLoop("TransferProcess : Transfer at Head of a Dead Loop"); |
7fd59977 |
1044 | } |
1045 | #ifdef TRANSLOG |
04232180 |
1046 | std::cout << "Transfer,level "<<thelevel<<Message_Flush; |
7fd59977 |
1047 | #endif |
1048 | //} |
1049 | |
1050 | // .... OK, on peut lancer l Execution |
1051 | //if (!former.IsNull()) |
1052 | former->SetStatusExec(Transfer_StatusRun); |
1053 | } |
1054 | #ifdef TRANSLOG |
04232180 |
1055 | std::cout << " GO .." << std::endl; |
7fd59977 |
1056 | #endif |
1057 | |
1058 | Handle(Transfer_Binder) binder; |
1059 | Standard_Boolean newbind = Standard_False; |
1060 | if (theerrh) { |
0ebe5b0a |
1061 | Message_Messenger::StreamBuffer aSender = themessenger->SendInfo(); |
1062 | |
7fd59977 |
1063 | // Transfert sous protection pour les exceptions (pour notification en fait) |
1064 | Standard_Integer oldlev = thelevel; |
1065 | try { |
1066 | OCC_CATCH_SIGNALS |
1067 | binder = TransferProduct(start); |
1068 | } |
1069 | |
1070 | // ... Exceptions a Rattraper : elles ne se ressemblent pas toutes ... ! |
a738b534 |
1071 | catch (Transfer_TransferDeadLoop const&) { |
7fd59977 |
1072 | if (binder.IsNull()) { |
0ebe5b0a |
1073 | aSender << " *** Dead Loop with no Result" << std::endl; |
7fd59977 |
1074 | if (thetrace) StartTrace (binder, start, thelevel-1,0); |
1075 | binder = new Transfer_VoidBinder; |
1076 | Bind (start,binder); newbind = Standard_True; |
1077 | } else if (binder->StatusExec() == Transfer_StatusLoop) { |
1078 | if (thetrace) { |
0ebe5b0a |
1079 | aSender << " *** Dead Loop : Finding head of Loop :" << std::endl; |
7fd59977 |
1080 | StartTrace (binder, start, thelevel-1,0); |
1081 | } |
1082 | else StartTrace (binder, start,thelevel-1,4); |
9775fa61 |
1083 | throw Transfer_TransferFailure("TransferProcess : Head of Dead Loop"); |
7fd59977 |
1084 | // Autrement dit, on change d exception (on est sorti de la boucle) |
1085 | } else { |
1086 | if (thetrace) { |
0ebe5b0a |
1087 | aSender << " *** Dead Loop : Actor in Loop :" << std::endl; |
7fd59977 |
1088 | StartTrace (binder, start, thelevel-1,0); |
1089 | } |
1090 | } |
1091 | binder->AddFail("Transfer in dead Loop"); |
1092 | thelevel = oldlev; |
1093 | } |
9775fa61 |
1094 | catch (Standard_Failure const& anException) { |
7fd59977 |
1095 | if (binder.IsNull()) { |
0ebe5b0a |
1096 | aSender << " *** Exception Raised with no Result" << std::endl; |
7fd59977 |
1097 | binder = new Transfer_VoidBinder; |
1098 | Bind (start,binder); newbind = Standard_True; |
1099 | } |
1100 | binder->AddFail("Transfer stopped by exception raising"); |
1101 | if (thetrace) { |
0ebe5b0a |
1102 | aSender << " *** Raised : " << anException.GetMessageString() << std::endl; |
7fd59977 |
1103 | StartTrace (binder, start, thelevel-1,4); |
1104 | } |
1105 | thelevel = oldlev; |
1106 | } |
1107 | } |
1108 | |
1109 | // Transfert non protege (ainsi, dbx a la main en cas de plantage par Raise) |
1110 | else binder = TransferProduct(start); |
1111 | |
1112 | // .... Conclusion : Noter dans la Map .... |
1113 | |
1114 | if (!newbind && !binder.IsNull()) { |
1115 | if (former.IsNull()) { |
1116 | // Peut-etre <theactor> a fait lui meme Bind ... verifier sinon le faire |
1117 | if (!IsBound(start)) Bind(start,binder); // resultat = categorie 0 |
1118 | else { // gka TRJ9 for writing SDR for solid |
1119 | // Handle(Transfer_Binder) tmpbind = Find(start); |
1120 | // if(!Contains(binder,tmpbind)) |
1121 | // binder->AddResult(tmpbind); |
1122 | Rebind(start,binder); // test_pattern.sat |
1123 | } |
1124 | } |
1125 | else Rebind(start,binder); |
1126 | // (du coup, <thelastbnd> vaut <binder>) |
1127 | #ifdef TRANSLOG |
04232180 |
1128 | std::cout << " ... OK" << std::endl; |
7fd59977 |
1129 | #endif |
1130 | } |
1131 | else { |
1132 | //= by ABV: 5 Oct 97: nothing generated, but former can be in run state - drop it |
1133 | //= ASK: may be set it to StatusInitial ? |
1134 | if ( ! former.IsNull() ) former->SetStatusExec ( Transfer_StatusDone ); //+ |
1135 | return nulbinder; // Binder Null ... que faire d autre ? |
1136 | } |
1137 | |
1138 | // .... Gerer les Racines (si prevu) .... |
1139 | |
1140 | if (therootl >= thelevel) { |
1141 | therootl = 0; |
1142 | if (therootm && binder->Status() != Transfer_StatusVoid) { |
1143 | SetRoot (start); |
1144 | } |
1145 | } |
1146 | return thelastbnd; |
1147 | } |
1148 | |
1149 | // ## ## TransferProduct : Action proprement dite ## ## |
1150 | |
1151 | Handle(Transfer_Binder) Transfer_TransferProcess::TransferProduct |
1152 | (const TheStart& start) |
1153 | { |
1154 | thelevel ++; // si decremente et == 0, transfert racine |
1155 | Handle(Transfer_Binder) binder; |
1156 | Handle(Transfer_Actor) actor = theactor; |
1157 | |
1158 | // On balaie les Next jusqu a avoir un Resultat |
1159 | while (!actor.IsNull()) { |
1160 | if (actor->Recognize (start)) binder = actor->Transferring(start,this); |
1161 | else binder.Nullify(); |
1162 | if (!binder.IsNull()) break; |
1163 | actor = actor->Next(); |
1164 | } |
1165 | if (binder.IsNull()) { |
1166 | // if (thetrace) { |
0ebe5b0a |
1167 | // aSender << "Transfer has produced no Result" <<endl; |
7fd59977 |
1168 | // StartTrace (binder, start, thelevel-1,0); sout << flush; |
1169 | // } |
1170 | if (thelevel > 0) thelevel --; |
1171 | return binder; |
1172 | } |
1173 | // Gestion du niveau racine (.. a regarder de pres ..) |
1174 | if (therootl == 0 && binder->StatusExec() == Transfer_StatusDone) |
1175 | therootl = thelevel - 1; |
1176 | |
1177 | if (thelevel > 0) thelevel --; |
1178 | return binder; |
1179 | } |
1180 | |
1181 | |
1182 | //======================================================================= |
1183 | //function : Transfer |
1184 | //purpose : |
1185 | //======================================================================= |
1186 | |
1187 | Standard_Boolean Transfer_TransferProcess::Transfer(const TheStart& start) |
1188 | { |
1189 | Handle(Transfer_Binder) binder = Transferring(start); |
1190 | return (!binder.IsNull()); |
1191 | } |
1192 | |
1193 | |
1194 | // ######################################################################### |
1195 | // .... Error Handling + Trace .... |
1196 | |
1197 | // trace : 1 pour Fail et Exception , 2 pour Root et Warning |
1198 | |
1199 | |
1200 | //======================================================================= |
1201 | //function : SetErrorHandle |
1202 | //purpose : |
1203 | //======================================================================= |
1204 | |
1205 | void Transfer_TransferProcess::SetErrorHandle(const Standard_Boolean err) |
1206 | { |
1207 | theerrh = err; |
1208 | } // traite par Transferring |
1209 | |
1210 | |
1211 | //======================================================================= |
1212 | //function : ErrorHandle |
1213 | //purpose : |
1214 | //======================================================================= |
1215 | |
1216 | Standard_Boolean Transfer_TransferProcess::ErrorHandle() const |
1217 | { |
1218 | return theerrh; |
1219 | } |
1220 | |
1221 | //======================================================================= |
1222 | //function : StartTrace |
1223 | //purpose : |
1224 | //======================================================================= |
1225 | |
1226 | void Transfer_TransferProcess::StartTrace(const Handle(Transfer_Binder)& binder, |
1227 | const TheStart& start, |
1228 | const Standard_Integer level, |
1229 | const Standard_Integer mode) const |
1230 | { |
0ebe5b0a |
1231 | Message_Messenger::StreamBuffer aSender = themessenger->SendInfo(); |
7fd59977 |
1232 | // ### Fail (Roots:50) -- Start start->DynamicType() |
1233 | // ### Fail (Roots:50) -- Start id:#label.. Type:start->DynamicType() |
1234 | if (thetrace > 3) { // Internal to be switch when searching bug (trace >= 4) |
0ebe5b0a |
1235 | if (mode == 1) aSender << " ### Fail"; |
1236 | if (mode == 2) aSender << " ### Warning"; |
1237 | if (mode == 3) aSender << " ### New Root n0 " << theroots.Extent(); |
1238 | if (mode == 4) aSender << " ### Exception"; |
1239 | if (mode == 5) aSender << " ### Substitution"; |
1240 | if (mode == 6) aSender << " ### Information"; |
7fd59977 |
1241 | if (level > 1) |
0ebe5b0a |
1242 | aSender << " (nested)"; // " at nesting Level:"<<level; |
7fd59977 |
1243 | if (mode >= 0 && mode != 3) |
0ebe5b0a |
1244 | aSender << " at " << theroots.Extent() << " Roots"; |
7fd59977 |
1245 | } |
0ebe5b0a |
1246 | if (!start.IsNull()) PrintTrace (start,aSender); |
7fd59977 |
1247 | //// sout << endl; |
1248 | |
1249 | if (!binder.IsNull()) { // old: if IsNull sout <<endl<< " --- Not Bound"; |
1250 | Handle(Transfer_Binder) bnd = binder; |
96a95605 |
1251 | Standard_Boolean hasres = Standard_False; |
7fd59977 |
1252 | while (!bnd.IsNull()) { |
1253 | if (bnd->Status() != Transfer_StatusVoid) { |
1254 | // --- Result Type: binder->ResultType() --- Binder : binder->DynamicType(); |
1255 | if (!hasres) |
0ebe5b0a |
1256 | aSender << "\n --- Result Type : "; |
7fd59977 |
1257 | else |
0ebe5b0a |
1258 | aSender << " , "; |
1259 | aSender << bnd->ResultTypeName(); |
7fd59977 |
1260 | // CKY 9-JAN-1999: waiting for XSTEP Kernel message (not IGES_2075) |
1261 | /* Message_Msg Msg2075("IGES_2075"); |
1262 | Msg2075.AddString(bnd->ResultTypeName()); |
1263 | Msg2075.TraceEver(); */ |
1264 | hasres = Standard_True; |
7fd59977 |
1265 | } |
1266 | bnd = bnd->NextResult(); |
1267 | } |
1268 | if (!hasres && mode > 2) { |
0ebe5b0a |
1269 | aSender << "\n --- No Result recorded"; |
7fd59977 |
1270 | // CKY 9-JAN-1999 : waiting for XSTEP Kernel message |
1271 | // (not IGES_2075, no reference to specifically TopoDS_Shape) |
1272 | /* Message_Msg Msg2075("IGES_2075"); |
1273 | Msg2075.AddString("No TopoDS_Shape"); |
1274 | Msg2075.TraceEver(); */ |
1275 | } |
1276 | //old if (isused) sout << " -- (Already Used in another Transfer)"; |
1277 | } |
0ebe5b0a |
1278 | aSender << std::endl; |
7fd59977 |
1279 | } |
1280 | |
1281 | |
1282 | //======================================================================= |
1283 | //function : PrintTrace |
1284 | //purpose : |
1285 | //======================================================================= |
1286 | |
0ebe5b0a |
1287 | void Transfer_TransferProcess::PrintTrace(const TheStart& start, Standard_OStream& S) const |
7fd59977 |
1288 | { |
1289 | if (!start.IsNull()) S <<" Type:" << start->DynamicType()->Name(); |
1290 | } |
1291 | |
1292 | |
1293 | //======================================================================= |
1294 | //function : IsLooping |
1295 | //purpose : |
1296 | //======================================================================= |
1297 | |
1298 | Standard_Boolean Transfer_TransferProcess::IsLooping |
1299 | (const Standard_Integer alevel) const |
1300 | { return alevel > NbMapped(); } |
1301 | |
1302 | |
1303 | |
1304 | // ######################################################################### |
1305 | // .... RESULTATS .... |
1306 | |
1307 | |
1308 | // ## ## RootResult : Les Racines ## ## |
1309 | |
1310 | |
1311 | //======================================================================= |
1312 | //function : RootResult |
1313 | //purpose : |
1314 | //======================================================================= |
1315 | |
1316 | Transfer_Iterator Transfer_TransferProcess::RootResult(const Standard_Boolean withstart) const |
1317 | { |
1318 | Transfer_Iterator iter(withstart); |
1319 | Standard_Integer max = theroots.Extent(); |
1320 | for (Standard_Integer j = 1; j <= max; j ++) { |
1321 | Standard_Integer i = theroots.FindKey(j); |
1322 | Handle(Transfer_Binder) binder = MapItem(i); |
1323 | if (binder.IsNull()) continue; |
1324 | if (withstart) iter.Add (binder,Mapped(i)); |
1325 | else iter.Add (binder); |
1326 | } |
1327 | return iter; |
1328 | } |
1329 | |
1330 | |
1331 | // ## ## CompleteResult : Tous les Resultats ## ## |
1332 | |
1333 | //======================================================================= |
1334 | //function : CompleteResult |
1335 | //purpose : |
1336 | //======================================================================= |
1337 | |
1338 | Transfer_Iterator Transfer_TransferProcess::CompleteResult |
1339 | (const Standard_Boolean withstart) const |
1340 | { |
1341 | Transfer_Iterator iter(withstart); |
1342 | Standard_Integer max = NbMapped(); |
1343 | for (Standard_Integer i = 1; i <= max; i ++) { |
1344 | Handle(Transfer_Binder) binder = MapItem(i); |
1345 | if (binder.IsNull()) continue; |
1346 | if (withstart) iter.Add (binder,Mapped(i)); |
1347 | else iter.Add (binder); |
1348 | } |
1349 | return iter; |
1350 | } |
1351 | |
1352 | |
1353 | // ## ## AbnormalResult : Transferts a probleme ## ## |
1354 | //======================================================================= |
1355 | //function : AbnormalResult |
1356 | //purpose : |
1357 | //======================================================================= |
1358 | |
1359 | Transfer_Iterator Transfer_TransferProcess::AbnormalResult() const |
1360 | { |
1361 | Transfer_Iterator iter(Standard_True); |
1362 | Standard_Integer max = NbMapped(); |
1363 | for (Standard_Integer i = 1; i <= max; i ++) { |
1364 | Handle(Transfer_Binder) binder = MapItem(i); |
1365 | if (binder.IsNull()) continue; |
1366 | Transfer_StatusExec statex = binder->StatusExec(); |
1367 | if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone) |
1368 | iter.Add (binder,Mapped(i)); // on note les cas "pas normaux" |
1369 | } |
1370 | return iter; |
1371 | } |
1372 | |
1373 | |
1374 | // ## ## ## CheckList : les messages ## ## ## |
1375 | //======================================================================= |
1376 | //function : CheckList |
1377 | //purpose : |
1378 | //======================================================================= |
1379 | |
1380 | Interface_CheckIterator Transfer_TransferProcess::CheckList |
1381 | (const Standard_Boolean erronly) const |
1382 | { |
1383 | Interface_CheckIterator list; |
1384 | Standard_Integer num, max = NbMapped(); |
1385 | for (Standard_Integer i = 1; i <= max; i ++) { |
1386 | Handle(Transfer_Binder) binder = MapItem(i); |
1387 | if (binder.IsNull()) continue; |
1388 | Transfer_StatusExec statex = binder->StatusExec(); |
1389 | Handle(Interface_Check) check = binder->Check(); |
1390 | if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone && |
1391 | !check->HasFailed()) |
1392 | check->AddFail("Transfer in Abnormal Status (!= Initial or Done)"); |
1393 | if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue; |
1394 | const TheStart& ent = Mapped(i); |
1395 | num = CheckNum(ent); |
1396 | if (num == 0) num = i; |
1397 | check->SetEntity(ent); |
1398 | list.Add(check,num); |
1399 | } |
1400 | return list; |
1401 | } |
1402 | |
1403 | |
1404 | // ######################################################################### |
1405 | // .... RESULTATS PAR ENTITE .... |
1406 | |
1407 | //======================================================================= |
1408 | //function : ResultOne |
1409 | //purpose : |
1410 | //======================================================================= |
1411 | |
1412 | Transfer_Iterator Transfer_TransferProcess::ResultOne(const TheStart& start, |
1413 | const Standard_Integer level, |
1414 | const Standard_Boolean withstart) const |
1415 | { |
1416 | Transfer_Iterator iter(withstart); |
1417 | Standard_Integer max = NbMapped(); |
1418 | Standard_Integer ind = MapIndex (start); |
1419 | if (ind == 0) return iter; |
1420 | Standard_Integer i1 = (level == 0 ? ind : 1); |
1421 | Standard_Integer i2 = (level == 0 ? ind : max); |
1422 | Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0); |
1423 | //MarkScoped (ind,level,map); |
1424 | |
1425 | for (Standard_Integer i = i1; i <= i2; i ++) { |
1426 | ind = map->Value(i); |
1427 | if (ind == 0) continue; |
1428 | Handle(Transfer_Binder) binder = MapItem(i); |
1429 | if (binder.IsNull()) continue; |
1430 | if (withstart) iter.Add (binder,Mapped(ind)); |
1431 | else iter.Add (binder); |
1432 | } |
1433 | return iter; |
1434 | } |
1435 | |
1436 | |
1437 | //======================================================================= |
1438 | //function : CheckListOne |
1439 | //purpose : |
1440 | //======================================================================= |
1441 | |
1442 | Interface_CheckIterator Transfer_TransferProcess::CheckListOne |
1443 | (const TheStart& start,const Standard_Integer level, |
1444 | const Standard_Boolean erronly) const |
1445 | { |
1446 | Interface_CheckIterator list; |
1447 | Standard_Integer max = NbMapped(); |
1448 | Standard_Integer num, ind = MapIndex (start); |
1449 | if (ind == 0) return list; |
1450 | Standard_Integer i1 = (level == 0 ? ind : 1); |
1451 | Standard_Integer i2 = (level == 0 ? ind : max); |
1452 | Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0); |
1453 | //MarkScoped (ind,level,map); |
1454 | |
1455 | for (Standard_Integer i = i1; i <= i2; i ++) { |
1456 | ind = map->Value(i); |
1457 | if (ind == 0) continue; |
1458 | Handle(Transfer_Binder) binder = MapItem(ind); |
1459 | if (binder.IsNull()) continue; |
1460 | Transfer_StatusExec statex = binder->StatusExec(); |
1461 | Handle(Interface_Check) check = binder->Check(); |
1462 | if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone && |
1463 | !check->HasFailed()) |
1464 | check->AddFail("Transfer in Abnormal Status (!= Initial or Done)"); |
1465 | if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue; |
1466 | const TheStart& ent = Mapped(ind); |
1467 | num = CheckNum(ent); if (num == 0) num = ind; |
1468 | check->SetEntity(ent); |
1469 | list.Add(check,num); |
1470 | } |
1471 | return list; |
1472 | } |
1473 | |
1474 | |
1475 | //======================================================================= |
1476 | //function : IsCheckListEmpty |
1477 | //purpose : |
1478 | //======================================================================= |
1479 | |
1480 | Standard_Boolean Transfer_TransferProcess::IsCheckListEmpty |
1481 | (const TheStart& start, const Standard_Integer level, |
1482 | const Standard_Boolean erronly) const |
1483 | { |
1484 | Standard_Integer max = NbMapped(); |
1485 | Standard_Integer ind = MapIndex (start); |
1486 | if (ind == 0) return Standard_False; |
1487 | Standard_Integer i1 = (level == 0 ? ind : 1); |
1488 | Standard_Integer i2 = (level == 0 ? ind : max); |
1489 | Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0); |
1490 | // MarkScoped (ind,level,map); |
1491 | |
1492 | for (Standard_Integer i = i1; i <= i2; i ++) { |
1493 | ind = map->Value(i); |
1494 | if (ind == 0) continue; |
1495 | Handle(Transfer_Binder) binder = MapItem(ind); |
1496 | if (binder.IsNull()) continue; |
1497 | |
1498 | Transfer_StatusExec statex = binder->StatusExec(); |
1499 | Handle(Interface_Check) check = binder->Check(); |
1500 | if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone) |
1501 | return Standard_False; |
1502 | if (check->HasFailed() || (!erronly && check->NbWarnings() > 0)) return Standard_False; |
1503 | } |
1504 | return Standard_True; |
1505 | } |
1506 | |
1507 | |
1508 | //======================================================================= |
1509 | //function : RemoveResult |
1510 | //purpose : |
1511 | //======================================================================= |
1512 | |
1513 | void Transfer_TransferProcess::RemoveResult(const TheStart& start, |
1514 | const Standard_Integer level, |
1515 | const Standard_Boolean /*compute*/) |
1516 | { |
1517 | //if (compute) ComputeScopes(); |
1518 | Standard_Integer max = NbMapped(); |
1519 | Standard_Integer ind = MapIndex (start); |
1520 | if (ind == 0) return; |
1521 | Standard_Integer i1 = (level == 0 ? ind : 1); |
1522 | Standard_Integer i2 = (level == 0 ? ind : max); |
1523 | Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0); |
1524 | // MarkScoped (ind,level,map); |
1525 | |
1526 | Standard_Integer i; // svv Jan11 2000 : porting on DEC |
1527 | for (i = i1; i <= i2; i ++) { |
1528 | ind = map->Value(i); |
1529 | if (ind == 0) continue; |
1530 | Handle(Transfer_Binder) binder = MapItem(ind); |
1531 | if (binder.IsNull()) continue; |
1532 | // Standard_Boolean cayest = binder->SetNbUserScopes (-1); |
1533 | // if (cayest) themap(ind) = nulbinder; // RAZ ! |
1534 | } |
1535 | |
1536 | //pdn commented for (i = NbRoots(); i > 0; i --) |
1537 | // if (theroots.Value(i) == ind) theroots.Remove(i); |
1538 | } |
1539 | |
1540 | |
1541 | Standard_Integer Transfer_TransferProcess::CheckNum(const TheStart& ) const |
1542 | { |
1543 | return 0; |
1544 | } |
1545 | |
1546 | |
1547 | //======================================================================= |
1548 | //function : SetProgress |
1549 | //purpose : Sets Progress indicator |
1550 | //======================================================================= |
1551 | |
1552 | void Transfer_TransferProcess::SetProgress(const Handle(Message_ProgressIndicator)& theProgress) |
1553 | { |
1554 | myProgress = theProgress; |
1555 | } |
1556 | |
1557 | //======================================================================= |
1558 | //function : GetProgress |
1559 | //purpose : Returns Progress indicator |
1560 | //======================================================================= |
1561 | |
1562 | Handle(Message_ProgressIndicator) Transfer_TransferProcess::GetProgress() const |
1563 | { |
1564 | return myProgress; |
1565 | } |