summaryrefslogtreecommitdiff
path: root/inc/Transfer_TransferProcess.gxx
blob: 6e231e1393d1a735c8c470e90ab6fe72c8e5a8eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
// DCE 21.01.99 S3767 Display original messages only 
//	 if the level is greater than 2

//#include <Transfer_TransferProcess.ixx>
//  Class generique

//  TheStart est suppose Handle(Standard_Transient) ou (Transfer_Finder)
//  Il doit offrir : "==" , .IsNull() , ->DynamicType()

#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>

#include <Message_Messenger.hxx>
#include <Message_Msg.hxx>
#include <Message.hxx>

#include <Transfer_VoidBinder.hxx>
#include <Transfer_SimpleBinderOfTransient.hxx>
#include <Transfer_MultipleBinder.hxx>
#include <Transfer_StatusResult.hxx>
#include <Transfer_TransferFailure.hxx>
#include <Transfer_TransferDeadLoop.hxx>

#include <TCollection_HAsciiString.hxx>
#include <Dico_DictionaryOfTransient.hxx>
#include <Dico_IteratorOfDictionaryOfTransient.hxx>
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_HArray1OfInteger.hxx>


//#define TRANSLOG   // debug

static Handle(Standard_Transient)  nultrans;   // pour retour const&(Null) ...
static Handle(Transfer_Binder)     nulbinder;


//=======================================================================
//function : Transfer_TransferProcess
//purpose  : 
//=======================================================================

Transfer_TransferProcess::Transfer_TransferProcess (const Standard_Integer nb)
      : themap (nb)
{
  theerrh  = Standard_True;
  therootm = Standard_False;
  thelevel = 0;     therootl  = 0;
  themessenger = Message::DefaultMessenger();
  thetrace = 0;
//  theroots = new TColStd_HSequenceOfInteger ();
  theindex = 0;
}


//=======================================================================
//function : Transfer_TransferProcess
//purpose  : 
//=======================================================================

Transfer_TransferProcess::Transfer_TransferProcess(const Handle(Message_Messenger)& messenger,
						   const Standard_Integer nb)
     : themap (nb)
{
  theerrh  = Standard_True;
  therootm = Standard_False;
  thelevel = 0;     therootl  = 0;
  SetMessenger (messenger);
  thetrace = 1;
//  theroots = new TColStd_HSequenceOfInteger ();
  theindex = 0;
}

    void Transfer_TransferProcess::Clear ()
{
  thelevel = 0;     therootl  = 0;
  theroots.Clear();
  themap.Clear();
  theindex = 0;  thelastobj.Nullify();  thelastbnd.Nullify();
}

    void Transfer_TransferProcess::Clean ()
{
  Standard_Integer i, nb = NbMapped();
  Standard_Integer j,unb = 0;
  for (i = 1; i <= nb; i ++) {
    if (themap(i).IsNull()) unb ++;
  }
  if (unb == 0) return;

//   Refaire la map -> decalages
  TColStd_Array1OfInteger unbs (1,nb);  unbs.Init(0);
  Transfer_TransferMap newmap (nb*2);
  for (i = 1; i <= nb; i ++) {
    TheStart ent = Mapped(i);
    Handle(Transfer_Binder) bnd = MapItem(i);
    if (bnd.IsNull()) continue;
    j = newmap.Add (ent,bnd);
    unbs.SetValue (i,j);
  }
  themap.Assign (newmap);

  // Update   La liste des racines
  TColStd_IndexedMapOfInteger aNewRoots;
  for( i=1; i<= theroots.Extent(); i++ ) {
    j = theroots.FindKey(i);
    Standard_Integer k = unbs.Value(j);
    if ( k ) aNewRoots.Add ( k );
  }
  theroots.Clear();
  theroots = aNewRoots;

//    Le reste : nettoyage
  thelastobj.Nullify();
  thelastbnd.Nullify();
  theindex = 0;
}


//=======================================================================
//function : Resize
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::Resize (const Standard_Integer nb)
{
  if (nb > themap.NbBuckets()) themap.ReSize(nb);
}


//=======================================================================
//function : SetActor
//purpose  : 
//=======================================================================

void  Transfer_TransferProcess::SetActor(const Handle(Transfer_Actor)& actor)
{
  if (theactor == actor)         return;
  if (theactor.IsNull())         theactor = actor;
  else if (actor.IsNull())       theactor = actor;  // declenche RAZ
  else if (theactor->IsLast()) { actor->SetNext(theactor);  theactor = actor; }
  else                           theactor->SetNext(actor);
}


//=======================================================================
//function : Actor
//purpose  : 
//=======================================================================

Handle(Transfer_Actor)  Transfer_TransferProcess::Actor () const 
{
  return theactor;
}


//  ########################################################################
//  ....                             MAPPING                            ....

//  ##    ##    ##       Actions Generales sur Binders       ##    ##    ##
//  ##    ##    ##               Consultations               ##    ##    ##


//        ##    ##    Find    ##    ##

//=======================================================================
//function : Find
//purpose  : 
//=======================================================================

Handle(Transfer_Binder) Transfer_TransferProcess::Find (const TheStart& start) const
//							 const Standard_Integer categ) const
{
  if (thelastobj == start) {
    //if (theindex > 0) return thelastbnd->Search(categ); //skl
    if (theindex > 0) return thelastbnd; //skl
  }
  Standard_Integer index = themap.FindIndex (start);
  if (index > 0) {
    const Handle(Transfer_Binder)& binder = themap.FindFromIndex(index);
    //if (binder.IsNull()) //skl
    return binder;
    //return binder->Search(categ); //skl
  }
  return nulbinder;
}

//        ##    ##    IsBound    ##    ##

//=======================================================================
//function : IsBound
//purpose  : 
//=======================================================================

Standard_Boolean  Transfer_TransferProcess::IsBound(const TheStart& start) const
//						    const Standard_Integer categ) const
{
  Handle(Transfer_Binder) binder = Find(start); //,categ); skl
  if (binder.IsNull()) return Standard_False;
  return binder->HasResult();
}

