summaryrefslogtreecommitdiff
path: root/inc/TDF_Data.hxx
blob: e4839d5a6e77e8ced78547fb3ef0ce456c9da8a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to 
// this header file considered to be the "object code" form of the original source.

#ifndef _TDF_Data_HeaderFile
#define _TDF_Data_HeaderFile

#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_DefineHandle_HeaderFile
#include <Standard_DefineHandle.hxx>
#endif
#ifndef _Handle_TDF_Data_HeaderFile
#include <Handle_TDF_Data.hxx>
#endif

#ifndef _TDF_LabelNodePtr_HeaderFile
#include <TDF_LabelNodePtr.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _TColStd_StackOfInteger_HeaderFile
#include <TColStd_StackOfInteger.hxx>
#endif
#ifndef _TDF_HAllocator_HeaderFile
#include <TDF_HAllocator.hxx>
#endif
#ifndef _MMgt_TShared_HeaderFile
#include <MMgt_TShared.hxx>
#endif
#ifndef _TDF_Label_HeaderFile
#include <TDF_Label.hxx>
#endif
#ifndef _Handle_TDF_Delta_HeaderFile
#include <Handle_TDF_Delta.hxx>
#endif
#ifndef _Standard_OStream_HeaderFile
#include <Standard_OStream.hxx>
#endif
class Standard_NoMoreObject;
class TDF_Transaction;
class TDF_LabelNode;
class TDF_Delta;
class TDF_Label;


//! This class is used to manipulate a complete <br>
//!          independant, self sufficient data structure and <br>
//!          its services: <br>
//! <br>
//!          Access to the root label; <br>
//! <br>
//!          Opens, aborts, commits a transaction; <br>
//! <br>
//!          Generation and use of Delta, depending on the time. <br>
//! This class uses a special allocator <br>
//! (see LabelNodeAllocator() method) <br>
//!  for more efficient allocation of <br>
//!  objects in memory. <br>
class TDF_Data : public MMgt_TShared {

public:

  //! A new and empty Data structure. <br>
  Standard_EXPORT   TDF_Data();
  //! Returns the root label of the Data structure. <br>
//! <br>
       const TDF_Label Root() const;
  //! Returns the current transaction number. <br>
  Standard_EXPORT     Standard_Integer Transaction() const;
  //! Returns the current tick. It is incremented each Commit. <br>
//! <br>
        Standard_Integer Time() const;
  //! Returns true if <aDelta> is applicable HERE and NOW. <br>
  Standard_EXPORT     Standard_Boolean IsApplicable(const Handle(TDF_Delta)& aDelta) const;
  //! Apply <aDelta> to undo a set of attribute <br>
//!          modifications. <br>
//! <br>
//!          Optionnal <withDelta> set to True indiquates a <br>
//!          Delta Set must be generated. (See above) <br>
  Standard_EXPORT     Handle_TDF_Delta Undo(const Handle(TDF_Delta)& aDelta,const Standard_Boolean withDelta = Standard_False) ;
  
  Standard_EXPORT     void Destroy() ;
~TDF_Data()
{
  Destroy();
}
  //! Returns the undo mode status. <br>
//! <br>
        Standard_Boolean NotUndoMode() const;
  //! Dumps the Data on <aStream>. <br>
//! <br>
  Standard_EXPORT     Standard_OStream& Dump(Standard_OStream& anOS) const;
    Standard_OStream& operator<<(Standard_OStream& anOS) const
{
  return Dump(anOS);
}
  //! Sets modification mode. <br>
//! <br>
        void AllowModification(const Standard_Boolean isAllowed) ;
  //! returns modification mode. <br>
//! <br>
        Standard_Boolean IsModificationAllowed() const;
  //! Returns TDF_HAllocator, which is an <br>
//! incremental allocator used by <br>
//! TDF_LabelNode. <br>
//!      This allocator is used to <br>
//!      manage TDF_LabelNode objects, <br>
//!      but it can also be used for <br>
//!      allocating memory to <br>
//!      application-specific data (be <br>
//!      careful because this <br>
//!      allocator does not release <br>
//!      the memory). <br>
//!      The benefits of this <br>
//!      allocation scheme are <br>
//!      noticeable when dealing with <br>
//!      large OCAF documents, due to: <br>
//! 1.    Very quick allocation of <br>
//!   objects (memory heap is not <br>
//!   used, the algorithm that <br>
//!   replaces it is very simple). <br>
//! 2.    Very quick destruction of <br>
//!   objects (memory is released not <br>
//!   by destructors of TDF_LabelNode, <br>
//!   but rather by the destructor of <br>
//!   TDF_Data). <br>
//! 3.  TDF_LabelNode objects do not <br>
//!   fragmentize the memory; they are <br>
//!   kept compactly in a number of <br>
//!   arrays of 16K each. <br>
//! 4.    Swapping is reduced on large <br>
//!   data, because each document now <br>
//!   occupies a smaller number of <br>
//!   memory pages. <br>
       const TDF_HAllocator& LabelNodeAllocator() const;

friend class TDF_Transaction;
friend class TDF_LabelNode;


  DEFINE_STANDARD_RTTI(TDF_Data)

protected:




private: 

  //! Increments the transaction number and returns it. <br>
  Standard_EXPORT     Standard_Integer OpenTransaction() ;
  //! Decrements the transaction number and commits the <br>
//!          modifications. <br>
//! <br>
//!          Raises if there is no current transaction. <br>
//! <br>
//!          Optionnal <withDelta> set to True indiquates a <br>
//!          Delta must be generated. <br>
  Standard_EXPORT     Handle_TDF_Delta CommitTransaction(const Standard_Boolean withDelta = Standard_False) ;
  //! Decrements the transaction number and commits the <br>
//!          modifications until AND including the transaction <br>
//!          <untilTransaction>. <br>
  Standard_EXPORT     Handle_TDF_Delta CommitUntilTransaction(const Standard_Integer untilTransaction,const Standard_Boolean withDelta = Standard_False) ;
  //! Decrements the transaction number and forgets the <br>
//!          modifications. <br>
//! <br>
//!          Raises if there is no current transaction. <br>
  Standard_EXPORT     void AbortTransaction() ;
  //! Decrements the transaction number and forgets the <br>
//!          modifications until AND including the transaction <br>
//!          <untilTransaction>. <br>
  Standard_EXPORT     void AbortUntilTransaction(const Standard_Integer untilTransaction) ;
  //! Decrements the transaction number and commits the <br>
//!          modifications. Used to implement the recursif <br>
//!          commit process. The returned boolean says how many <br>
//!          attributes (new, modified or deleted) has been <br>
//!          committed from the previous transaction into the <br>
//!          current one. <br>
  Standard_EXPORT     Standard_Integer CommitTransaction(const TDF_Label& aLabel,const Handle(TDF_Delta)& aDelta,const Standard_Boolean withDelta) ;

TDF_LabelNodePtr myRoot;
Standard_Integer myTransaction;
Standard_Integer myNbTouchedAtt;
Standard_Boolean myNotUndoMode;
Standard_Integer myTime;
TColStd_StackOfInteger myTimes;
TDF_HAllocator myLabelNodeAllocator;
Standard_Boolean myAllowModification;


};


#include <TDF_Data.lxx>



// other Inline functions and methods (like "C++: function call" methods)


#endif