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.
14 #include <XSControl_SignTransferStatus.ixx>
15 #include <Transfer_Binder.hxx>
16 #include <TCollection_AsciiString.hxx>
17 #include <Interface_Check.hxx>
20 static TCollection_AsciiString& themes()
22 static TCollection_AsciiString tm;
25 // si resultat avec type: a exploiter tout de suite !
27 XSControl_SignTransferStatus::XSControl_SignTransferStatus ()
28 : IFSelect_Signature("Transfer Status") { }
30 XSControl_SignTransferStatus::XSControl_SignTransferStatus
31 (const Handle(XSControl_TransferReader)& TR)
32 : IFSelect_Signature("Transfer Status") ,
35 void XSControl_SignTransferStatus::SetReader
36 (const Handle(XSControl_TransferReader)& TR)
39 void XSControl_SignTransferStatus::SetMap
40 (const Handle(Transfer_TransientProcess)& TP)
43 Handle(Transfer_TransientProcess) XSControl_SignTransferStatus::Map () const
46 Handle(XSControl_TransferReader) XSControl_SignTransferStatus::Reader () const
51 // BinderStatus retourne une valeur :
52 // 0 Binder Null. 1 void 2 Warning seul 3 Fail seul
53 // 11 Resultat OK. 12 Resultat+Warning. 13 Resultat+Fail
54 // 20 Abnormal (Interrupted)
56 static Standard_Integer BinderStatus (const Handle(Transfer_Binder)& binder)
58 Standard_Integer stat = 0;
59 if (binder.IsNull()) return 0;
60 Interface_CheckStatus cst = binder->Check()->Status();
61 Transfer_StatusExec est = binder->StatusExec ();
62 Standard_Boolean res = binder->HasResult();
63 if (est == Transfer_StatusRun || est == Transfer_StatusLoop) return 20;
64 if (cst == Interface_CheckOK) stat = (res ? 11 : 1);
65 else if (cst == Interface_CheckWarning) stat = (res ? 12 : 2);
66 else if (cst == Interface_CheckFail) stat = (res ? 13 : 3);
72 Standard_CString XSControl_SignTransferStatus::Value
73 (const Handle(Standard_Transient)& ent,
74 const Handle(Interface_InterfaceModel)& /*model*/) const
76 if (ent.IsNull()) return "";
77 Handle(Transfer_TransientProcess) TP = theTP;
78 if (TP.IsNull() && !theTR.IsNull()) TP = theTR->TransientProcess();
79 if (TP.IsNull()) return "";
81 Handle(Transfer_Binder) binder = TP->Find(ent);
83 Standard_Integer stat = BinderStatus (binder);
85 if (stat <= 1) return "";
86 if (stat == 2) return "Warning";
87 if (stat == 3) return "Fail";
88 if (stat == 20) return "Fail on run";
92 // Y a un resultat : donner son type
93 Handle(Transfer_Binder) bnd = binder;
94 Standard_Integer hasres = Standard_False;
95 while (!bnd.IsNull()) {
96 if (bnd->Status() != Transfer_StatusVoid) {
97 if (!hasres) themes().AssignCat("Result:");
98 else themes().AssignCat(",");
99 themes().AssignCat(bnd->ResultTypeName());
100 hasres = Standard_True;
102 bnd = bnd->NextResult();
104 // if (stat == 11) sprintf(themes,"Result:%s",binder->ResultTypeName());
105 if (stat == 12) themes().AssignCat("/Warning");
106 if (stat == 13) themes().AssignCat("/Fail");
108 return themes().ToCString();