//        ##    ##    IsAlreadyUsed    ##    ##

//=======================================================================
//function : IsAlreadyUsed
//purpose  : 
//=======================================================================

Standard_Boolean Transfer_TransferProcess::IsAlreadyUsed(const TheStart& start) const
//							 const Standard_Integer categ) const
{
  Handle(Transfer_Binder) binder = Find(start); //,categ); skl
  if (binder.IsNull()) {
    StartTrace (binder,start,thelevel,4);
    Transfer_TransferFailure::Raise
      ("TransferProcess : IsAlreadyUsed, transfer not done cannot be used...");
  }
  return (binder->Status() == Transfer_StatusUsed);
}


//        ##    ##    FindAndMask (private)    ##    ##

//=======================================================================
//function : FindAndMask
//purpose  : 
//=======================================================================

Handle(Transfer_Binder) Transfer_TransferProcess::FindAndMask(const TheStart& start)
//							      const Standard_Integer categ)
{
  if (thelastobj == start) {
    if (theindex > 0) return thelastbnd; //skl ->Search(categ);
  }
  thelastobj = start;
  theindex   = themap.FindIndex (start);
  if (theindex > 0) thelastbnd = themap.FindFromIndex(theindex);
  else thelastbnd.Nullify();
  //if (thelastbnd.IsNull()) skl
  return thelastbnd;
  //return thelastbnd->Search(categ); //skl
}


//  ##    ##    ##               Modifications               ##    ##    ##


//=======================================================================
//function : Bind
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::Bind (const TheStart& start,
				     const Handle(Transfer_Binder)& binder)
//				      const Standard_Integer categ)
{
  if (binder.IsNull()) return;
  Handle(Transfer_Binder) former = FindAndMask(start);//,categ);skl
  if (!former.IsNull()) {
//  On admet VoidBinder : alors on reprend son Check
    if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) {
      binder->Merge(former);
      //binder->SetCategory(categ); //skl
      themap(theindex) = binder;                          // Substitution
    }
    else if (former->Status() == Transfer_StatusUsed) {
      StartTrace (former,start,thelevel,4);
      Transfer_TransferFailure::Raise
	("TransferProcess : Bind, already Bound");
    }
    else {
      if (thetrace > 2) StartTrace (former,start,thelevel,5);
      binder->CCheck()->GetMessages (former->Check());
    }
  }
  //binder->SetCategory(categ); //skl
  if (theindex == 0 || thelastbnd.IsNull()) {
    if (theindex == 0) theindex = themap.Add(start,binder);  // Nouveau
    else themap(theindex) = binder;                          // idem en fait
    thelastbnd = binder;
  }
  else { //skl
    //binder->AddResult(thelastbnd);
    thelastbnd  = binder;
    themap(theindex) = binder;
  }
/*skl else if (thelastbnd->Category() == categ) {   // Substitue cette categorie
    binder->Next(Standard_False)->SetNext(thelastbnd->Next(Standard_True),Standard_True);
    thelastbnd  = binder;
    themap(theindex) = binder;
  } else {
    thelastbnd->AddNext (binder,categ,Standard_True);
  } */
}


//=======================================================================
//function : Rebind
//purpose  : 
//=======================================================================

void  Transfer_TransferProcess::Rebind (const TheStart& start,
					const Handle(Transfer_Binder)& binder)
//					const Standard_Integer categ)
{
  Bind(start,binder); //,categ);skl
  // entre les deux, les differences allaient s amenuisant
  //  au debut, on criait si pas encore Bound (idiot)
  //  ne restait plus comme difference que le test StatusUsed sur Rebind,
  //    tandis que Bind refusait des lors qu il y avait un resultat
  //  -> a present, Bind s aligne sur Rebind
}


//=======================================================================
//function : Unbind
//purpose  : 
//=======================================================================

Standard_Boolean Transfer_TransferProcess::Unbind(const TheStart& start)
//						   const Standard_Integer categ)
{
  Handle(Transfer_Binder) former = FindAndMask(start);//,categ);skl
  if (theindex == 0) return Standard_False;
  if (former.IsNull()) return Standard_False;
  if (former->DynamicType() == STANDARD_TYPE(Transfer_VoidBinder)) return Standard_True;
  //const Interface_Check& ach = thelastbnd->Check();
  //Handle(Transfer_Binder) newbinder = thelastbnd->RemoveNext(categ);skl
  //if (newbinder != thelastbnd)skl
    themap(theindex) = thelastbnd;// = newbinder;skl
  if(theroots.Contains(theindex)) {
    TColStd_IndexedMapOfInteger aNewRoots;
    for(Standard_Integer i = 1; i <= theroots.Extent(); i++)
      if(theindex!= theroots.FindKey(i))
	aNewRoots.Add(theroots.FindKey(i));
    
    theroots.Clear();
    theroots = aNewRoots;
  }

  thelastobj.Nullify();
  thelastbnd.Nullify();
  theindex = 0;
  return Standard_True;
}


//=======================================================================
//function : FindElseBind
//purpose  : 
//=======================================================================

Handle(Transfer_Binder) Transfer_TransferProcess::FindElseBind(const TheStart& start)
//							       const Standard_Integer categ)
{
  Handle(Transfer_Binder) binder = FindAndMask (start);//,categ);skl
  if (!binder.IsNull()) return binder;
  binder = new Transfer_VoidBinder;
  Bind(start,binder);//,categ);skl
  return binder;
}


//  ##    ##    ##              Messages associes              ##    ##    ##

//=======================================================================
//function : SetMessenger
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::SetMessenger (const Handle(Message_Messenger)& messenger)
{
  if ( messenger.IsNull() )
    themessenger = Message::DefaultMessenger();
  else   
    themessenger = messenger;
}

//=======================================================================
//function : Messenger
//purpose  : 
//=======================================================================

Handle(Message_Messenger) Transfer_TransferProcess::Messenger () const
{
  return themessenger;
}

