a1e3d4f1cc7119b420efe311807ff4a5f294aa38
[occt.git] / src / Transfer / Transfer_Binder.hxx
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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Transfer_Binder_HeaderFile
18 #define _Transfer_Binder_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
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;
31
32 // resolve name collisions with X11 headers
33 #ifdef Status
34   #undef Status
35 #endif
36
37 class Transfer_Binder;
38 DEFINE_STANDARD_HANDLE(Transfer_Binder, MMgt_TShared)
39
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
44 //!
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).
49 //!
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
55 //! SetAlreadyUsed)
56 //!
57 //! Checks can be completed by a record of cases, as string which
58 //! can be used as codes, but not to be printed
59 //!
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
63 {
64
65 public:
66
67   
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);
72   
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;
77   
78   //! Returns the Type which characterizes the Result (if known)
79   Standard_EXPORT virtual Handle(Standard_Type) ResultType() const = 0;
80   
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;
84   
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);
88   
89   //! Returns the next result, Null if none
90   Standard_EXPORT Handle(Transfer_Binder) NextResult() const;
91   
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;
98   
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();
102   
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;
107   
108   //! Returns execution status
109   Standard_EXPORT Transfer_StatusExec StatusExec() const;
110   
111   //! Modifies execution status; called by TransferProcess only
112   //! (for StatusError, rather use SetError, below)
113   Standard_EXPORT void SetStatusExec (const Transfer_StatusExec stat);
114   
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
119   //!
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 = "");
124   
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 = "");
128   
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;
132   
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();
136
137
138
139
140   DEFINE_STANDARD_RTTIEXT(Transfer_Binder,MMgt_TShared)
141
142 protected:
143
144   
145   //! Sets fields at initial values
146   Standard_EXPORT Transfer_Binder();
147   
148   //! Used to declare that a result is recorded for an individual
149   //! transfer (works by setting StatusResult to Defined)
150   //!
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();
155
156
157
158 private:
159
160   
161   //! Called by AddResult, to keep unicity of each item in the list
162   Standard_EXPORT void CutResult (const Handle(Transfer_Binder)& next);
163
164   Transfer_StatusResult thestatus;
165   Transfer_StatusExec theexecst;
166   Handle(Interface_Check) thecheck;
167   Handle(Transfer_Binder) thenextr;
168
169
170 };
171
172
173
174
175
176
177
178 #endif // _Transfer_Binder_HeaderFile