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 <Interface_InterfaceModel.hxx>
17 #include <Standard_Transient.hxx>
18 #include <Standard_Type.hxx>
19 #include <TCollection_AsciiString.hxx>
20 #include <Transfer_Binder.hxx>
21 #include <Transfer_TransientProcess.hxx>
22 #include <XSControl_SignTransferStatus.hxx>
23 #include <XSControl_TransferReader.hxx>
25 IMPLEMENT_STANDARD_RTTIEXT(XSControl_SignTransferStatus,IFSelect_Signature)
28 static TCollection_AsciiString& themes()
30 static TCollection_AsciiString tm;
33 // si resultat avec type: a exploiter tout de suite !
35 XSControl_SignTransferStatus::XSControl_SignTransferStatus ()
36 : IFSelect_Signature("Transfer Status") { }
38 XSControl_SignTransferStatus::XSControl_SignTransferStatus
39 (const Handle(XSControl_TransferReader)& TR)
40 : IFSelect_Signature("Transfer Status") ,
43 void XSControl_SignTransferStatus::SetReader
44 (const Handle(XSControl_TransferReader)& TR)
47 void XSControl_SignTransferStatus::SetMap
48 (const Handle(Transfer_TransientProcess)& TP)
51 Handle(Transfer_TransientProcess) XSControl_SignTransferStatus::Map () const
54 Handle(XSControl_TransferReader) XSControl_SignTransferStatus::Reader () const
59 // BinderStatus retourne une valeur :
60 // 0 Binder Null. 1 void 2 Warning seul 3 Fail seul
61 // 11 Resultat OK. 12 Resultat+Warning. 13 Resultat+Fail
62 // 20 Abnormal (Interrupted)
64 static Standard_Integer BinderStatus (const Handle(Transfer_Binder)& binder)
66 Standard_Integer stat = 0;
67 if (binder.IsNull()) return 0;
68 Interface_CheckStatus cst = binder->Check()->Status();
69 Transfer_StatusExec est = binder->StatusExec ();
70 Standard_Boolean res = binder->HasResult();
71 if (est == Transfer_StatusRun || est == Transfer_StatusLoop) return 20;
72 if (cst == Interface_CheckOK) stat = (res ? 11 : 1);
73 else if (cst == Interface_CheckWarning) stat = (res ? 12 : 2);
74 else if (cst == Interface_CheckFail) stat = (res ? 13 : 3);
80 Standard_CString XSControl_SignTransferStatus::Value
81 (const Handle(Standard_Transient)& ent,
82 const Handle(Interface_InterfaceModel)& /*model*/) const
84 if (ent.IsNull()) return "";
85 Handle(Transfer_TransientProcess) TP = theTP;
86 if (TP.IsNull() && !theTR.IsNull()) TP = theTR->TransientProcess();
87 if (TP.IsNull()) return "";
89 Handle(Transfer_Binder) binder = TP->Find(ent);
91 Standard_Integer stat = BinderStatus (binder);
93 if (stat <= 1) return "";
94 if (stat == 2) return "Warning";
95 if (stat == 3) return "Fail";
96 if (stat == 20) return "Fail on run";
100 // Y a un resultat : donner son type
101 Handle(Transfer_Binder) bnd = binder;
102 Standard_Integer hasres = Standard_False;
103 while (!bnd.IsNull()) {
104 if (bnd->Status() != Transfer_StatusVoid) {
105 if (!hasres) themes().AssignCat("Result:");
106 else themes().AssignCat(",");
107 themes().AssignCat(bnd->ResultTypeName());
108 hasres = Standard_True;
110 bnd = bnd->NextResult();
112 // if (stat == 11) sprintf(themes,"Result:%s",binder->ResultTypeName());
113 if (stat == 12) themes().AssignCat("/Warning");
114 if (stat == 13) themes().AssignCat("/Fail");
116 return themes().ToCString();