//=======================================================================
//function : SetTraceLevel
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::SetTraceLevel (const Standard_Integer tracelev)
{
  thetrace = tracelev;
}

//=======================================================================
//function : TraceLevel
//purpose  : 
//=======================================================================

Standard_Integer Transfer_TransferProcess::TraceLevel () const
{
  return thetrace;
}

//=======================================================================
//function : SendFail
//purpose  : 
//=======================================================================

void  Transfer_TransferProcess::SendFail(const TheStart& start,
					 const Message_Msg& amsg)
{
  AddFail(start,amsg);
}


//=======================================================================
//function : SendWarning
//purpose  : 
//=======================================================================

void  Transfer_TransferProcess::SendWarning(const TheStart& start,
					    const Message_Msg& amsg)
{
  AddWarning(start,amsg);
}


//=======================================================================
//function : SendMsg
//purpose  : 
//=======================================================================

void  Transfer_TransferProcess::SendMsg(const TheStart& start,
					const Message_Msg& amsg)
{
  Handle(Transfer_Binder) binder = FindAndMask(start);
  if (binder.IsNull()) {
    binder = new Transfer_VoidBinder;
    Bind (start,binder);
  }
  // Alimente la trace : Regle causant (user messages)
  if (thetrace > 0) {
    StartTrace (binder,start,thelevel,6);
    themessenger << amsg.Value();
    if (amsg.IsEdited()&&thetrace>2)
      themessenger << " [from: " << amsg.Original() << "]";
    themessenger << endl;
  }
}


//=======================================================================
//function : AddFail
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::AddFail(const TheStart& start,
				       const Standard_CString mess,
				       const Standard_CString orig)
{
  Handle(Transfer_Binder) binder = FindAndMask(start);
  if (binder.IsNull()) {
    binder = new Transfer_VoidBinder;
    Bind (start,binder);
  }
  binder->AddFail (mess,orig);
  if (thetrace > 0) {
    StartTrace (binder,start,thelevel,1);
    themessenger << "    --> Fail : " << mess;
    if (orig[0] != '\0'&&thetrace>2) themessenger << " [from: " << orig << "]";
    themessenger << endl;
  }
}


//=======================================================================
//function : AddError
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::AddError(const TheStart& start,
					const Standard_CString mess,
					const Standard_CString orig)
{
  AddFail (start,mess,orig);
}


//=======================================================================
//function : AddFail
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::AddFail(const TheStart& start,
				       const Message_Msg& amsg)
{
  if (amsg.IsEdited()) AddFail (start,TCollection_AsciiString(amsg.Value()).ToCString(),
				TCollection_AsciiString(amsg.Original()).ToCString());
  else AddFail (start,TCollection_AsciiString(amsg.Value()).ToCString());
}


//=======================================================================
//function : AddWarning
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::AddWarning(const TheStart& start,
					  const Standard_CString mess,
					  const Standard_CString orig)
{
  Handle(Transfer_Binder) binder = FindAndMask(start);
  if (binder.IsNull()) {
    binder = new Transfer_VoidBinder;
    Bind (start,binder);
  }
  binder->AddWarning(mess,orig);
  if (thetrace > 1) {
    StartTrace (binder,start,thelevel,2);
    themessenger << "    --> Warning : " << mess;
    if (orig[0] != '\0'&&thetrace>2) themessenger << " [from: " << orig << "]";
    themessenger << endl;
  }
}


//=======================================================================
//function : AddWarning
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::AddWarning(const TheStart& start,
					  const Message_Msg& amsg)
{
  if (amsg.IsEdited()) AddWarning (start,TCollection_AsciiString(amsg.Value()).ToCString(),
				   TCollection_AsciiString(amsg.Original()).ToCString());
  else AddWarning (start,TCollection_AsciiString(amsg.Value()).ToCString());
}


//=======================================================================
//function : Mend
//purpose  : 
//=======================================================================

void  Transfer_TransferProcess::Mend(const TheStart& start,
				     const Standard_CString pref)
{
  Handle(Transfer_Binder) binder = FindAndMask(start);
  if (binder.IsNull()) return;  // rien a faire ...
  Handle(Interface_Check) ach =  binder->CCheck();
  ach->Mend (pref);
}


//=======================================================================
//function : Check
//purpose  : 
//=======================================================================

Handle(Interface_Check) Transfer_TransferProcess::Check(const TheStart& start) const
{
  const Handle(Transfer_Binder)& binder = Find(start);
  if (binder.IsNull()) {
    Handle(Interface_Check) check;
    return check;
  }
  return binder->Check();
}

