0027349: XtControl_Reader is not thread-safe
[occt.git] / src / XSControl / XSControl_TransferWriter.hxx
CommitLineData
42cf5bc1 1// Created on: 1996-03-13
2// Created by: Christian CAILLET
3// Copyright (c) 1996-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_TransferWriter_HeaderFile
18#define _XSControl_TransferWriter_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
42cf5bc1 23#include <MMgt_TShared.hxx>
42cf5bc1 24#include <IFSelect_ReturnStatus.hxx>
7f56eba8 25#include <Transfer_FinderProcess.hxx>
42cf5bc1 26class XSControl_Controller;
42cf5bc1 27class Standard_Transient;
28class Interface_InterfaceModel;
29class TopoDS_Shape;
30class Interface_CheckIterator;
31
32
33class XSControl_TransferWriter;
34DEFINE_STANDARD_HANDLE(XSControl_TransferWriter, MMgt_TShared)
35
36//! TransferWriter gives help to control transfer to write a file
37//! after having converted data from Cascade/Imagine
38//!
39//! It works with a Controller (which itself can work with an
40//! Actor to Write) and a FinderProcess. It records results and
41//! checks
42class XSControl_TransferWriter : public MMgt_TShared
43{
7f56eba8 44 public:
42cf5bc1 45
46 //! Creates a TransferWriter, empty, ready to run
47 //! with an empty FinderProcess (but no controller, etc)
7f56eba8 48 XSControl_TransferWriter()
49 : myTransferWriter(new Transfer_FinderProcess),
50 myTransferMode(0)
51 {}
42cf5bc1 52
53 //! Returns the FinderProcess itself
7f56eba8 54 const Handle(Transfer_FinderProcess) & FinderProcess() const
55 { return myTransferWriter; }
42cf5bc1 56
57 //! Sets a new FinderProcess and forgets the former one
7f56eba8 58 void SetFinderProcess (const Handle(Transfer_FinderProcess)& theFP)
59 { myTransferWriter = theFP; }
60
42cf5bc1 61 //! Returns the currently used Controller
7f56eba8 62 const Handle(XSControl_Controller) & Controller() const
63 { return myController; }
42cf5bc1 64
65 //! Sets a new Controller, also sets a new FinderProcess
7f56eba8 66 Standard_EXPORT void SetController (const Handle(XSControl_Controller)& theCtl)
67 {
68 myController = theCtl;
69 Clear(-1);
70 }
42cf5bc1 71
72 //! Clears recorded data according a mode
73 //! 0 clears FinderProcess (results, checks)
74 //! -1 create a new FinderProcess
7f56eba8 75 Standard_EXPORT void Clear (const Standard_Integer theMode);
42cf5bc1 76
77 //! Returns the current Transfer Mode (an Integer)
78 //! It will be interpreted by the Controller to run Transfers
79 //! This call form could be later replaced by more specific ones
80 //! (parameters suited for each norm / transfer case)
7f56eba8 81 Standard_Integer TransferMode() const
82 { return myTransferMode; }
83
42cf5bc1 84 //! Changes the Transfer Mode
7f56eba8 85 void SetTransferMode (const Standard_Integer theMode)
86 { myTransferMode = theMode; }
87
42cf5bc1 88 //! Prints statistics on current Trace File, according what,mode
89 //! See PrintStatsProcess for details
7f56eba8 90 Standard_EXPORT void PrintStats (const Standard_Integer theWhat, const Standard_Integer theMode = 0) const;
42cf5bc1 91
92 //! Tells if a transient object (from an application) is a valid
93 //! candidate for a transfer to a model
94 //! Asks the Controller (RecognizeWriteTransient)
95 //! If <obj> is a HShape, calls RecognizeShape
7f56eba8 96 Standard_EXPORT Standard_Boolean RecognizeTransient (const Handle(Standard_Transient)& theObj);
42cf5bc1 97
98 //! Transfers a Transient object (from an application) to a model
99 //! of current norm, according to the last call to SetTransferMode
100 //! Works by calling the Controller
101 //! Returns status : =0 if OK, >0 if error during transfer, <0 if
102 //! transfer badly initialised
7f56eba8 103 Standard_EXPORT IFSelect_ReturnStatus TransferWriteTransient (const Handle(Interface_InterfaceModel)& theModel, const Handle(Standard_Transient)& theObj);
42cf5bc1 104
105 //! Tells if a Shape is valid for a transfer to a model
106 //! Asks the Controller (RecognizeWriteShape)
7f56eba8 107 Standard_EXPORT Standard_Boolean RecognizeShape (const TopoDS_Shape& theShape);
42cf5bc1 108
109 //! Transfers a Shape from CasCade to a model of current norm,
110 //! according to the last call to SetTransferMode
111 //! Works by calling the Controller
112 //! Returns status : =0 if OK, >0 if error during transfer, <0 if
113 //! transfer badly initialised
7f56eba8 114 Standard_EXPORT IFSelect_ReturnStatus TransferWriteShape (const Handle(Interface_InterfaceModel)& theModel, const TopoDS_Shape& theShape);
42cf5bc1 115
116 //! Returns the check-list of last transfer (write), i.e. the
117 //! check-list currently recorded in the FinderProcess
118 Standard_EXPORT Interface_CheckIterator CheckList() const;
119
120 //! Returns the check-list of last transfer (write), but tries
121 //! to bind to each check, the resulting entity in the model
122 //! instead of keeping the original Mapper, whenever known
7f56eba8 123 Standard_EXPORT Interface_CheckIterator ResultCheckList (const Handle(Interface_InterfaceModel)& theModel) const;
42cf5bc1 124
92efcf78 125 DEFINE_STANDARD_RTTIEXT(XSControl_TransferWriter,MMgt_TShared)
42cf5bc1 126
7f56eba8 127 private:
42cf5bc1 128
7f56eba8 129 Handle(XSControl_Controller) myController;
130 Handle(Transfer_FinderProcess) myTransferWriter;
131 Standard_Integer myTransferMode;
42cf5bc1 132};
133
42cf5bc1 134#endif // _XSControl_TransferWriter_HeaderFile