0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / TDF / TDF_Transaction.hxx
1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _TDF_Transaction_HeaderFile
17 #define _TDF_Transaction_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
22
23 #include <Standard_Integer.hxx>
24 #include <TCollection_AsciiString.hxx>
25 #include <Standard_Boolean.hxx>
26 class TDF_Data;
27 class Standard_DomainError;
28 class Standard_NullObject;
29 class TDF_Delta;
30 class TCollection_AsciiString;
31
32
33 //! This class offers services to open, commit or
34 //! abort a transaction in a more secure way than
35 //! using Data from TDF. If you forget to close a
36 //! transaction, it will be automaticaly aborted at
37 //! the destruction of this object, at the closure of
38 //! its scope.
39 //!
40 //! In case of catching errors, the effect will be the
41 //! same: aborting transactions until the good current
42 //! one.
43 class TDF_Transaction 
44 {
45 public:
46
47   DEFINE_STANDARD_ALLOC
48
49   
50   //! Creates an empty transaction context, unable to be
51   //! opened.
52   Standard_EXPORT TDF_Transaction(const TCollection_AsciiString& aName = "");
53   
54   //! Creates a transaction context on <aDF>, ready to
55   //! be opened.
56   Standard_EXPORT TDF_Transaction(const Handle(TDF_Data)& aDF, const TCollection_AsciiString& aName = "");
57   
58   //! Aborts all the transactions on <myDF> and sets
59   //! <aDF> to build a transaction context on <aDF>,
60   //! ready to be opened.
61   Standard_EXPORT void Initialize (const Handle(TDF_Data)& aDF);
62   
63   //! If not yet done, opens a new transaction on
64   //! <myDF>. Returns the index of the just opened
65   //! transaction.
66   //!
67   //! It raises DomainError if the transaction is
68   //! already open, and NullObject if there is no
69   //! current Data framework.
70   Standard_EXPORT Standard_Integer Open();
71   
72   //! Commits the transactions until AND including the
73   //! current opened one.
74   Standard_EXPORT Handle(TDF_Delta) Commit (const Standard_Boolean withDelta = Standard_False);
75   
76   //! Aborts the transactions until AND including the
77   //! current opened one.
78   Standard_EXPORT void Abort();
79 ~TDF_Transaction()
80 {
81   Abort();
82 }
83   
84   //! Returns the Data from TDF.
85     Handle(TDF_Data) Data() const;
86   
87   //! Returns the number of the transaction opened by <me>.
88     Standard_Integer Transaction() const;
89   
90   //! Returns the transaction name.
91   const TCollection_AsciiString& Name() const;
92   
93   //! Returns true if the transaction is open.
94     Standard_Boolean IsOpen() const;
95
96
97
98
99 protected:
100
101
102
103
104
105 private:
106
107   
108   //! Private to avoid copy.
109   Standard_EXPORT TDF_Transaction(const TDF_Transaction& aTrans);
110
111
112   Handle(TDF_Data) myDF;
113   Standard_Integer myUntilTransaction;
114   TCollection_AsciiString myName;
115
116
117 };
118
119
120 #include <TDF_Transaction.lxx>
121
122
123
124
125
126 #endif // _TDF_Transaction_HeaderFile