/*skl
void Transfer_TransferProcess::AddCaseName(const TheStart& start,
					   const Standard_CString casename)
{
  AddCaseValue (start, new TCollection_HAsciiString (casename));
}


void Transfer_TransferProcess::AddCaseValue(const TheStart& start,
					    const Handle(Standard_Transient)& caseval)
{
  Handle(Transfer_Binder) binder = FindAndMask(start);
  if (binder.IsNull()) {
    binder = new Transfer_VoidBinder;
    Bind (start,binder);
  }
  binder->AddCaseValue (caseval);
}


Handle(TColStd_HSequenceOfTransient) Transfer_TransferProcess::CaseList
       (const TheStart& start) const
{
  Handle(TColStd_HSequenceOfTransient) list;
  const Handle(Transfer_Binder)& binder = Find(start);
  if (binder.IsNull()) return list;
  return binder->CaseList();
}

Standard_Integer Transfer_TransferProcess::NextItemWithAttribute
  (const Standard_CString name, const Standard_Integer num0) const
{
  Standard_Integer num, nb = NbMapped();
  for (num = num0+1; num <= nb; num ++) {
    Handle(Transfer_Binder) bnd = MapItem (num);
    if (bnd.IsNull()) continue;
    if (!bnd->Attribute(name).IsNull()) return num;
  }
  return 0;
}


Interface_ParamType Transfer_TransferProcess::AttributeType
  (const Standard_CString name) const
{
  Interface_ParamType aty, res = Interface_ParamVoid;
  Standard_Integer num, nb = NbMapped();
  for (num = 1; num <= nb; num ++) {
    Handle(Transfer_Binder) bnd = MapItem (num);
    if (bnd.IsNull()) continue;
    aty = bnd->AttributeType(name);
    if (aty == Interface_ParamVoid) continue;
    if (res == Interface_ParamVoid) res = aty;
    else if (res != aty) return Interface_ParamMisc;
  }
  return res;
}

Handle(Dico_DictionaryOfInteger) Transfer_TransferProcess::Attributes
  (const Standard_CString rootname) const
{
  Handle(Dico_DictionaryOfInteger) list = new Dico_DictionaryOfInteger;
  Standard_Integer num, nb = NbMapped();
  for (num = 1; num <= nb; num ++) {
    Handle(Transfer_Binder) bnd = MapItem (num);
    if (bnd.IsNull()) continue;
    Handle(Dico_DictionaryOfTransient) atr = bnd->AttrList();
    if (atr.IsNull()) continue;
    Dico_IteratorOfDictionaryOfTransient iatr(atr,rootname);
    for (; iatr.More(); iatr.Next()) {
      TCollection_AsciiString name = iatr.Name();
      Standard_Boolean deja;
      Standard_Integer& nbval = list->NewItem (name.ToCString(),deja);
      if (!deja) nbval = 0;
      nbval ++;
    }

  }
  return list;
}
skl*/


//  ##    ##    ##        Actions sur Types Privilegies        ##    ##    ##
//  ##    ##    ##          (Transient)                        ##    ##    ##

// Bind associe un objet a un objet resultat; or la Map associe un Objet a un
// Binder (qui designe son resultat)
//  *Transient  travaillent avec un SimpleBinderOfTransient
// si  deja la, on considere son resultat
// sinon, on cree un Binder du bon type


//=======================================================================
//function : BindTransient
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::BindTransient(const TheStart& start,
					     const Handle(Standard_Transient)& res)
//					     const Standard_Integer categ)
{
  if (res.IsNull()) return;
  Handle(Transfer_Binder) former = Find(start);//,categ);skl
  Handle(Transfer_SimpleBinderOfTransient) binder =
    Handle(Transfer_SimpleBinderOfTransient)::DownCast(former);
//      Binding sur place ?
  if (!binder.IsNull()) {
    if (binder->Status() == Transfer_StatusVoid) { binder->SetResult(res); return; }
  }
//      Sinon, refaire
  binder = new Transfer_SimpleBinderOfTransient;
  binder->SetResult (res);
  if (former.IsNull()) Bind(start,binder);//,categ);skl
  else Rebind(start,binder);//,categ);skl
}


//=======================================================================
//function : FindTransient
//purpose  : 
//=======================================================================

const Handle(Standard_Transient)& Transfer_TransferProcess::FindTransient
       (const TheStart& start) const
{
  Handle(Transfer_SimpleBinderOfTransient) binder =
    Handle(Transfer_SimpleBinderOfTransient)::DownCast(Find(start));
  if (binder.IsNull()) return nultrans;
  if (!binder->HasResult()) return nultrans;
  return binder->Result();
}


//  Binding Multiple : D abord le declarer par BindMultiple (si pas deja fait)
//  Puis ajouter les termes par AddMultiple

//=======================================================================
//function : BindMultiple
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::BindMultiple(const TheStart& start)
//					    const Standard_Integer categ)
{
  Handle(Transfer_Binder) binder = FindAndMask (start);//,categ);skl
  if (!binder.IsNull()) {
    if (!binder->IsKind(STANDARD_TYPE(Transfer_MultipleBinder))) {
      StartTrace (thelastbnd,start,thelevel,4);
      Transfer_TransferFailure::Raise ("TransferProcess : BindMultiple");
    }
  }
  else Bind(start,new Transfer_MultipleBinder);//,categ);skl
}


//=======================================================================
//function : AddMultiple
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::AddMultiple(const TheStart& start,
					   const Handle(Standard_Transient)& res)
//					   const Standard_Integer categ)
{
  Handle(Transfer_Binder) binder = FindAndMask(start);//,categ);skl
  Handle(Transfer_MultipleBinder) multr =
    Handle(Transfer_MultipleBinder)::DownCast(binder);
  if (multr.IsNull()) {
    StartTrace (binder,start,thelevel,4);
    if (binder.IsNull()) Transfer_TransferFailure::Raise
      ("TransferProcess : AddMultiple, nothing bound");
    else                 Transfer_TransferFailure::Raise
      ("TransferProcess : AddMultiple, Binder not a MultipleBinder");
  }
  multr->AddResult(res);
}


//=======================================================================
//function : FindTypedTransient
//purpose  : 
//=======================================================================

Standard_Boolean Transfer_TransferProcess::FindTypedTransient
  (const TheStart& start, const Handle(Standard_Type)& atype,
   Handle(Standard_Transient)& val) const
{
  return GetTypedTransient (Find(start),atype,val);
}


//=======================================================================
//function : GetTypedTransient
//purpose  : 
//=======================================================================

Standard_Boolean  Transfer_TransferProcess::GetTypedTransient
  (const Handle(Transfer_Binder)& binder, const Handle(Standard_Type)& atype,
   Handle(Standard_Transient)& val) const
{
  return Transfer_SimpleBinderOfTransient::GetTypedResult(binder,atype,val);
}


//  ##    ##    ##    ##    ##    Acces Atomique    ##    ##    ##    ##    ##
//    (ne gere pas le scope mais donne acces aux categories)

//=======================================================================
//function : NbMapped
//purpose  : 
//=======================================================================

Standard_Integer  Transfer_TransferProcess::NbMapped () const
{
  return themap.Extent();
}


//=======================================================================
//function : Mapped
//purpose  : 
//=======================================================================

const TheStart& Transfer_TransferProcess::Mapped(const Standard_Integer num) const
{
  return themap.FindKey(num);
}


