0023002: empty delete operator in TDF_LabelNode
[occt.git] / src / TDF / TDF_Transaction.cxx
1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 //
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.
9 //
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.
12 //
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.
19
20 //              -------------------
21
22 // Version:     0.0
23 //Version       Date            Purpose
24 //              0.0     Oct  1 1997     Creation
25
26
27
28 #include <TDF_Transaction.ixx>
29
30 #undef DEB_TRANSACTION
31 #ifdef DEB
32 #define DEB_TRANSACTION
33 #endif
34 #undef DEB_TRANSACTION_DUMP
35
36 #include <TDF_Tool.hxx>
37
38 //=======================================================================
39 //function : TDF_Transaction
40 //purpose  : 
41 //=======================================================================
42
43 TDF_Transaction::TDF_Transaction
44 (const TCollection_AsciiString& aName)
45 : myUntilTransaction(0),
46   myName(aName)
47 {}
48
49
50 //=======================================================================
51 //function : TDF_Transaction
52 //purpose  : Private copy constructor.
53 //=======================================================================
54
55 TDF_Transaction::TDF_Transaction(const TDF_Transaction& aTrans)
56 {}
57
58
59 //=======================================================================
60 //function : TDF_Transaction
61 //purpose  : 
62 //=======================================================================
63
64 TDF_Transaction::TDF_Transaction
65 (const Handle(TDF_Data)& aDF,
66  const TCollection_AsciiString& aName)
67 : myDF(aDF),
68   myUntilTransaction(0),
69   myName(aName)
70 {}
71
72
73
74
75 //=======================================================================
76 //function : Initialize
77 //purpose  : Initializes a transaction ready to be opened.
78 //=======================================================================
79
80 void TDF_Transaction::Initialize(const Handle(TDF_Data)& aDF)
81 {
82   if (IsOpen()) myDF->AbortUntilTransaction(myUntilTransaction);
83   myDF = aDF;
84   myUntilTransaction = 0;
85 }
86
87
88 //=======================================================================
89 //function : Open
90 //purpose  : 
91 //=======================================================================
92
93 Standard_Integer TDF_Transaction::Open()
94 {
95 #ifdef DEB_TRANSACTION
96   cout<<"Transaction "<<myName<<" opens #"<<myDF->Transaction()+1<<endl;
97 #endif
98   if (IsOpen())
99     Standard_DomainError::Raise("This transaction is already open.");
100   if (myDF.IsNull())
101     Standard_NullObject::Raise("Null TDF_Data.");
102   return myUntilTransaction = myDF->OpenTransaction();
103 }
104
105
106 //=======================================================================
107 //function : Commit
108 //purpose  : 
109 //=======================================================================
110
111 Handle(TDF_Delta) TDF_Transaction::Commit(const Standard_Boolean withDelta)
112 {
113 #ifdef DEB_TRANSACTION
114   cout<<"Transaction "<<myName<<" commits ";
115 #endif
116   Handle(TDF_Delta) delta;
117   if (IsOpen()) {
118 #ifdef DEB_TRANSACTION
119     cout<<"from #"<<myDF->Transaction()<<" until #"<<myUntilTransaction<<" while current is #"<<myDF->Transaction()<<endl;
120 #endif
121 #ifdef DEB_TRANSACTION_DUMP
122     cout<<"DF before commit"<<endl;
123     TDF_Tool::DeepDump(cout,myDF);
124 #endif
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);
131 #endif
132   }
133 #ifdef DEB_TRANSACTION
134   else cout<<"but this transaction is not open!"<<endl;
135 #endif
136   return delta;
137 }
138
139
140 //=======================================================================
141 //function : Abort
142 //purpose  : alias ~
143 //=======================================================================
144
145 void TDF_Transaction::Abort()
146 {
147   if (IsOpen()) {
148 #ifdef DEB_TRANSACTION
149     cout<<"Transaction "<<myName<<" aborts from #"<<myDF->Transaction()<<" until #"<<myUntilTransaction<<" while current is #"<<myDF->Transaction()<<endl;
150 #endif
151 #ifdef DEB_TRANSACTION_DUMP
152     cout<<"DF before abort"<<endl;
153     TDF_Tool::DeepDump(cout,myDF);
154 #endif
155     myDF->AbortUntilTransaction(myUntilTransaction);
156     myUntilTransaction = 0;
157 #ifdef DEB_TRANSACTION_DUMP
158     cout<<"DF after abort"<<endl;
159     TDF_Tool::DeepDump(cout,myDF);
160 #endif
161   }
162 }
163