0031501: Foundation Classes, Message_Printer - remove theToPutEndl argument -- prepar...
[occt.git] / src / XSControl / XSControl_WorkSession.hxx
CommitLineData
42cf5bc1 1// Created on: 1995-06-01
2// Created by: Christian CAILLET
3// Copyright (c) 1995-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 _XSControl_WorkSession_HeaderFile
18#define _XSControl_WorkSession_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
42cf5bc1 23#include <IFSelect_WorkSession.hxx>
42cf5bc1 24#include <IFSelect_ReturnStatus.hxx>
7f56eba8 25#include <XSControl_TransferWriter.hxx>
42cf5bc1 26class XSControl_Controller;
27class XSControl_TransferReader;
42cf5bc1 28class XSControl_Vars;
29class Message_Messenger;
30class Transfer_TransientProcess;
31class Standard_Transient;
32class Interface_InterfaceModel;
33class Transfer_FinderProcess;
34class TopoDS_Shape;
35class Interface_CheckIterator;
36
37
38class XSControl_WorkSession;
39DEFINE_STANDARD_HANDLE(XSControl_WorkSession, IFSelect_WorkSession)
40
41//! This WorkSession completes the basic one, by adding :
42//! - use of Controller, with norm selection...
43//! - management of transfers (both ways) with auxiliary classes
44//! TransferReader and TransferWriter
45//! -> these transfers may work with a Context List : its items
46//! are given by the user, according to the transfer to be
47//! i.e. it is interpreted by the Actors
48//! Each item is accessed by a Name
49class XSControl_WorkSession : public IFSelect_WorkSession
50{
7f56eba8 51 public:
42cf5bc1 52
53 Standard_EXPORT XSControl_WorkSession();
54
7f56eba8 55 ~XSControl_WorkSession()
56 { ClearBinders(); }
57
42cf5bc1 58 //! In addition to basic ClearData, clears Transfer and Management
59 //! for interactive use, for mode = 0,1,2 and over 4
60 //! Plus : mode = 5 to clear Transfers (both ways) only
61 //! mode = 6 to clear enforced results
62 //! mode = 7 to clear transfers, results
7f56eba8 63 Standard_EXPORT virtual void ClearData (const Standard_Integer theMode) Standard_OVERRIDE;
42cf5bc1 64
65 //! Selects a Norm defined by its name.
66 //! A Norm is described and handled by a Controller
67 //! Returns True if done, False if <normname> is unknown
68 //!
7f56eba8 69 //! The current Profile for this Norm is taken.
70 Standard_EXPORT Standard_Boolean SelectNorm (const Standard_CString theNormName);
42cf5bc1 71
72 //! Selects a Norm defined by its Controller itself
7f56eba8 73 Standard_EXPORT void SetController (const Handle(XSControl_Controller)& theCtl);
42cf5bc1 74
75 //! Returns the name of the last Selected Norm. If none is
76 //! defined, returns an empty string
77 //! By default, returns the complete name of the norm
78 //! If <rsc> is True, returns the short name used for resource
7f56eba8 79 Standard_EXPORT Standard_CString SelectedNorm (const Standard_Boolean theRsc = Standard_False) const;
42cf5bc1 80
81 //! Returns the norm controller itself
7f56eba8 82 const Handle(XSControl_Controller) & NormAdaptor() const
83 { return myController; }
42cf5bc1 84
85 //! Returns the current Context List, Null if not defined
86 //! The Context is given to the TransientProcess for TransferRead
997e128f 87 const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> & Context() const
7f56eba8 88 { return myContext; }
42cf5bc1 89
90 //! Sets the current Context List, as a whole
91 //! Sets it to the TransferReader
997e128f 92 Standard_EXPORT void SetAllContext (const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& theContext);
42cf5bc1 93
94 //! Clears the whole current Context (nullifies it)
95 Standard_EXPORT void ClearContext();
96
97 //! Prints the transfer status of a transferred item, as beeing
98 //! the Mapped n0 <num>, from MapWriter if <wri> is True, or
99 //! from MapReader if <wri> is False
100 //! Returns True when done, False else (i.e. num out of range)
0ebe5b0a 101 Standard_EXPORT Standard_Boolean PrintTransferStatus (const Standard_Integer theNum, const Standard_Boolean theWri, Standard_OStream& theS) const;
42cf5bc1 102
103 //! Sets a Transfer Reader, by internal ways, according mode :
104 //! 0 recreates it clear, 1 clears it (does not recreate)
105 //! 2 aligns Roots of TransientProcess from final Results
106 //! 3 aligns final Results from Roots of TransientProcess
107 //! 4 begins a new transfer (by BeginTransfer)
108 //! 5 recreates TransferReader then begins a new transfer
7f56eba8 109 Standard_EXPORT void InitTransferReader (const Standard_Integer theMode);
42cf5bc1 110
111 //! Sets a Transfer Reader, which manages transfers on reading
7f56eba8 112 Standard_EXPORT void SetTransferReader (const Handle(XSControl_TransferReader)& theTR);
42cf5bc1 113
114 //! Returns the Transfer Reader, Null if not set
7f56eba8 115 const Handle(XSControl_TransferReader) & TransferReader () const
116 { return myTransferReader; }
8d0b8649 117
118 //! Returns the TransientProcess(internal data for TransferReader)
119 Standard_EXPORT Handle(Transfer_TransientProcess) MapReader() const;
120
42cf5bc1 121 //! Changes the Map Reader, i.e. considers that the new one
122 //! defines the relevant read results (forgets the former ones)
123 //! Returns True when done, False in case of bad definition, i.e.
124 //! if Model from TP differs from that of Session
7f56eba8 125 Standard_EXPORT Standard_Boolean SetMapReader (const Handle(Transfer_TransientProcess)& theTP);
42cf5bc1 126
127 //! Returns the result attached to a starting entity
128 //! If <mode> = 0, returns Final Result
129 //! If <mode> = 1, considers Last Result
130 //! If <mode> = 2, considers Final, else if absent, Last
131 //! returns it as Transient, if result is not transient returns
132 //! the Binder
133 //! <mode> = 10,11,12 idem but returns the Binder itself
134 //! (if it is not, e.g. Shape, returns the Binder)
135 //! <mode> = 20, returns the ResultFromModel
7f56eba8 136 Standard_EXPORT Handle(Standard_Transient) Result (const Handle(Standard_Transient)& theEnt, const Standard_Integer theMode) const;
42cf5bc1 137
138 //! Commands the transfer of, either one entity, or a list
139 //! I.E. calls the TransferReader after having analysed <ents>
140 //! It is cumulated from the last BeginTransfer
141 //! <ents> is processed by GiveList, hence :
142 //! - <ents> a Selection : its SelectionResult
143 //! - <ents> a HSequenceOfTransient : this list
144 //! - <ents> the Model : in this specific case, all the roots,
145 //! with no cumulation of former transfers (TransferReadRoots)
7f56eba8 146 Standard_EXPORT Standard_Integer TransferReadOne (const Handle(Standard_Transient)& theEnts);
42cf5bc1 147
148 //! Commands the transfer of all the root entities of the model
149 //! i.e. calls TransferRoot from the TransferReader with the Graph
150 //! No cumulation with former calls to TransferReadOne
151 Standard_EXPORT Standard_Integer TransferReadRoots();
152
153 //! produces and returns a new Model well conditionned
154 //! It is produced by the Norm Controller
155 //! It can be Null (if this function is not implemented)
156 Standard_EXPORT Handle(Interface_InterfaceModel) NewModel();
157
158 //! Returns the Transfer Reader, Null if not set
7f56eba8 159 const Handle(XSControl_TransferWriter) & TransferWriter() const
160 { return myTransferWriter; }
42cf5bc1 161
162 //! Changes the Map Reader, i.e. considers that the new one
163 //! defines the relevant read results (forgets the former ones)
164 //! Returns True when done, False if <FP> is Null
7f56eba8 165 Standard_Boolean SetMapWriter (const Handle(Transfer_FinderProcess)& theFP)
166 {
167 if (theFP.IsNull()) return Standard_False;
168 myTransferWriter->SetFinderProcess(theFP);
169 return Standard_True;
170 }
42cf5bc1 171
172 //! Transfers a Shape from CasCade to a model of current norm,
173 //! according to the last call to SetModeWriteShape
174 //! Returns status :Done if OK, Fail if error during transfer,
175 //! Error if transfer badly initialised
7f56eba8 176 Standard_EXPORT IFSelect_ReturnStatus TransferWriteShape (const TopoDS_Shape& theShape, const Standard_Boolean theCompGraph = Standard_True);
42cf5bc1 177
178 //! Returns the check-list of last transfer (write)
179 //! It is recorded in the FinderProcess, but it must be bound with
180 //! resulting entities (in the resulting file model) rather than
181 //! with original objects (in fact, their mappers)
182 Standard_EXPORT Interface_CheckIterator TransferWriteCheckList() const;
183
7f56eba8 184 const Handle(XSControl_Vars) & Vars() const
185 { return myVars; }
42cf5bc1 186
7f56eba8 187 void SetVars (const Handle(XSControl_Vars)& theVars)
188 { myVars = theVars; }
42cf5bc1 189
92efcf78 190 DEFINE_STANDARD_RTTIEXT(XSControl_WorkSession,IFSelect_WorkSession)
42cf5bc1 191
7f56eba8 192 private:
193
194 //! Clears binders
195 Standard_EXPORT void ClearBinders();
42cf5bc1 196
7f56eba8 197 Handle(XSControl_Controller) myController;
198 Handle(XSControl_TransferReader) myTransferReader;
199 Handle(XSControl_TransferWriter) myTransferWriter;
997e128f 200 NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> myContext;
7f56eba8 201 Handle(XSControl_Vars) myVars;
42cf5bc1 202};
203
42cf5bc1 204#endif // _XSControl_WorkSession_HeaderFile