//=======================================================================
//function : MapIndex
//purpose  : 
//=======================================================================

Standard_Integer Transfer_TransferProcess::MapIndex(const TheStart& start) const
{
  return themap.FindIndex(start);
}


//=======================================================================
//function : MapItem
//purpose  : 
//=======================================================================

Handle(Transfer_Binder) Transfer_TransferProcess::MapItem(const Standard_Integer num) const
//							  const Standard_Integer categ) const
{
  Handle(Transfer_Binder) binder = themap.FindFromIndex(num);
  //sklif (binder.IsNull())
  return binder;
  //sklreturn binder->Search (categ);
}


//  ########################################################################
//  ....                         ROOT MANAGEMENT                        ....

//=======================================================================
//function : SetRoot
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::SetRoot (const TheStart& start)
{
  Standard_Integer index = MapIndex(start);
  if (index == 0) {
    //StartTrace (thelastbnd,start,thelevel,4);
    //Transfer_TransferFailure::Raise("TransferProcess : SetRoot");
    return;
  }

  theroots.Add(index);
  if (thetrace > 2) StartTrace (MapItem(index),start,thelevel,3);
}


//=======================================================================
//function : SetRootManagement
//purpose  : 
//=======================================================================

void  Transfer_TransferProcess::SetRootManagement(const Standard_Boolean stat)
{
  therootm = stat;
}


//=======================================================================
//function : NbRoots
//purpose  : 
//=======================================================================

Standard_Integer  Transfer_TransferProcess::NbRoots () const
{
  return theroots.Extent();
}


//=======================================================================
//function : Root
//purpose  : 
//=======================================================================

const TheStart&  Transfer_TransferProcess::Root(const Standard_Integer num) const
{
  Standard_Integer ind = 0;
  if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num);
  return themap.FindKey (ind);
}


//=======================================================================
//function : RootItem
//purpose  : 
//=======================================================================

Handle(Transfer_Binder) Transfer_TransferProcess::RootItem(const Standard_Integer num) const
//							   const Standard_Integer categ) const
{
  Standard_Integer ind = 0;
  if (num > 0 && num <= theroots.Extent()) ind = theroots.FindKey(num);
  return themap.FindFromIndex(ind);//->Search(categ);skl
}


//=======================================================================
//function : RootIndex
//purpose  : 
//=======================================================================

Standard_Integer  Transfer_TransferProcess::RootIndex(const TheStart& start) const
{
  Standard_Integer index = MapIndex(start);
  if (index == 0) return 0;
  return theroots.FindIndex(index);
}


//=======================================================================
//function : NestingLevel
//purpose  : 
//=======================================================================

Standard_Integer  Transfer_TransferProcess::NestingLevel () const
{
  return thelevel;
}


//=======================================================================
//function : ResetNestingLevel
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::ResetNestingLevel ()
{
  thelevel = 0;
}


//  ########################################################################
//  ....                        SCOPE MANAGEMENT                        ....


//======================================================================
//Purpose : gka TRJ9 for writing SDR for solid
//          Check if binder has already been bound to the result binder.
//======================================================================

// static Standard_Boolean Contains(const Handle(Transfer_Binder)& resbinder, 
// 				 const Handle(Transfer_Binder)& addbinder)
// {
//   Handle(Transfer_Binder) tmpbind = resbinder;
//   for ( ; ! tmpbind.IsNull(); tmpbind = tmpbind->NextResult() )
//     if ( tmpbind == addbinder ) return Standard_True;
//   return Standard_False;
// }

//  ########################################################################
//  ....                    AUTOMATISMES DE TRANSFERT                   ....

//  ##    ##    ##    ##    ##  Fonctions de Base  ##    ##    ##    ##    ##


//=======================================================================
//function : Recognize
//purpose  : 
//=======================================================================

Standard_Boolean  Transfer_TransferProcess::Recognize(const TheStart& start) const
{
  Handle(Transfer_Actor) actor = theactor;
  //   On balaie les Next jusqu a avoir un Resultat
  while (!actor.IsNull()) {
    if (actor->Recognize (start)) return Standard_True;
    actor = actor->Next();
  }
  return Standard_False;
}


//=======================================================================
//function : Transferring
//purpose  : 
//=======================================================================

