Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:21

0001 // Created by: DAUTRY Philippe
0002 // Copyright (c) 1997-1999 Matra Datavision
0003 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _TDF_Transaction_HeaderFile
0017 #define _TDF_Transaction_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021 #include <Standard_Handle.hxx>
0022 
0023 #include <Standard_Integer.hxx>
0024 #include <TCollection_AsciiString.hxx>
0025 class TDF_Data;
0026 class TDF_Delta;
0027 
0028 
0029 //! This class offers services to open, commit or
0030 //! abort a transaction in a more secure way than
0031 //! using Data from TDF. If you forget to close a
0032 //! transaction, it will be automatically aborted at
0033 //! the destruction of this object, at the closure of
0034 //! its scope.
0035 //!
0036 //! In case of catching errors, the effect will be the
0037 //! same: aborting transactions until the good current
0038 //! one.
0039 class TDF_Transaction 
0040 {
0041 public:
0042 
0043   DEFINE_STANDARD_ALLOC
0044 
0045   
0046   //! Creates an empty transaction context, unable to be
0047   //! opened.
0048   Standard_EXPORT TDF_Transaction(const TCollection_AsciiString& aName = "");
0049   
0050   //! Creates a transaction context on <aDF>, ready to
0051   //! be opened.
0052   Standard_EXPORT TDF_Transaction(const Handle(TDF_Data)& aDF, const TCollection_AsciiString& aName = "");
0053   
0054   //! Aborts all the transactions on <myDF> and sets
0055   //! <aDF> to build a transaction context on <aDF>,
0056   //! ready to be opened.
0057   Standard_EXPORT void Initialize (const Handle(TDF_Data)& aDF);
0058   
0059   //! If not yet done, opens a new transaction on
0060   //! <myDF>. Returns the index of the just opened
0061   //! transaction.
0062   //!
0063   //! It raises DomainError if the transaction is
0064   //! already open, and NullObject if there is no
0065   //! current Data framework.
0066   Standard_EXPORT Standard_Integer Open();
0067   
0068   //! Commits the transactions until AND including the
0069   //! current opened one.
0070   Standard_EXPORT Handle(TDF_Delta) Commit (const Standard_Boolean withDelta = Standard_False);
0071   
0072   //! Aborts the transactions until AND including the
0073   //! current opened one.
0074   Standard_EXPORT void Abort();
0075 ~TDF_Transaction()
0076 {
0077   Abort();
0078 }
0079   
0080   //! Returns the Data from TDF.
0081     Handle(TDF_Data) Data() const;
0082   
0083   //! Returns the number of the transaction opened by <me>.
0084     Standard_Integer Transaction() const;
0085   
0086   //! Returns the transaction name.
0087   const TCollection_AsciiString& Name() const;
0088   
0089   //! Returns true if the transaction is open.
0090     Standard_Boolean IsOpen() const;
0091 
0092   //! Dumps the content of me into the stream
0093   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0094 
0095 private:
0096 
0097   //! Private to avoid copy.
0098   TDF_Transaction(const TDF_Transaction& aTrans);
0099   TDF_Transaction& operator= (const TDF_Transaction& theOther);
0100 
0101 private:
0102 
0103   Handle(TDF_Data) myDF;
0104   TCollection_AsciiString myName;
0105   Standard_Integer myUntilTransaction;
0106 
0107 };
0108 
0109 
0110 #include <TDF_Transaction.lxx>
0111 
0112 
0113 
0114 
0115 
0116 #endif // _TDF_Transaction_HeaderFile