1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _TDF_Transaction_HeaderFile
17 #define _TDF_Transaction_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
23 #include <Standard_Integer.hxx>
24 #include <TCollection_AsciiString.hxx>
25 #include <Standard_Boolean.hxx>
27 class Standard_DomainError;
28 class Standard_NullObject;
30 class TCollection_AsciiString;
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
40 //! In case of catching errors, the effect will be the
41 //! same: aborting transactions until the good current
50 //! Creates an empty transaction context, unable to be
52 Standard_EXPORT TDF_Transaction(const TCollection_AsciiString& aName = "");
54 //! Creates a transaction context on <aDF>, ready to
56 Standard_EXPORT TDF_Transaction(const Handle(TDF_Data)& aDF, const TCollection_AsciiString& aName = "");
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);
63 //! If not yet done, opens a new transaction on
64 //! <myDF>. Returns the index of the just opened
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();
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);
76 //! Aborts the transactions until AND including the
77 //! current opened one.
78 Standard_EXPORT void Abort();
84 //! Returns the Data from TDF.
85 Handle(TDF_Data) Data() const;
87 //! Returns the number of the transaction opened by <me>.
88 Standard_Integer Transaction() const;
90 //! Returns the transaction name.
91 Standard_EXPORT const TCollection_AsciiString& Name() const;
93 //! Returns true if the transaction is open.
94 Standard_Boolean IsOpen() const;
108 //! Private to avoid copy.
109 Standard_EXPORT TDF_Transaction(const TDF_Transaction& aTrans);
112 Handle(TDF_Data) myDF;
113 Standard_Integer myUntilTransaction;
114 TCollection_AsciiString myName;
120 #include <TDF_Transaction.lxx>
126 #endif // _TDF_Transaction_HeaderFile