0026937: Eliminate NO_CXX_EXCEPTION macro support
[occt.git] / src / Transfer / Transfer_TransferInput.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Interface_EntityIterator.hxx>
16 #include <Interface_InterfaceModel.hxx>
17 #include <Interface_Macros.hxx>
18 #include <Interface_Protocol.hxx>
19 #include <TColStd_HSequenceOfTransient.hxx>
20 #include <Transfer_Binder.hxx>
21 #include <Transfer_FinderProcess.hxx>
22 #include <Transfer_IteratorOfProcessForFinder.hxx>
23 #include <Transfer_IteratorOfProcessForTransient.hxx>
24 #include <Transfer_MultipleBinder.hxx>
25 #include <Transfer_SimpleBinderOfTransient.hxx>
26 #include <Transfer_TransferFailure.hxx>
27 #include <Transfer_TransferInput.hxx>
28 #include <Transfer_TransferIterator.hxx>
29 #include <Transfer_TransientProcess.hxx>
30 #include <Transfer_VoidBinder.hxx>
31
32 Transfer_TransferInput::Transfer_TransferInput ()    {  }
33
34
35 //  Resultats : Pour le Modele ...
36
37     Interface_EntityIterator  Transfer_TransferInput::Entities
38   (Transfer_TransferIterator& list) const
39 {
40   Interface_EntityIterator iter;
41   for (list.Start(); list.More(); list.Next()) {
42     Handle(Transfer_Binder) binder = list.Value();
43     if (binder.IsNull()) continue;
44     if (binder->IsKind(STANDARD_TYPE(Transfer_VoidBinder))) continue;
45
46 // Vrai resultat : doit etre transient (simple ou liste)
47     DeclareAndCast(Transfer_SimpleBinderOfTransient,transb,binder);
48     DeclareAndCast(Transfer_MultipleBinder,multi,binder);
49     if (!transb.IsNull()) {
50       if (transb->HasResult()) iter.AddItem(transb->Result());
51     }
52     else if (!multi.IsNull()) {
53       Handle(TColStd_HSequenceOfTransient) mulres = multi->MultipleResult();
54       Standard_Integer nbres = 0;
55       if (!mulres.IsNull()) nbres = mulres->Length();
56       for (Standard_Integer i = 1; i <= nbres; i ++)
57         iter.AddItem(mulres->Value(i));
58     }
59     else throw Transfer_TransferFailure("TransferInput : Entities, one of the Results is not Transient Handle");
60   }
61   return iter;
62 }
63
64
65     void Transfer_TransferInput::FillModel
66   (const Handle(Transfer_TransientProcess)& proc,
67    const Handle(Interface_InterfaceModel)& amodel) const
68 {
69   Transfer_TransferIterator list = proc->CompleteResult();
70   Interface_EntityIterator  iter = Entities (list);
71   amodel->GetFromTransfer(iter);
72 }
73
74     void Transfer_TransferInput::FillModel
75   (const Handle(Transfer_TransientProcess)& proc,
76    const Handle(Interface_InterfaceModel)& amodel,
77    const Handle(Interface_Protocol)& proto,
78    const Standard_Boolean roots) const
79 {
80   Transfer_TransferIterator list;
81   if (roots) list = proc->RootResult();
82   else       list = proc->CompleteResult();
83   Interface_EntityIterator  iter = Entities (list);
84   for (iter.Start(); iter.More(); iter.Next())
85     amodel->AddWithRefs (iter.Value(), proto);
86 }
87
88
89     void Transfer_TransferInput::FillModel
90   (const Handle(Transfer_FinderProcess)& proc,
91    const Handle(Interface_InterfaceModel)& amodel) const
92 {
93   Transfer_TransferIterator list = proc->CompleteResult();
94   Interface_EntityIterator  iter = Entities (list);
95   amodel->GetFromTransfer(iter);
96 }
97
98     void Transfer_TransferInput::FillModel
99   (const Handle(Transfer_FinderProcess)& proc,
100    const Handle(Interface_InterfaceModel)& amodel,
101    const Handle(Interface_Protocol)& proto,
102    const Standard_Boolean roots) const
103 {
104   Transfer_TransferIterator list;
105   if (roots) list = proc->RootResult();
106   else       list = proc->CompleteResult();
107   Interface_EntityIterator  iter = Entities (list);
108   for (iter.Start(); iter.More(); iter.Next())
109     amodel->AddWithRefs (iter.Value(), proto);
110 }