Handle(Transfer_Binder) Transfer_TransferProcess::Transferring(const TheStart& start)
{
  //   Map deja alimentee ?
  Handle(Transfer_Binder) former = FindAndMask(start);

  //  ....    Transfert deja effectue avec Resultat ?    ....

  //  On considere que cette nouvelle demande de Transfert correspond donc a une
  //  utilisation en plus : noter "AlreadyUsed", donc resultat non modifiable
  if (!former.IsNull()) {
    if (former->HasResult()) {
      former->SetAlreadyUsed();
      return former;
    }
  //}

    //  ....    Etat Initial : peut-etre deja fait ... ou infaisable !

  //if (!former.IsNull()) {
    Transfer_StatusExec statex = former->StatusExec();
    switch (statex) {
      case Transfer_StatusInitial :               // Transfert prepare a faire
	break;
      case Transfer_StatusDone :                  // Transfert deja fait
//#ifdef TRANSLOG
	themessenger << " .. and Transfer done" << endl;
//#endif
//	if (former->HasResult()) former->SetAlreadyUsed();
	return former;
      case Transfer_StatusRun :                   // ca y est, on boucle
	former->SetStatusExec(Transfer_StatusLoop);
	return former;
      case Transfer_StatusError :                 // pas propre, ca ...
	if (thetrace) {
	  themessenger << "                  *** Transfer in Error Status  :" << endl;
	  StartTrace (former, start, thelevel,0);
//	  (*themessenger->Out()) << flush;
	}
	else StartTrace (former, start,thelevel,4);
	Transfer_TransferFailure::Raise
	  ("TransferProcess : Transfer in Error Status");
      case Transfer_StatusLoop :                  // la boucle est bouclee ...
	if (thetrace) {
	  themessenger << "                  *** Transfer  Head of Dead Loop  :" << endl;
	  StartTrace (former, start, thelevel,0);
//	  (*themessenger->Out()) << flush;
	}
	else StartTrace (former, start,thelevel,4);
	Transfer_TransferDeadLoop::Raise
	  ("TransferProcess : Transfer at Head of a Dead Loop");
    }
#ifdef TRANSLOG
    cout << "Transfer,level "<<thelevel<<Message_Flush;
#endif
  //}

  //  ....    OK, on peut lancer l Execution
  //if (!former.IsNull()) 
    former->SetStatusExec(Transfer_StatusRun);
  }
#ifdef TRANSLOG
  cout << " GO .." << endl;
#endif

  Handle(Transfer_Binder) binder;
  Standard_Boolean newbind = Standard_False;
  if (theerrh) {
    //   Transfert sous protection pour les exceptions (pour notification en fait)
    Standard_Integer oldlev = thelevel;
    try {
      OCC_CATCH_SIGNALS
      binder = TransferProduct(start);
    }

    //    ...  Exceptions a Rattraper : elles ne se ressemblent pas toutes ... !
    catch (Transfer_TransferDeadLoop) {
      if (binder.IsNull()) {
	themessenger << "                  *** Dead Loop with no Result" << endl;
	if (thetrace) StartTrace (binder, start, thelevel-1,0);
	binder = new Transfer_VoidBinder;
	Bind (start,binder);  newbind = Standard_True;
      } else if (binder->StatusExec() == Transfer_StatusLoop) {
	if (thetrace) {
	  themessenger << "                  *** Dead Loop : Finding head of Loop :" << endl;
	  StartTrace (binder, start, thelevel-1,0);
	}
	else StartTrace (binder, start,thelevel-1,4);
	Transfer_TransferFailure::Raise("TransferProcess : Head of Dead Loop");
// Autrement dit, on change d exception (on est sorti de la boucle)
      } else {
	if (thetrace) {
	  themessenger << "                  *** Dead Loop : Actor in Loop :" << endl;
	  StartTrace (binder, start, thelevel-1,0);
	}
      }
      binder->AddFail("Transfer in dead Loop");
      thelevel = oldlev;
    }
    catch (Standard_Failure) {
      if (binder.IsNull()) {
	themessenger << "                  *** Exception Raised with no Result" << endl;
	binder = new Transfer_VoidBinder;
	Bind (start,binder);  newbind = Standard_True;
      }
      binder->AddFail("Transfer stopped by exception raising");
      if (thetrace) {
	themessenger << "    *** Raised : " << Standard_Failure::Caught()->GetMessageString() << endl;
	StartTrace (binder, start, thelevel-1,4);
      }
      thelevel = oldlev;
    }
  }

//   Transfert non protege (ainsi, dbx a la main en cas de plantage par Raise)
  else  binder = TransferProduct(start);

//  ....                Conclusion : Noter dans la Map                ....

  if (!newbind && !binder.IsNull()) {
    if (former.IsNull()) {
//    Peut-etre <theactor> a fait lui meme Bind ... verifier sinon le faire
      if (!IsBound(start)) Bind(start,binder);     // resultat = categorie 0
      else {                                       // gka TRJ9 for writing SDR for solid
// 	Handle(Transfer_Binder) tmpbind = Find(start);
// 	if(!Contains(binder,tmpbind))
// 	   binder->AddResult(tmpbind);
 	Rebind(start,binder); // test_pattern.sat
      }
    }
    else Rebind(start,binder);
//  (du coup, <thelastbnd> vaut <binder>)
#ifdef TRANSLOG
    cout << " ... OK" << endl;
#endif
  }
  else {
    //= by ABV: 5 Oct 97: nothing generated, but former can be in run state - drop it
    //= ASK: may be set it to StatusInitial ?
    if ( ! former.IsNull() ) former->SetStatusExec ( Transfer_StatusDone ); //+
    return nulbinder;    // Binder Null ... que faire d autre ?
  }

//  ....                Gerer les Racines (si prevu)                ....

  if (therootl >= thelevel) {
    therootl = 0;
    if (therootm && binder->Status() != Transfer_StatusVoid) {
      SetRoot (start);
    }
  }
  return thelastbnd;
}

//  ##    ##        TransferProduct : Action proprement dite        ##    ##

    Handle(Transfer_Binder) Transfer_TransferProcess::TransferProduct
  (const TheStart& start)
{
  thelevel ++;             // si decremente et == 0, transfert racine
  Handle(Transfer_Binder) binder;
  Handle(Transfer_Actor) actor = theactor;

//   On balaie les Next jusqu a avoir un Resultat
  while (!actor.IsNull()) {
    if (actor->Recognize (start)) binder = actor->Transferring(start,this);
    else binder.Nullify();
    if (!binder.IsNull()) break;
    actor = actor->Next();
  }
  if (binder.IsNull()) {
//    if (thetrace) {
//      themessenger << "Transfer has produced no Result" <<endl;
//      StartTrace (binder, start, thelevel-1,0); sout << flush;
//    }
    if (thelevel > 0) thelevel --;
    return binder;
  }
//      Gestion du niveau racine (.. a regarder de pres ..)
  if (therootl == 0 && binder->StatusExec() == Transfer_StatusDone)
    therootl = thelevel - 1;

  if (thelevel > 0) thelevel --;
  return binder;
}


//=======================================================================
//function : Transfer
//purpose  : 
//=======================================================================

Standard_Boolean  Transfer_TransferProcess::Transfer(const TheStart& start)
{
  Handle(Transfer_Binder) binder = Transferring(start);
  return (!binder.IsNull());
}


//  #########################################################################
//  ....                      Error Handling + Trace                     ....

//  trace : 1 pour Fail et Exception , 2 pour Root et Warning


//=======================================================================
//function : SetErrorHandle
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::SetErrorHandle(const Standard_Boolean err)
{
  theerrh = err;
}    // traite par Transferring


