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 // -------------------
19 //Version Date Purpose
20 // 0.0 Oct 1 1997 Creation
24 #include <TDF_Transaction.ixx>
26 #undef DEB_TRANSACTION
28 #define DEB_TRANSACTION
30 #undef DEB_TRANSACTION_DUMP
32 #include <TDF_Tool.hxx>
34 //=======================================================================
35 //function : TDF_Transaction
37 //=======================================================================
39 TDF_Transaction::TDF_Transaction
40 (const TCollection_AsciiString& aName)
41 : myUntilTransaction(0),
46 //=======================================================================
47 //function : TDF_Transaction
48 //purpose : Private copy constructor.
49 //=======================================================================
51 TDF_Transaction::TDF_Transaction(const TDF_Transaction& /*aTrans*/)
55 //=======================================================================
56 //function : TDF_Transaction
58 //=======================================================================
60 TDF_Transaction::TDF_Transaction
61 (const Handle(TDF_Data)& aDF,
62 const TCollection_AsciiString& aName)
64 myUntilTransaction(0),
71 //=======================================================================
72 //function : Initialize
73 //purpose : Initializes a transaction ready to be opened.
74 //=======================================================================
76 void TDF_Transaction::Initialize(const Handle(TDF_Data)& aDF)
78 if (IsOpen()) myDF->AbortUntilTransaction(myUntilTransaction);
80 myUntilTransaction = 0;
84 //=======================================================================
87 //=======================================================================
89 Standard_Integer TDF_Transaction::Open()
91 #ifdef OCCT_DEBUG_TRANSACTION
92 cout<<"Transaction "<<myName<<" opens #"<<myDF->Transaction()+1<<endl;
95 Standard_DomainError::Raise("This transaction is already open.");
97 Standard_NullObject::Raise("Null TDF_Data.");
98 return myUntilTransaction = myDF->OpenTransaction();
102 //=======================================================================
105 //=======================================================================
107 Handle(TDF_Delta) TDF_Transaction::Commit(const Standard_Boolean withDelta)
109 #ifdef OCCT_DEBUG_TRANSACTION
110 cout<<"Transaction "<<myName<<" commits ";
112 Handle(TDF_Delta) delta;
114 #ifdef OCCT_DEBUG_TRANSACTION
115 cout<<"from #"<<myDF->Transaction()<<" until #"<<myUntilTransaction<<" while current is #"<<myDF->Transaction()<<endl;
117 #ifdef OCCT_DEBUG_TRANSACTION_DUMP
118 cout<<"DF before commit"<<endl;
119 TDF_Tool::DeepDump(cout,myDF);
121 Standard_Integer until = myUntilTransaction;
122 myUntilTransaction = 0;
123 delta = myDF->CommitUntilTransaction(until, withDelta);
124 #ifdef OCCT_DEBUG_TRANSACTION_DUMP
125 cout<<"DF after commit"<<endl;
126 TDF_Tool::DeepDump(cout,myDF);
129 #ifdef OCCT_DEBUG_TRANSACTION
130 else cout<<"but this transaction is not open!"<<endl;
136 //=======================================================================
139 //=======================================================================
141 void TDF_Transaction::Abort()
144 #ifdef OCCT_DEBUG_TRANSACTION
145 cout<<"Transaction "<<myName<<" aborts from #"<<myDF->Transaction()<<" until #"<<myUntilTransaction<<" while current is #"<<myDF->Transaction()<<endl;
147 #ifdef OCCT_DEBUG_TRANSACTION_DUMP
148 cout<<"DF before abort"<<endl;
149 TDF_Tool::DeepDump(cout,myDF);
151 myDF->AbortUntilTransaction(myUntilTransaction);
152 myUntilTransaction = 0;
153 #ifdef OCCT_DEBUG_TRANSACTION_DUMP
154 cout<<"DF after abort"<<endl;
155 TDF_Tool::DeepDump(cout,myDF);