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;
32 // resolve name collisions with X11 headers
37 class Transfer_Binder;
38 DEFINE_STANDARD_HANDLE(Transfer_Binder, MMgt_TShared)
40 //! A Binder is an auxiliary object to Map the Result of the
41 //! Transfer of a given Object : it records the Result of the
42 //! Unitary Transfer (Resulting Object), status of progress and
43 //! error (if any) of the Process
45 //! The class Binder itself makes no definition for the Result :
46 //! it is defined by sub-classes : it can be either Simple (and
47 //! has to be typed : see generic class SimpleBinder) or Multiple
48 //! (see class MultipleBinder).
50 //! In principle, for a Transfer in progress, Result cannot be
51 //! accessed : this would cause an exception raising.
52 //! This is controlled by the value if StatusResult : if it is
53 //! "Used", the Result cannot be changed. This status is normally
54 //! controlled by TransferProcess but can be directly (see method
57 //! Checks can be completed by a record of cases, as string which
58 //! can be used as codes, but not to be printed
60 //! In addition to the Result, a Binder can bring a list of
61 //! Attributes, which are additional data, each of them has a name
62 class Transfer_Binder : public MMgt_TShared
68 //! Merges basic data (Check, ExecStatus) from another Binder but
69 //! keeps its result. Used when a binder is replaced by another
70 //! one, this allows to keep messages
71 Standard_EXPORT void Merge (const Handle(Transfer_Binder)& other);
73 //! Returns True if a Binder has several results, either by itself
74 //! or because it has next results
75 //! Can be defined by sub-classes.
76 Standard_EXPORT virtual Standard_Boolean IsMultiple() const;
78 //! Returns the Type which characterizes the Result (if known)
79 Standard_EXPORT virtual Handle(Standard_Type) ResultType() const = 0;
81 //! Returns the Name of the Type which characterizes the Result
82 //! Can be returned even if ResultType itself is unknown
83 Standard_EXPORT virtual Standard_CString ResultTypeName() const = 0;
85 //! Adds a next result (at the end of the list)
86 //! Remark : this information is not processed by Merge
87 Standard_EXPORT void AddResult (const Handle(Transfer_Binder)& next);
89 //! Returns the next result, Null if none
90 Standard_EXPORT Handle(Transfer_Binder) NextResult() const;
92 //! Returns True if a Result is available (StatusResult = Defined)
93 //! A Unique Result will be gotten by Result (which must be
94 //! defined in each sub-class according to result type)
95 //! For a Multiple Result, see class MultipleBinder
96 //! For other case, specific access has to be forecast
97 Standard_EXPORT Standard_Boolean HasResult() const;
99 //! Declares that result is now used by another one, it means that
100 //! it cannot be modified (by Rebind)
101 Standard_EXPORT void SetAlreadyUsed();
103 //! Returns status, which can be Initial (not yet done), Made (a
104 //! result is recorded, not yet shared), Used (it is shared and
105 //! cannot be modified)
106 Standard_EXPORT Transfer_StatusResult Status() const;
108 //! Returns execution status
109 Standard_EXPORT Transfer_StatusExec StatusExec() const;
111 //! Modifies execution status; called by TransferProcess only
112 //! (for StatusError, rather use SetError, below)
113 Standard_EXPORT void SetStatusExec (const Transfer_StatusExec stat);
115 //! Used to declare an individual transfer as beeing erroneous
116 //! (Status is set to Void, StatusExec is set to Error, <errmess>
117 //! is added to Check's list of Fails)
118 //! It is possible to record several messages of error
120 //! It has same effect for TransferProcess as raising an exception
121 //! during the operation of Transfer, except the Transfer tries to
122 //! continue (as if ErrorHandle had been set)
123 Standard_EXPORT void AddFail (const Standard_CString mess, const Standard_CString orig = "");
125 //! Used to attach a Warning Message to an individual Transfer
126 //! It has no effect on the Status
127 Standard_EXPORT void AddWarning (const Standard_CString mess, const Standard_CString orig = "");
129 //! Returns Check which stores Fail messages
130 //! Note that no Entity is associated in this Check
131 Standard_EXPORT const Handle(Interface_Check) Check() const;
133 //! Returns Check which stores Fail messages, in order to modify
134 //! it (adding messages, or replacing it)
135 Standard_EXPORT Handle(Interface_Check) CCheck();
140 DEFINE_STANDARD_RTTIEXT(Transfer_Binder,MMgt_TShared)
145 //! Sets fields at initial values
146 Standard_EXPORT Transfer_Binder();
148 //! Used to declare that a result is recorded for an individual
149 //! transfer (works by setting StatusResult to Defined)
151 //! This Method is to be called once a Result is really recorded
152 //! (see sub-classes of Binder, especially SimpleBinder) : it is
153 //! senseless if called isolately
154 Standard_EXPORT void SetResultPresent();
161 //! Called by AddResult, to keep unicity of each item in the list
162 Standard_EXPORT void CutResult (const Handle(Transfer_Binder)& next);
164 Transfer_StatusResult thestatus;
165 Transfer_StatusExec theexecst;
166 Handle(Interface_Check) thecheck;
167 Handle(Transfer_Binder) thenextr;
178 #endif // _Transfer_Binder_HeaderFile