//=======================================================================
//function : ErrorHandle
//purpose  : 
//=======================================================================

Standard_Boolean  Transfer_TransferProcess::ErrorHandle() const
{
  return theerrh;
}

//=======================================================================
//function : StartTrace
//purpose  : 
//=======================================================================

void Transfer_TransferProcess::StartTrace(const Handle(Transfer_Binder)& binder,
					  const TheStart& start,
					  const Standard_Integer level,
					  const Standard_Integer mode) const 
{
  // ###  Fail (Roots:50)  --  Start start->DynamicType()
  // ###  Fail (Roots:50)  --  Start id:#label.. Type:start->DynamicType()
  if (thetrace > 3) {  // Internal to be switch when searching bug (trace >= 4)
    if (mode == 1) themessenger << "  ###  Fail";
    if (mode == 2) themessenger << "  ###  Warning";
    if (mode == 3) themessenger << "  ###  New Root n0 " << theroots.Extent();
    if (mode == 4) themessenger << "  ###  Exception";
    if (mode == 5) themessenger << "  ###  Substitution";
    if (mode == 6) themessenger << "  ###  Information";
    if (level > 1)
      themessenger << " (nested)";  // " at nesting Level:"<<level;
    if (mode >= 0 && mode != 3)
      themessenger << " at " << theroots.Extent() << " Roots";
  }
  if (!start.IsNull()) PrintTrace (start,themessenger);
////  sout << endl;

  if (!binder.IsNull()) {   // old: if IsNull sout <<endl<< "  ---  Not Bound";
    Handle(Transfer_Binder) bnd = binder;
    Standard_Boolean hasres = Standard_False;
    while (!bnd.IsNull()) {
      if (bnd->Status() != Transfer_StatusVoid) {
// ---  Result Type: binder->ResultType()  ---  Binder : binder->DynamicType();
	if (!hasres)
	  themessenger << "\n  ---  Result Type : ";
	else 
	  themessenger << " , ";
	themessenger << bnd->ResultTypeName();
//  CKY 9-JAN-1999:  waiting for XSTEP Kernel message (not IGES_2075)
/*        Message_Msg Msg2075("IGES_2075");
          Msg2075.AddString(bnd->ResultTypeName());
          Msg2075.TraceEver();  */
	hasres = Standard_True;
      }
      bnd = bnd->NextResult();
    }
    if (!hasres && mode > 2) {
      themessenger << "\n  ---  No Result recorded";
//  CKY 9-JAN-1999 : waiting for XSTEP Kernel message
//     (not IGES_2075, no reference to specifically TopoDS_Shape)
/*       Message_Msg Msg2075("IGES_2075");
         Msg2075.AddString("No TopoDS_Shape");
         Msg2075.TraceEver();  */
    }
//old    if (isused) sout << "  --    (Already Used in another Transfer)";
  }
  themessenger << endl;
}


//=======================================================================
//function : PrintTrace
//purpose  : 
//=======================================================================

void  Transfer_TransferProcess::PrintTrace(const TheStart& start,
					   const Handle(Message_Messenger)& S) const
{
  if (!start.IsNull())   S <<" Type:" << start->DynamicType()->Name();
}


//=======================================================================
//function : IsLooping
//purpose  : 
//=======================================================================

Standard_Boolean  Transfer_TransferProcess::IsLooping
  (const Standard_Integer alevel) const 
      {  return alevel > NbMapped();  }



//  #########################################################################
//  ....                            RESULTATS                            ....


//  ##    ##        RootResult : Les Racines        ##    ##


//=======================================================================
//function : RootResult
//purpose  : 
//=======================================================================

Transfer_Iterator Transfer_TransferProcess::RootResult(const Standard_Boolean withstart) const
{
  Transfer_Iterator iter(withstart);
  Standard_Integer max = theroots.Extent();
  for (Standard_Integer j = 1; j <= max; j ++) {
    Standard_Integer i = theroots.FindKey(j);
    Handle(Transfer_Binder) binder = MapItem(i);
    if (binder.IsNull()) continue;
    if (withstart) iter.Add (binder,Mapped(i));
    else iter.Add (binder);
  }
  return iter;
}


//  ##    ##        CompleteResult : Tous les Resultats        ##    ##

//=======================================================================
//function : CompleteResult
//purpose  : 
//=======================================================================

Transfer_Iterator Transfer_TransferProcess::CompleteResult
  (const Standard_Boolean withstart) const
{
  Transfer_Iterator iter(withstart);
  Standard_Integer max = NbMapped();
  for (Standard_Integer i = 1; i <= max; i ++) {
    Handle(Transfer_Binder) binder = MapItem(i);
    if (binder.IsNull()) continue;
    if (withstart) iter.Add (binder,Mapped(i));
    else iter.Add (binder);
  }
  return iter;
}


//  ##    ##        AbnormalResult : Transferts a probleme        ##    ##
//=======================================================================
//function : AbnormalResult
//purpose  : 
//=======================================================================

Transfer_Iterator Transfer_TransferProcess::AbnormalResult() const
{
  Transfer_Iterator iter(Standard_True);
  Standard_Integer max = NbMapped();
  for (Standard_Integer i = 1; i <= max; i ++) {
    Handle(Transfer_Binder) binder = MapItem(i);
    if (binder.IsNull()) continue;
    Transfer_StatusExec statex = binder->StatusExec();
    if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone)
      iter.Add (binder,Mapped(i));  // on note les cas "pas normaux"
  }
  return iter;
}


//  ##    ##    ##         CheckList : les messages         ##    ##    ##
//=======================================================================
//function : CheckList
//purpose  : 
//=======================================================================

