1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
20 // -------------------
23 //Version Date Purpose
24 // 0.0 Oct 1 1997 Creation
28 #include <TDF_Transaction.ixx>
30 #undef DEB_TRANSACTION
32 #define DEB_TRANSACTION
34 #undef DEB_TRANSACTION_DUMP
36 #include <TDF_Tool.hxx>
38 //=======================================================================
39 //function : TDF_Transaction
41 //=======================================================================
43 TDF_Transaction::TDF_Transaction
44 (const TCollection_AsciiString& aName)
45 : myUntilTransaction(0),
50 //=======================================================================
51 //function : TDF_Transaction
52 //purpose : Private copy constructor.
53 //=======================================================================
55 TDF_Transaction::TDF_Transaction(const TDF_Transaction& aTrans)
59 //=======================================================================
60 //function : TDF_Transaction
62 //=======================================================================
64 TDF_Transaction::TDF_Transaction
65 (const Handle(TDF_Data)& aDF,
66 const TCollection_AsciiString& aName)
68 myUntilTransaction(0),
75 //=======================================================================
76 //function : Initialize
77 //purpose : Initializes a transaction ready to be opened.
78 //=======================================================================
80 void TDF_Transaction::Initialize(const Handle(TDF_Data)& aDF)
82 if (IsOpen()) myDF->AbortUntilTransaction(myUntilTransaction);
84 myUntilTransaction = 0;
88 //=======================================================================
91 //=======================================================================
93 Standard_Integer TDF_Transaction::Open()
95 #ifdef DEB_TRANSACTION
96 cout<<"Transaction "<<myName<<" opens #"<<myDF->Transaction()+1<<endl;
99 Standard_DomainError::Raise("This transaction is already open.");
101 Standard_NullObject::Raise("Null TDF_Data.");
102 return myUntilTransaction = myDF->OpenTransaction();
106 //=======================================================================
109 //=======================================================================
111 Handle(TDF_Delta) TDF_Transaction::Commit(const Standard_Boolean withDelta)
113 #ifdef DEB_TRANSACTION
114 cout<<"Transaction "<<myName<<" commits ";
116 Handle(TDF_Delta) delta;
118 #ifdef DEB_TRANSACTION
119 cout<<"from #"<<myDF->Transaction()<<" until #"<<myUntilTransaction<<" while current is #"<<myDF->Transaction()<<endl;
121 #ifdef DEB_TRANSACTION_DUMP
122 cout<<"DF before commit"<<endl;
123 TDF_Tool::DeepDump(cout,myDF);
125 Standard_Integer until = myUntilTransaction;
126 myUntilTransaction = 0;
127 delta = myDF->CommitUntilTransaction(until, withDelta);
128 #ifdef DEB_TRANSACTION_DUMP
129 cout<<"DF after commit"<<endl;
130 TDF_Tool::DeepDump(cout,myDF);
133 #ifdef DEB_TRANSACTION
134 else cout<<"but this transaction is not open!"<<endl;
140 //=======================================================================
143 //=======================================================================
145 void TDF_Transaction::Abort()
148 #ifdef DEB_TRANSACTION
149 cout<<"Transaction "<<myName<<" aborts from #"<<myDF->Transaction()<<" until #"<<myUntilTransaction<<" while current is #"<<myDF->Transaction()<<endl;
151 #ifdef DEB_TRANSACTION_DUMP
152 cout<<"DF before abort"<<endl;
153 TDF_Tool::DeepDump(cout,myDF);
155 myDF->AbortUntilTransaction(myUntilTransaction);
156 myUntilTransaction = 0;
157 #ifdef DEB_TRANSACTION_DUMP
158 cout<<"DF after abort"<<endl;
159 TDF_Tool::DeepDump(cout,myDF);