1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <Geom2d_CartesianPoint.hxx>
16 #include <Interface_Check.hxx>
17 #include <Interface_IntVal.hxx>
18 #include <Standard_Type.hxx>
19 #include <TCollection_HAsciiString.hxx>
20 #include <Transfer_Binder.hxx>
21 #include <Transfer_TransferFailure.hxx>
22 #include <Transfer_VoidBinder.hxx>
24 IMPLEMENT_STANDARD_RTTIEXT(Transfer_Binder,MMgt_TShared)
26 //=======================================================================
27 //function : Transfer_Binder
29 //=======================================================================
30 Transfer_Binder::Transfer_Binder ()
32 thestatus = Transfer_StatusVoid;
33 theexecst = Transfer_StatusInitial;
34 thecheck = new Interface_Check;
37 //=======================================================================
40 //=======================================================================
42 void Transfer_Binder::Merge (const Handle(Transfer_Binder)& other)
44 if (other.IsNull()) return;
45 if ((int) theexecst < (int) other->StatusExec()) theexecst = other->StatusExec();
46 thecheck->GetMessages (other->Check());
49 //=======================================================================
50 //function : IsMultiple
52 //=======================================================================
54 Standard_Boolean Transfer_Binder::IsMultiple () const
56 if (thenextr.IsNull()) return Standard_False;
57 if (!HasResult()) return thenextr->IsMultiple();
59 Handle(Transfer_Binder) next = thenextr;
60 while (!next.IsNull()) {
61 if (next->HasResult()) return Standard_True;
62 next = next->NextResult();
64 return Standard_False;
67 //=======================================================================
68 //function : AddResult
70 //=======================================================================
72 void Transfer_Binder::AddResult (const Handle(Transfer_Binder)& next)
74 if (next == this || next.IsNull()) return;
75 next->CutResult(this);
76 if (thenextr.IsNull())
79 //Modification of recursive to cycle
80 Handle(Transfer_Binder) theBinder = thenextr;
81 while( theBinder != next ) {
82 if( theBinder->NextResult().IsNull() ) {
83 theBinder->AddResult(next);
87 theBinder = theBinder->NextResult();
91 // if (thenextr.IsNull()) thenextr = next;
92 // else if (thenextr == next) return;
93 // else thenextr->AddResult (next);
96 //=======================================================================
97 //function : CutResult
99 //=======================================================================
101 void Transfer_Binder::CutResult (const Handle(Transfer_Binder)& next)
103 if (thenextr.IsNull()) return;
104 if (thenextr == next) thenextr.Nullify();
105 //else thenextr->CutResult (next);
107 Handle(Transfer_Binder) currBinder = thenextr, currNext;
108 while( !( (currNext = currBinder->NextResult()) == next ) ) {
109 if( currNext.IsNull() )
111 currBinder = currNext;
113 currBinder->CutResult(next);
117 //=======================================================================
118 //function : NextResult
120 //=======================================================================
122 Handle(Transfer_Binder) Transfer_Binder::NextResult () const
126 //=======================================================================
127 //function : SetResultPresent
129 //=======================================================================
131 void Transfer_Binder::SetResultPresent ()
133 if (thestatus == Transfer_StatusUsed) throw Transfer_TransferFailure("Binder : SetResult, Result is Already Set and Used");
134 theexecst = Transfer_StatusDone;
135 thestatus = Transfer_StatusDefined;
138 //=======================================================================
139 //function : HasResult
141 //=======================================================================
143 Standard_Boolean Transfer_Binder::HasResult () const
144 { return (thestatus != Transfer_StatusVoid); }
146 //=======================================================================
147 //function : SetAlreadyUsed
149 //=======================================================================
151 void Transfer_Binder::SetAlreadyUsed ()
152 { if (thestatus != Transfer_StatusVoid) thestatus = Transfer_StatusUsed; }
155 //=======================================================================
158 //=======================================================================
160 Transfer_StatusResult Transfer_Binder::Status () const
161 { return thestatus; }
164 // ############ Checks ############
166 //=======================================================================
167 //function : StatusExec
169 //=======================================================================
171 Transfer_StatusExec Transfer_Binder::StatusExec () const
172 { return theexecst; }
174 //=======================================================================
175 //function : SetStatusExec
177 //=======================================================================
179 void Transfer_Binder::SetStatusExec (const Transfer_StatusExec stat)
180 { theexecst = stat; }
182 //=======================================================================
185 //=======================================================================
187 void Transfer_Binder::AddFail
188 (const Standard_CString mess, const Standard_CString orig)
190 theexecst = Transfer_StatusError;
191 thecheck->AddFail(mess,orig);
194 //=======================================================================
195 //function : AddWarning
197 //=======================================================================
199 void Transfer_Binder::AddWarning
200 (const Standard_CString mess, const Standard_CString orig)
202 // theexecst = Transfer_StatusError;
203 thecheck->AddWarning(mess,orig);
206 //=======================================================================
209 //=======================================================================
211 const Handle(Interface_Check) Transfer_Binder::Check () const
216 //=======================================================================
219 //=======================================================================
221 Handle(Interface_Check) Transfer_Binder::CCheck ()