|
||||
File indexing completed on 2025-01-18 10:05:21
0001 // Created on: 2002-11-18 0002 // Created by: Vladimir ANIKIN 0003 // Copyright (c) 2002-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 _TDocStd_MultiTransactionManager_HeaderFile 0017 #define _TDocStd_MultiTransactionManager_HeaderFile 0018 0019 #include <Standard.hxx> 0020 0021 #include <TDocStd_SequenceOfApplicationDelta.hxx> 0022 #include <Standard_Integer.hxx> 0023 #include <Standard_Boolean.hxx> 0024 #include <Standard_Transient.hxx> 0025 #include <Standard_OStream.hxx> 0026 class TCollection_ExtendedString; 0027 class TDocStd_Document; 0028 0029 0030 class TDocStd_MultiTransactionManager; 0031 DEFINE_STANDARD_HANDLE(TDocStd_MultiTransactionManager, Standard_Transient) 0032 0033 //! Class for synchronization of transactions within multiple documents. 0034 //! Each transaction of this class involvess one transaction in each modified document. 0035 //! 0036 //! The documents to be synchronized should be added explicitly to 0037 //! the manager; then its interface is used to ensure that all transactions 0038 //! (Open/Commit, Undo/Redo) are performed synchronously in all managed documents. 0039 //! 0040 //! The current implementation does not support nested transactions 0041 //! on multitransaction manager level. It only sets the flag enabling 0042 //! or disabling nested transactions in all its documents, so that 0043 //! a nested transaction can be opened for each particular document 0044 //! with TDocStd_Document class interface. 0045 //! 0046 //! NOTE: When you invoke CommitTransaction of multi transaction 0047 //! manager, all nested transaction of its documents will be closed (committed). 0048 class TDocStd_MultiTransactionManager : public Standard_Transient 0049 { 0050 0051 public: 0052 0053 0054 //! Constructor 0055 Standard_EXPORT TDocStd_MultiTransactionManager(); 0056 0057 //! Sets undo limit for the manager and all documents. 0058 Standard_EXPORT void SetUndoLimit (const Standard_Integer theLimit); 0059 0060 //! Returns undo limit for the manager. 0061 Standard_Integer GetUndoLimit() const; 0062 0063 //! Undoes the current transaction of the manager. 0064 //! It calls the Undo () method of the document being 0065 //! on top of the manager list of undos (list.First()) 0066 //! and moves the list item to the top of the list of manager 0067 //! redos (list.Prepend(item)). 0068 Standard_EXPORT void Undo(); 0069 0070 //! Redoes the current transaction of the application. It calls 0071 //! the Redo () method of the document being on top of the 0072 //! manager list of redos (list.First()) and moves the list 0073 //! item to the top of the list of manager undos (list.Prepend(item)). 0074 Standard_EXPORT void Redo(); 0075 0076 //! Returns available manager undos. 0077 const TDocStd_SequenceOfApplicationDelta& GetAvailableUndos() const; 0078 0079 //! Returns available manager redos. 0080 const TDocStd_SequenceOfApplicationDelta& GetAvailableRedos() const; 0081 0082 //! Opens transaction in each document and sets the flag that 0083 //! transaction is opened. If there are already opened transactions in the documents, 0084 //! these transactions will be aborted before opening new ones. 0085 Standard_EXPORT void OpenCommand(); 0086 0087 //! Unsets the flag of started manager transaction and aborts 0088 //! transaction in each document. 0089 Standard_EXPORT void AbortCommand(); 0090 0091 //! Commits transaction in all documents and fills the transaction manager 0092 //! with the documents that have been changed during the transaction. 0093 //! Returns True if new data has been added to myUndos. 0094 //! NOTE: All nested transactions in the documents will be committed. 0095 Standard_EXPORT Standard_Boolean CommitCommand(); 0096 0097 //! Makes the same steps as the previous function but defines the name for transaction. 0098 //! Returns True if new data has been added to myUndos. 0099 Standard_EXPORT Standard_Boolean CommitCommand (const TCollection_ExtendedString& theName); 0100 0101 //! Returns true if a transaction is opened. 0102 Standard_Boolean HasOpenCommand() const; 0103 0104 //! Removes undo information from the list of undos of the manager and 0105 //! all documents which have been modified during the transaction. 0106 Standard_EXPORT void RemoveLastUndo(); 0107 0108 //! Dumps transactions in undos and redos 0109 Standard_EXPORT void DumpTransaction (Standard_OStream& theOS) const; 0110 0111 //! Adds the document to the transaction manager and 0112 //! checks if it has been already added 0113 Standard_EXPORT void AddDocument (const Handle(TDocStd_Document)& theDoc); 0114 0115 //! Removes the document from the transaction manager. 0116 Standard_EXPORT void RemoveDocument (const Handle(TDocStd_Document)& theDoc); 0117 0118 //! Returns the added documents to the transaction manager. 0119 const TDocStd_SequenceOfDocument& Documents() const; 0120 0121 //! Sets nested transaction mode if isAllowed == Standard_True 0122 //! NOTE: field myIsNestedTransactionMode exists only for synchronization 0123 //! between several documents and has no effect on transactions 0124 //! of multitransaction manager. 0125 Standard_EXPORT void SetNestedTransactionMode (const Standard_Boolean isAllowed = Standard_True); 0126 0127 //! Returns Standard_True if NestedTransaction mode is set. 0128 //! Methods for protection of changes outside transactions 0129 Standard_Boolean IsNestedTransactionMode() const; 0130 0131 //! If theTransactionOnly is True, denies all changes outside transactions. 0132 Standard_EXPORT void SetModificationMode (const Standard_Boolean theTransactionOnly); 0133 0134 //! Returns True if changes are allowed only inside transactions. 0135 Standard_Boolean ModificationMode() const; 0136 0137 //! Clears undos in the manager and in documents. 0138 Standard_EXPORT void ClearUndos(); 0139 0140 //! Clears redos in the manager and in documents. 0141 Standard_EXPORT void ClearRedos(); 0142 0143 0144 0145 0146 DEFINE_STANDARD_RTTIEXT(TDocStd_MultiTransactionManager,Standard_Transient) 0147 0148 protected: 0149 0150 0151 0152 0153 private: 0154 0155 0156 TDocStd_SequenceOfDocument myDocuments; 0157 TDocStd_SequenceOfApplicationDelta myUndos; 0158 TDocStd_SequenceOfApplicationDelta myRedos; 0159 Standard_Integer myUndoLimit; 0160 Standard_Boolean myOpenTransaction; 0161 Standard_Boolean myIsNestedTransactionMode; 0162 Standard_Boolean myOnlyTransactionModification; 0163 0164 0165 }; 0166 0167 0168 #include <TDocStd_MultiTransactionManager.lxx> 0169 0170 0171 0172 0173 0174 #endif // _TDocStd_MultiTransactionManager_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |