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 <Interface_Check.hxx>
16 #include <Standard_NoSuchObject.hxx>
17 #include <Standard_Transient.hxx>
18 #include <Transfer_Binder.hxx>
19 #include <Transfer_SimpleBinderOfTransient.hxx>
20 #include <Transfer_TransferIterator.hxx>
22 static Handle(Standard_Transient) nultrans; // pour retour const&(Null)
25 Transfer_TransferIterator::Transfer_TransferIterator ()
27 theitems = new Transfer_HSequenceOfBinder();
28 theselect = new TColStd_HSequenceOfInteger();
33 void Transfer_TransferIterator::AddItem
34 (const Handle(Transfer_Binder)& atr)
36 theitems->Append(atr);
38 themaxi = theselect->Length();
41 void Transfer_TransferIterator::SelectBinder
42 (const Handle(Standard_Type)& atype, const Standard_Boolean keep)
44 for (Standard_Integer i = theitems->Length(); i > 0; i --) {
45 if (theitems->Value(i)->IsKind(atype) != keep) {
46 theselect->SetValue(i,0);
47 if (themaxi == i) themaxi = i-1;
52 void Transfer_TransferIterator::SelectResult
53 (const Handle(Standard_Type)& atype, const Standard_Boolean keep)
55 Standard_Integer casetype = 0;
56 if (atype->SubType(STANDARD_TYPE(Standard_Transient))) casetype = 2;
58 for (Standard_Integer i = theitems->Length(); i > 0; i --) {
59 Handle(Transfer_Binder) atr = theitems->Value(i);
60 Handle(Standard_Type) btype = ResultType();
61 Standard_Boolean matchtype;
62 if (!atr->HasResult()) matchtype = Standard_False;
63 else if (atr->IsMultiple()) matchtype = Standard_False;
64 else if (casetype == 0) matchtype = (atype == btype); // Type fixe
65 else matchtype = (btype->SubType(atype)); // Dynamique
66 if (matchtype != keep) {
67 theselect->SetValue(i,0);
68 if (themaxi == i) themaxi = i-1;
73 void Transfer_TransferIterator::SelectUnique
74 (const Standard_Boolean keep)
76 for (Standard_Integer i = theitems->Length(); i > 0; i --) {
77 Handle(Transfer_Binder) atr = theitems->Value(i);
78 if (atr->IsMultiple() == keep) {
79 theselect->SetValue(i,0);
80 if (themaxi == i) themaxi = i-1;
85 void Transfer_TransferIterator::SelectItem
86 (const Standard_Integer num, const Standard_Boolean keep)
88 if (num < 1 || num > theselect->Length()) return;
89 if (keep) theselect->SetValue (num,1);
90 else theselect->SetValue (num,0);
93 // .... Iteration-Interrogations ....
95 Standard_Integer Transfer_TransferIterator::Number () const
97 Standard_Integer numb,i; numb = 0;
98 for (i = 1; i <= themaxi; i ++) {
99 if (theselect->Value(i) != 0) numb ++;
104 void Transfer_TransferIterator::Start ()
105 { thecurr = 0; Next(); }
107 Standard_Boolean Transfer_TransferIterator::More ()
109 if (thecurr > themaxi) return Standard_False;
110 if (theselect->Value(thecurr) == 0) Next();
111 if (thecurr > themaxi) return Standard_False;
112 return (theselect->Value(thecurr) > 0);
115 void Transfer_TransferIterator::Next ()
118 if (thecurr > themaxi) return;
119 if (theselect->Value(thecurr) == 0) Next();
122 const Handle(Transfer_Binder)& Transfer_TransferIterator::Value () const
124 if (thecurr == 0 || thecurr > themaxi) throw Standard_NoSuchObject("TransferIterator : Value");
125 if (theselect->Value(thecurr) == 0) throw Standard_NoSuchObject("TransferIterator : Value");
126 return theitems->Value(thecurr);
129 // .... Acces aux Donnees du Binder Courant ....
131 Standard_Boolean Transfer_TransferIterator::HasResult () const
133 Handle(Transfer_Binder) atr = Value();
134 return atr->HasResult();
137 Standard_Boolean Transfer_TransferIterator::HasUniqueResult () const
139 Handle(Transfer_Binder) atr = Value();
140 if (atr->IsMultiple()) return Standard_False;
141 return atr->HasResult();
145 Handle(Standard_Type) Transfer_TransferIterator::ResultType () const
147 Handle(Standard_Type) btype;
148 Handle(Transfer_Binder) atr = Value();
149 if (!atr->IsMultiple()) btype = atr->ResultType();
150 // ResultType de Binder prend en compte le Type Dynamique pour les Handle
155 Standard_Boolean Transfer_TransferIterator::HasTransientResult () const
157 Handle(Standard_Type) btype = ResultType();
158 if (btype.IsNull()) return Standard_False;
159 return btype->SubType(STANDARD_TYPE(Standard_Transient));
162 const Handle(Standard_Transient)&
163 Transfer_TransferIterator::TransientResult () const
165 Handle(Transfer_SimpleBinderOfTransient) atr =
166 Handle(Transfer_SimpleBinderOfTransient)::DownCast(Value());
167 if (!atr.IsNull()) return atr->Result();
172 Transfer_StatusExec Transfer_TransferIterator::Status () const
174 Handle(Transfer_Binder) atr = Value();
175 return atr->StatusExec();
179 Standard_Boolean Transfer_TransferIterator::HasFails () const
181 Handle(Transfer_Binder) atr = Value();
182 return atr->Check()->HasFailed();
185 Standard_Boolean Transfer_TransferIterator::HasWarnings () const
187 Handle(Transfer_Binder) atr = Value();
188 return atr->Check()->HasWarnings();
191 const Handle(Interface_Check) Transfer_TransferIterator::Check () const
193 Handle(Transfer_Binder) atr = Value();