1 // Created on: 1993-06-09
2 // Created by: Christian CAILLET
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Transfer_Binder_HeaderFile
18 #define _Transfer_Binder_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Transfer_StatusResult.hxx>
24 #include <Transfer_StatusExec.hxx>
25 #include <MMgt_TShared.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Type.hxx>
28 #include <Standard_CString.hxx>
29 class Interface_Check;
30 class Transfer_TransferFailure;
33 class Transfer_Binder;
34 DEFINE_STANDARD_HANDLE(Transfer_Binder, MMgt_TShared)
36 //! A Binder is an auxiliary object to Map the Result of the
37 //! Transfer of a given Object : it records the Result of the
38 //! Unitary Transfer (Resulting Object), status of progress and
39 //! error (if any) of the Process
41 //! The class Binder itself makes no definition for the Result :
42 //! it is defined by sub-classes : it can be either Simple (and
43 //! has to be typed : see generic class SimpleBinder) or Multiple
44 //! (see class MultipleBinder).
46 //! In principle, for a Transfer in progress, Result cannot be
47 //! accessed : this would cause an exception raising.
48 //! This is controlled by the value if StatusResult : if it is
49 //! "Used", the Result cannot be changed. This status is normally
50 //! controlled by TransferProcess but can be directly (see method
53 //! Checks can be completed by a record of cases, as string which
54 //! can be used as codes, but not to be printed
56 //! In addition to the Result, a Binder can bring a list of
57 //! Attributes, which are additional data, each of them has a name
58 class Transfer_Binder : public MMgt_TShared
64 //! Merges basic data (Check, ExecStatus) from another Binder but
65 //! keeps its result. Used when a binder is replaced by another
66 //! one, this allows to keep messages
67 Standard_EXPORT void Merge (const Handle(Transfer_Binder)& other);
69 //! Returns True if a Binder has several results, either by itself
70 //! or because it has next results
71 //! Can be defined by sub-classes.
72 Standard_EXPORT virtual Standard_Boolean IsMultiple() const;
74 //! Returns the Type which characterizes the Result (if known)
75 Standard_EXPORT virtual Handle(Standard_Type) ResultType() const = 0;
77 //! Returns the Name of the Type which characterizes the Result
78 //! Can be returned even if ResultType itself is unknown
79 Standard_EXPORT virtual Standard_CString ResultTypeName() const = 0;
81 //! Adds a next result (at the end of the list)
82 //! Remark : this information is not processed by Merge
83 Standard_EXPORT void AddResult (const Handle(Transfer_Binder)& next);
85 //! Returns the next result, Null if none
86 Standard_EXPORT Handle(Transfer_Binder) NextResult() const;
88 //! Returns True if a Result is available (StatusResult = Defined)
89 //! A Unique Result will be gotten by Result (which must be
90 //! defined in each sub-class according to result type)
91 //! For a Multiple Result, see class MultipleBinder
92 //! For other case, specific access has to be forecast
93 Standard_EXPORT Standard_Boolean HasResult() const;
95 //! Declares that result is now used by another one, it means that
96 //! it cannot be modified (by Rebind)
97 Standard_EXPORT void SetAlreadyUsed();
99 //! Returns status, which can be Initial (not yet done), Made (a
100 //! result is recorded, not yet shared), Used (it is shared and
101 //! cannot be modified)
102 Standard_EXPORT Transfer_StatusResult Status() const;
104 //! Returns execution status
105 Standard_EXPORT Transfer_StatusExec StatusExec() const;
107 //! Modifies execution status; called by TransferProcess only
108 //! (for StatusError, rather use SetError, below)
109 Standard_EXPORT void SetStatusExec (const Transfer_StatusExec stat);
111 //! Used to declare an individual transfer as beeing erroneous
112 //! (Status is set to Void, StatusExec is set to Error, <errmess>
113 //! is added to Check's list of Fails)
114 //! It is possible to record several messages of error
116 //! It has same effect for TransferProcess as raising an exception
117 //! during the operation of Transfer, except the Transfer tries to
118 //! continue (as if ErrorHandle had been set)
119 Standard_EXPORT void AddFail (const Standard_CString mess, const Standard_CString orig = "");
121 //! Used to attach a Warning Message to an individual Transfer
122 //! It has no effect on the Status
123 Standard_EXPORT void AddWarning (const Standard_CString mess, const Standard_CString orig = "");
125 //! Returns Check which stores Fail messages
126 //! Note that no Entity is associated in this Check
127 Standard_EXPORT const Handle(Interface_Check) Check() const;
129 //! Returns Check which stores Fail messages, in order to modify
130 //! it (adding messages, or replacing it)
131 Standard_EXPORT Handle(Interface_Check) CCheck();
136 DEFINE_STANDARD_RTTIEXT(Transfer_Binder,MMgt_TShared)
141 //! Sets fields at initial values
142 Standard_EXPORT Transfer_Binder();
144 //! Used to declare that a result is recorded for an individual
145 //! transfer (works by setting StatusResult to Defined)
147 //! This Method is to be called once a Result is really recorded
148 //! (see sub-classes of Binder, especially SimpleBinder) : it is
149 //! senseless if called isolately
150 Standard_EXPORT void SetResultPresent();
157 //! Called by AddResult, to keep unicity of each item in the list
158 Standard_EXPORT void CutResult (const Handle(Transfer_Binder)& next);
160 Transfer_StatusResult thestatus;
161 Transfer_StatusExec theexecst;
162 Handle(Interface_Check) thecheck;
163 Handle(Transfer_Binder) thenextr;
174 #endif // _Transfer_Binder_HeaderFile