summaryrefslogtreecommitdiff
path: root/src/Transfer/Transfer_Binder.cxx
blob: c37f9aae38b6b82a5950f9fddced02f7b377d66f (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
#include <Transfer_Binder.ixx>
#include <Transfer_VoidBinder.hxx>
#include <Transfer_TransferFailure.hxx>

#include <TCollection_HAsciiString.hxx>
#include <Interface_IntVal.hxx>
#include <Geom2d_CartesianPoint.hxx>


//=======================================================================
//function : Transfer_Binder
//purpose  : 
//=======================================================================

Transfer_Binder::Transfer_Binder ()
{  
  thestatus = Transfer_StatusVoid; 
  theexecst = Transfer_StatusInitial;
  thecheck = new Interface_Check;
} 

//=======================================================================
//function : Merge
//purpose  : 
//=======================================================================

void Transfer_Binder::Merge (const Handle(Transfer_Binder)& other)
{
  if (other.IsNull()) return;
  if ((int) theexecst < (int) other->StatusExec()) theexecst = other->StatusExec();
  thecheck->GetMessages (other->Check());
}

//=======================================================================
//function : IsMultiple
//purpose  : 
//=======================================================================

Standard_Boolean  Transfer_Binder::IsMultiple () const
{
  if (thenextr.IsNull()) return Standard_False;
  if (!HasResult()) return thenextr->IsMultiple();

  Handle(Transfer_Binder) next = thenextr;
  while (!next.IsNull()) {
    if (next->HasResult()) return Standard_True;
    next = next->NextResult();
  }
  return Standard_False;
}

//=======================================================================
//function : AddResult
//purpose  : 
//=======================================================================

void  Transfer_Binder::AddResult (const Handle(Transfer_Binder)& next)
{
  if (next == this || next.IsNull()) return;
  next->CutResult(this);
  if (thenextr.IsNull()) 
    thenextr = next;
  else {
    //Modification of recursive to cycle
    Handle(Transfer_Binder) theBinder = thenextr;
    while( theBinder != next ) { 
      if( theBinder->NextResult().IsNull() ) {
        theBinder->AddResult(next);
        return;
      }
      else
        theBinder = theBinder->NextResult();
    }
  }
  //former recursive
  // if (thenextr.IsNull()) thenextr = next;
  // else if (thenextr == next) return;
  // else thenextr->AddResult (next);
}

//=======================================================================
//function : CutResult
//purpose  : 
//=======================================================================

void  Transfer_Binder::CutResult (const Handle(Transfer_Binder)& next)
{
  if (thenextr.IsNull()) return;
  if (thenextr == next) thenextr.Nullify();
  //else thenextr->CutResult (next);
  else {
    Handle(Transfer_Binder) currBinder = thenextr, currNext;
    while( !( (currNext = currBinder->NextResult()) == next ) ) {
      if( currNext.IsNull() )
        return;
      currBinder = currNext;
    }
    currBinder->CutResult(next);
  }
}

//=======================================================================
//function : NextResult
//purpose  : 
//=======================================================================

Handle(Transfer_Binder)  Transfer_Binder::NextResult () const
      {  return thenextr;  }


//=======================================================================
//function : SetResultPresent
//purpose  : 
//=======================================================================

void Transfer_Binder::SetResultPresent ()
{
  if (thestatus == Transfer_StatusUsed) Transfer_TransferFailure::Raise
    ("Binder : SetResult, Result is Already Set and Used");
  theexecst = Transfer_StatusDone;
  thestatus = Transfer_StatusDefined;
}

//=======================================================================
//function : HasResult
//purpose  : 
//=======================================================================

Standard_Boolean Transfer_Binder::HasResult () const
      {  return (thestatus != Transfer_StatusVoid);  }

//=======================================================================
//function : SetAlreadyUsed
//purpose  : 
//=======================================================================

void Transfer_Binder::SetAlreadyUsed ()
{  if (thestatus != Transfer_StatusVoid) thestatus = Transfer_StatusUsed;  }


//=======================================================================
//function : Status
//purpose  : 
//=======================================================================

Transfer_StatusResult Transfer_Binder::Status () const
{  return thestatus;  }


//  ############    Checks    ############

//=======================================================================
//function : StatusExec
//purpose  : 
//=======================================================================

Transfer_StatusExec Transfer_Binder::StatusExec () const
{  return theexecst;  }

//=======================================================================
//function : SetStatusExec
//purpose  : 
//=======================================================================

void Transfer_Binder::SetStatusExec (const Transfer_StatusExec stat)
{  theexecst = stat;  }

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

void Transfer_Binder::AddFail
  (const Standard_CString mess, const Standard_CString orig)
{
  theexecst = Transfer_StatusError;
  thecheck->AddFail(mess,orig);
}

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

void Transfer_Binder::AddWarning
  (const Standard_CString mess, const Standard_CString orig)
{
//  theexecst = Transfer_StatusError;
  thecheck->AddWarning(mess,orig);
}

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

const Handle(Interface_Check) Transfer_Binder::Check () const
{
  return thecheck;
}

//=======================================================================
//function : CCheck
//purpose  : 
//=======================================================================

Handle(Interface_Check) Transfer_Binder::CCheck ()
{
  return thecheck;
}