Warnings on vc14 were eliminated
[occt.git] / src / Transfer / Transfer_Binder.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 <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>
23
24 IMPLEMENT_STANDARD_RTTIEXT(Transfer_Binder,MMgt_TShared)
25
26 //=======================================================================
27 //function : Transfer_Binder
28 //purpose  : 
29 //=======================================================================
30 Transfer_Binder::Transfer_Binder ()
31 {  
32   thestatus = Transfer_StatusVoid; 
33   theexecst = Transfer_StatusInitial;
34   thecheck = new Interface_Check;
35
36
37 //=======================================================================
38 //function : Merge
39 //purpose  : 
40 //=======================================================================
41
42 void Transfer_Binder::Merge (const Handle(Transfer_Binder)& other)
43 {
44   if (other.IsNull()) return;
45   if ((int) theexecst < (int) other->StatusExec()) theexecst = other->StatusExec();
46   thecheck->GetMessages (other->Check());
47 }
48
49 //=======================================================================
50 //function : IsMultiple
51 //purpose  : 
52 //=======================================================================
53
54 Standard_Boolean  Transfer_Binder::IsMultiple () const
55 {
56   if (thenextr.IsNull()) return Standard_False;
57   if (!HasResult()) return thenextr->IsMultiple();
58
59   Handle(Transfer_Binder) next = thenextr;
60   while (!next.IsNull()) {
61     if (next->HasResult()) return Standard_True;
62     next = next->NextResult();
63   }
64   return Standard_False;
65 }
66
67 //=======================================================================
68 //function : AddResult
69 //purpose  : 
70 //=======================================================================
71
72 void  Transfer_Binder::AddResult (const Handle(Transfer_Binder)& next)
73 {
74   if (next == this || next.IsNull()) return;
75   next->CutResult(this);
76   if (thenextr.IsNull()) 
77     thenextr = next;
78   else {
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);
84         return;
85       }
86       else
87         theBinder = theBinder->NextResult();
88     }
89   }
90   //former recursive
91   // if (thenextr.IsNull()) thenextr = next;
92   // else if (thenextr == next) return;
93   // else thenextr->AddResult (next);
94 }
95
96 //=======================================================================
97 //function : CutResult
98 //purpose  : 
99 //=======================================================================
100
101 void  Transfer_Binder::CutResult (const Handle(Transfer_Binder)& next)
102 {
103   if (thenextr.IsNull()) return;
104   if (thenextr == next) thenextr.Nullify();
105   //else thenextr->CutResult (next);
106   else {
107     Handle(Transfer_Binder) currBinder = thenextr, currNext;
108     while( !( (currNext = currBinder->NextResult()) == next ) ) {
109       if( currNext.IsNull() )
110         return;
111       currBinder = currNext;
112     }
113     currBinder->CutResult(next);
114   }
115 }
116
117 //=======================================================================
118 //function : NextResult
119 //purpose  : 
120 //=======================================================================
121
122 Handle(Transfer_Binder)  Transfer_Binder::NextResult () const
123       {  return thenextr;  }
124
125
126 //=======================================================================
127 //function : SetResultPresent
128 //purpose  : 
129 //=======================================================================
130
131 void Transfer_Binder::SetResultPresent ()
132 {
133   if (thestatus == Transfer_StatusUsed) throw Transfer_TransferFailure("Binder : SetResult, Result is Already Set and Used");
134   theexecst = Transfer_StatusDone;
135   thestatus = Transfer_StatusDefined;
136 }
137
138 //=======================================================================
139 //function : HasResult
140 //purpose  : 
141 //=======================================================================
142
143 Standard_Boolean Transfer_Binder::HasResult () const
144       {  return (thestatus != Transfer_StatusVoid);  }
145
146 //=======================================================================
147 //function : SetAlreadyUsed
148 //purpose  : 
149 //=======================================================================
150
151 void Transfer_Binder::SetAlreadyUsed ()
152 {  if (thestatus != Transfer_StatusVoid) thestatus = Transfer_StatusUsed;  }
153
154
155 //=======================================================================
156 //function : Status
157 //purpose  : 
158 //=======================================================================
159
160 Transfer_StatusResult Transfer_Binder::Status () const
161 {  return thestatus;  }
162
163
164 //  ############    Checks    ############
165
166 //=======================================================================
167 //function : StatusExec
168 //purpose  : 
169 //=======================================================================
170
171 Transfer_StatusExec Transfer_Binder::StatusExec () const
172 {  return theexecst;  }
173
174 //=======================================================================
175 //function : SetStatusExec
176 //purpose  : 
177 //=======================================================================
178
179 void Transfer_Binder::SetStatusExec (const Transfer_StatusExec stat)
180 {  theexecst = stat;  }
181
182 //=======================================================================
183 //function : AddFail
184 //purpose  : 
185 //=======================================================================
186
187 void Transfer_Binder::AddFail
188   (const Standard_CString mess, const Standard_CString orig)
189 {
190   theexecst = Transfer_StatusError;
191   thecheck->AddFail(mess,orig);
192 }
193
194 //=======================================================================
195 //function : AddWarning
196 //purpose  : 
197 //=======================================================================
198
199 void Transfer_Binder::AddWarning
200   (const Standard_CString mess, const Standard_CString orig)
201 {
202 //  theexecst = Transfer_StatusError;
203   thecheck->AddWarning(mess,orig);
204 }
205
206 //=======================================================================
207 //function : Check
208 //purpose  : 
209 //=======================================================================
210
211 const Handle(Interface_Check) Transfer_Binder::Check () const
212 {
213   return thecheck;
214 }
215
216 //=======================================================================
217 //function : CCheck
218 //purpose  : 
219 //=======================================================================
220
221 Handle(Interface_Check) Transfer_Binder::CCheck ()
222 {
223   return thecheck;
224 }
225