Interface_CheckIterator  Transfer_TransferProcess::CheckList
  (const Standard_Boolean erronly) const
{
  Interface_CheckIterator list;
  Standard_Integer num, max = NbMapped();
  for (Standard_Integer i = 1; i <= max; i ++) {
    Handle(Transfer_Binder) binder = MapItem(i);
    if (binder.IsNull()) continue;
    Transfer_StatusExec statex = binder->StatusExec();
    Handle(Interface_Check) check = binder->Check();
    if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone &&
	!check->HasFailed())
      check->AddFail("Transfer in Abnormal Status (!= Initial or Done)");
    if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue;
    const TheStart& ent = Mapped(i);
    num = CheckNum(ent);
    if (num == 0) num = i;
    check->SetEntity(ent);
    list.Add(check,num);
  }
  return list;
}


//  #########################################################################
//  ....                       RESULTATS PAR ENTITE                      ....

//=======================================================================
//function : ResultOne
//purpose  : 
//=======================================================================

Transfer_Iterator Transfer_TransferProcess::ResultOne(const TheStart& start,
						      const Standard_Integer level,
						      const Standard_Boolean withstart) const
{
  Transfer_Iterator iter(withstart);
  Standard_Integer max = NbMapped();
  Standard_Integer ind = MapIndex (start);
  if (ind == 0) return iter;
  Standard_Integer i1 = (level == 0 ? ind : 1);
  Standard_Integer i2 = (level == 0 ? ind : max);
  Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
  //MarkScoped (ind,level,map);

  for (Standard_Integer i = i1; i <= i2; i ++) {
    ind = map->Value(i);
    if (ind == 0) continue;
    Handle(Transfer_Binder) binder = MapItem(i);
    if (binder.IsNull()) continue;
    if (withstart) iter.Add (binder,Mapped(ind));
    else iter.Add (binder);
  }
  return iter;
}


//=======================================================================
//function : CheckListOne
//purpose  : 
//=======================================================================

Interface_CheckIterator  Transfer_TransferProcess::CheckListOne
  (const TheStart& start,const Standard_Integer level,
   const Standard_Boolean erronly) const
{
  Interface_CheckIterator list;
  Standard_Integer max = NbMapped();
  Standard_Integer num, ind = MapIndex (start);
  if (ind == 0) return list;
  Standard_Integer i1 = (level == 0 ? ind : 1);
  Standard_Integer i2 = (level == 0 ? ind : max);
  Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
  //MarkScoped (ind,level,map);

  for (Standard_Integer i = i1; i <= i2; i ++) {
    ind = map->Value(i);
    if (ind == 0) continue;
    Handle(Transfer_Binder) binder = MapItem(ind);
    if (binder.IsNull()) continue;
    Transfer_StatusExec statex = binder->StatusExec();
    Handle(Interface_Check) check = binder->Check();
    if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone &&
	!check->HasFailed())
      check->AddFail("Transfer in Abnormal Status (!= Initial or Done)");
    if (!check->HasFailed() && (erronly || check->NbWarnings() == 0)) continue;
    const TheStart& ent = Mapped(ind);
    num = CheckNum(ent);  if (num == 0) num = ind;
    check->SetEntity(ent);
    list.Add(check,num);
  }
  return list;
}


//=======================================================================
//function : IsCheckListEmpty
//purpose  : 
//=======================================================================

Standard_Boolean  Transfer_TransferProcess::IsCheckListEmpty
  (const TheStart& start, const Standard_Integer level,
   const Standard_Boolean erronly) const
{
  Standard_Integer max = NbMapped();
  Standard_Integer ind = MapIndex (start);
  if (ind == 0) return Standard_False;
  Standard_Integer i1 = (level == 0 ? ind : 1);
  Standard_Integer i2 = (level == 0 ? ind : max);
  Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
//  MarkScoped (ind,level,map);

  for (Standard_Integer i = i1; i <= i2; i ++) {
    ind = map->Value(i);
    if (ind == 0) continue;
    Handle(Transfer_Binder) binder = MapItem(ind);
    if (binder.IsNull()) continue;

    Transfer_StatusExec statex = binder->StatusExec();
    Handle(Interface_Check) check = binder->Check();
    if (statex != Transfer_StatusInitial && statex != Transfer_StatusDone)
      return Standard_False;
    if (check->HasFailed() || (!erronly && check->NbWarnings() > 0)) return Standard_False;
  }
  return Standard_True;
}


//=======================================================================
//function : RemoveResult
//purpose  : 
//=======================================================================

void  Transfer_TransferProcess::RemoveResult(const TheStart& start,
					     const Standard_Integer level,
					     const Standard_Boolean /*compute*/)
{
  //if (compute) ComputeScopes();
  Standard_Integer max = NbMapped();
  Standard_Integer ind = MapIndex (start);
  if (ind == 0) return;
  Standard_Integer i1 = (level == 0 ? ind : 1);
  Standard_Integer i2 = (level == 0 ? ind : max);
  Handle(TColStd_HArray1OfInteger) map = new TColStd_HArray1OfInteger (i1,i2,0);
//  MarkScoped (ind,level,map);

  Standard_Integer i; // svv Jan11 2000 : porting on DEC
  for (i = i1; i <= i2; i ++) {
    ind = map->Value(i);
    if (ind == 0) continue;
    Handle(Transfer_Binder) binder = MapItem(ind);
    if (binder.IsNull()) continue;
//    Standard_Boolean cayest = binder->SetNbUserScopes (-1);
//    if (cayest) themap(ind) = nulbinder;    // RAZ !
  }

//pdn commented  for (i = NbRoots(); i > 0; i --)
//    if (theroots.Value(i) == ind) theroots.Remove(i);
}


Standard_Integer  Transfer_TransferProcess::CheckNum(const TheStart& ) const
{
  return 0;
}


//=======================================================================
//function : SetProgress
//purpose  : Sets Progress indicator
//=======================================================================

void Transfer_TransferProcess::SetProgress(const Handle(Message_ProgressIndicator)& theProgress)
{
  myProgress = theProgress;
}

//=======================================================================
//function : GetProgress
//purpose  : Returns Progress indicator
//=======================================================================

Handle(Message_ProgressIndicator) Transfer_TransferProcess::GetProgress() const
{
  return myProgress;
}