|
|
|||
File indexing completed on 2026-09-28 09:21:56
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_Data_HeaderFile 0017 #define _TDF_Data_HeaderFile 0018 0019 #include <Standard.hxx> 0020 #include <Standard_Type.hxx> 0021 0022 #include <TDF_LabelNodePtr.hxx> 0023 #include <Standard_Integer.hxx> 0024 #include <NCollection_List.hxx> 0025 #include <TDF_HAllocator.hxx> 0026 #include <Standard_Transient.hxx> 0027 #include <TDF_Label.hxx> 0028 #include <Standard_OStream.hxx> 0029 #include <NCollection_DataMap.hxx> 0030 class TDF_Delta; 0031 class TDF_Label; 0032 0033 //! This class is used to manipulate a complete independent, 0034 //! self sufficient data structure and its services: 0035 //! 0036 //! Access to the root label; 0037 //! 0038 //! Opens, aborts, commits a transaction; 0039 //! 0040 //! Generation and use of Delta, depending on the time. 0041 //! This class uses a special allocator 0042 //! (see LabelNodeAllocator() method) 0043 //! for more efficient allocation of objects in memory. 0044 class TDF_Data : public Standard_Transient 0045 { 0046 0047 public: 0048 //! A new and empty Data structure. 0049 Standard_EXPORT TDF_Data(); 0050 0051 //! Returns the root label of the Data structure. 0052 const TDF_Label Root() const; 0053 0054 //! Returns the current transaction number. 0055 int Transaction() const; 0056 0057 //! Returns the current tick. It is incremented each Commit. 0058 int Time() const; 0059 0060 //! Returns true if <aDelta> is applicable HERE and NOW. 0061 Standard_EXPORT bool IsApplicable(const occ::handle<TDF_Delta>& aDelta) const; 0062 0063 //! Apply <aDelta> to undo a set of attribute modifications. 0064 //! 0065 //! Optional <withDelta> set to True indicates a 0066 //! Delta Set must be generated. (See above) 0067 Standard_EXPORT occ::handle<TDF_Delta> Undo(const occ::handle<TDF_Delta>& aDelta, 0068 const bool withDelta = false); 0069 0070 Standard_EXPORT void Destroy(); 0071 0072 ~TDF_Data() override { Destroy(); } 0073 0074 //! Returns the undo mode status. 0075 bool NotUndoMode() const; 0076 0077 //! Dumps the Data on <aStream>. 0078 Standard_EXPORT Standard_OStream& Dump(Standard_OStream& anOS) const; 0079 0080 Standard_OStream& operator<<(Standard_OStream& anOS) const { return Dump(anOS); } 0081 0082 //! Sets modification mode. 0083 void AllowModification(const bool isAllowed); 0084 0085 //! returns modification mode. 0086 bool IsModificationAllowed() const; 0087 0088 //! Initializes a mechanism for fast access to the labels by their entries. 0089 //! The fast access is useful for large documents and often access to the labels 0090 //! via entries. Internally, a table of entry - label is created, 0091 //! which allows to obtain a label by its entry in a very fast way. 0092 //! If the mechanism is turned off, the internal table is cleaned. 0093 //! New labels are added to the table, if the mechanism is on 0094 //! (no need to re-initialize the mechanism). 0095 Standard_EXPORT void SetAccessByEntries(const bool aSet); 0096 0097 //! Returns a status of mechanism for fast access to the labels via entries. 0098 bool IsAccessByEntries() const { return myAccessByEntries; } 0099 0100 //! Returns a label by an entry. 0101 //! Returns false, if such a label doesn't exist 0102 //! or mechanism for fast access to the label by entry is not initialized. 0103 bool GetLabel(const TCollection_AsciiString& anEntry, TDF_Label& aLabel) 0104 { 0105 return myAccessByEntriesTable.Find(anEntry, aLabel); 0106 } 0107 0108 //! An internal method. It is used internally on creation of new labels. 0109 //! It adds a new label into internal table for fast access to the labels by entry. 0110 Standard_EXPORT void RegisterLabel(const TDF_Label& aLabel); 0111 0112 //! Returns TDF_HAllocator, which is an 0113 //! incremental allocator used by 0114 //! TDF_LabelNode. 0115 //! This allocator is used to 0116 //! manage TDF_LabelNode objects, 0117 //! but it can also be used for 0118 //! allocating memory to 0119 //! application-specific data (be 0120 //! careful because this 0121 //! allocator does not release 0122 //! the memory). 0123 //! The benefits of this 0124 //! allocation scheme are 0125 //! noticeable when dealing with 0126 //! large OCAF documents, due to: 0127 //! 1. Very quick allocation of 0128 //! objects (memory heap is not 0129 //! used, the algorithm that 0130 //! replaces it is very simple). 0131 //! 2. Very quick destruction of 0132 //! objects (memory is released not 0133 //! by destructors of TDF_LabelNode, 0134 //! but rather by the destructor of 0135 //! TDF_Data). 0136 //! 3. TDF_LabelNode objects do not 0137 //! fragmentize the memory; they are 0138 //! kept compactly in a number of 0139 //! arrays of 16K each. 0140 //! 4. Swapping is reduced on large 0141 //! data, because each document now 0142 //! occupies a smaller number of 0143 //! memory pages. 0144 const TDF_HAllocator& LabelNodeAllocator() const; 0145 0146 //! Dumps the content of me into the stream 0147 Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const; 0148 0149 friend class TDF_Transaction; 0150 friend class TDF_LabelNode; 0151 0152 DEFINE_STANDARD_RTTIEXT(TDF_Data, Standard_Transient) 0153 0154 private: 0155 //! Fixes order of Attributes' Deltas to perform undo/redo without exceptions: 0156 //! puts OnRemoval deltas to the end of the list. 0157 void FixOrder(const occ::handle<TDF_Delta>& theDelta); 0158 0159 //! Increments the transaction number and returns it. 0160 Standard_EXPORT int OpenTransaction(); 0161 0162 //! Decrements the transaction number and commits the 0163 //! modifications. 0164 //! 0165 //! Raises if there is no current transaction. 0166 //! 0167 //! Optional <withDelta> set to True indicates a 0168 //! Delta must be generated. 0169 Standard_EXPORT occ::handle<TDF_Delta> CommitTransaction(const bool withDelta = false); 0170 0171 //! Decrements the transaction number and commits the 0172 //! modifications until AND including the transaction 0173 //! <untilTransaction>. 0174 Standard_EXPORT occ::handle<TDF_Delta> CommitUntilTransaction(const int untilTransaction, 0175 const bool withDelta = false); 0176 0177 //! Decrements the transaction number and forgets the 0178 //! modifications. 0179 //! 0180 //! Raises if there is no current transaction. 0181 Standard_EXPORT void AbortTransaction(); 0182 0183 //! Decrements the transaction number and forgets the 0184 //! modifications until AND including the transaction 0185 //! <untilTransaction>. 0186 Standard_EXPORT void AbortUntilTransaction(const int untilTransaction); 0187 0188 //! Decrements the transaction number and commits the 0189 //! modifications. Used to implement the recursif 0190 //! commit process. The returned boolean says how many 0191 //! attributes (new, modified or deleted) has been 0192 //! committed from the previous transaction into the 0193 //! current one. 0194 Standard_EXPORT int CommitTransaction(const TDF_Label& aLabel, 0195 const occ::handle<TDF_Delta>& aDelta, 0196 const bool withDelta); 0197 0198 TDF_LabelNodePtr myRoot; 0199 int myTransaction; 0200 int myNbTouchedAtt; 0201 bool myNotUndoMode; 0202 int myTime; 0203 NCollection_List<int> myTimes; 0204 TDF_HAllocator myLabelNodeAllocator; 0205 bool myAllowModification; 0206 bool myAccessByEntries; 0207 NCollection_DataMap<TCollection_AsciiString, TDF_Label> myAccessByEntriesTable; 0208 }; 0209 0210 #include <TDF_Data.lxx> 0211 0212 #endif // _TDF_Data_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|