|
|
|||
Warning, file /include/opencascade/TDocStd_MultiTransactionManager.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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_ApplicationDelta.hxx> 0022 #include <NCollection_Sequence.hxx> 0023 #include <Standard_Integer.hxx> 0024 #include <Standard_Boolean.hxx> 0025 #include <Standard_Transient.hxx> 0026 #include <Standard_OStream.hxx> 0027 class TCollection_ExtendedString; 0028 class TDocStd_Document; 0029 0030 //! Class for synchronization of transactions within multiple documents. 0031 //! Each transaction of this class involvess one transaction in each modified document. 0032 //! 0033 //! The documents to be synchronized should be added explicitly to 0034 //! the manager; then its interface is used to ensure that all transactions 0035 //! (Open/Commit, Undo/Redo) are performed synchronously in all managed documents. 0036 //! 0037 //! The current implementation does not support nested transactions 0038 //! on multitransaction manager level. It only sets the flag enabling 0039 //! or disabling nested transactions in all its documents, so that 0040 //! a nested transaction can be opened for each particular document 0041 //! with TDocStd_Document class interface. 0042 //! 0043 //! NOTE: When you invoke CommitTransaction of multi transaction 0044 //! manager, all nested transaction of its documents will be closed (committed). 0045 class TDocStd_MultiTransactionManager : public Standard_Transient 0046 { 0047 0048 public: 0049 //! Constructor 0050 Standard_EXPORT TDocStd_MultiTransactionManager(); 0051 0052 //! Sets undo limit for the manager and all documents. 0053 Standard_EXPORT void SetUndoLimit(const int theLimit); 0054 0055 //! Returns undo limit for the manager. 0056 int GetUndoLimit() const; 0057 0058 //! Undoes the current transaction of the manager. 0059 //! It calls the Undo () method of the document being 0060 //! on top of the manager list of undos (list.First()) 0061 //! and moves the list item to the top of the list of manager 0062 //! redos (list.Prepend(item)). 0063 Standard_EXPORT void Undo(); 0064 0065 //! Redoes the current transaction of the application. It calls 0066 //! the Redo () method of the document being on top of the 0067 //! manager list of redos (list.First()) and moves the list 0068 //! item to the top of the list of manager undos (list.Prepend(item)). 0069 Standard_EXPORT void Redo(); 0070 0071 //! Returns available manager undos. 0072 const NCollection_Sequence<occ::handle<TDocStd_ApplicationDelta>>& GetAvailableUndos() const; 0073 0074 //! Returns available manager redos. 0075 const NCollection_Sequence<occ::handle<TDocStd_ApplicationDelta>>& GetAvailableRedos() const; 0076 0077 //! Opens transaction in each document and sets the flag that 0078 //! transaction is opened. If there are already opened transactions in the documents, 0079 //! these transactions will be aborted before opening new ones. 0080 Standard_EXPORT void OpenCommand(); 0081 0082 //! Unsets the flag of started manager transaction and aborts 0083 //! transaction in each document. 0084 Standard_EXPORT void AbortCommand(); 0085 0086 //! Commits transaction in all documents and fills the transaction manager 0087 //! with the documents that have been changed during the transaction. 0088 //! Returns True if new data has been added to myUndos. 0089 //! NOTE: All nested transactions in the documents will be committed. 0090 Standard_EXPORT bool CommitCommand(); 0091 0092 //! Makes the same steps as the previous function but defines the name for transaction. 0093 //! Returns True if new data has been added to myUndos. 0094 Standard_EXPORT bool CommitCommand(const TCollection_ExtendedString& theName); 0095 0096 //! Returns true if a transaction is opened. 0097 bool HasOpenCommand() const; 0098 0099 //! Removes undo information from the list of undos of the manager and 0100 //! all documents which have been modified during the transaction. 0101 Standard_EXPORT void RemoveLastUndo(); 0102 0103 //! Dumps transactions in undos and redos 0104 Standard_EXPORT void DumpTransaction(Standard_OStream& theOS) const; 0105 0106 //! Adds the document to the transaction manager and 0107 //! checks if it has been already added 0108 Standard_EXPORT void AddDocument(const occ::handle<TDocStd_Document>& theDoc); 0109 0110 //! Removes the document from the transaction manager. 0111 Standard_EXPORT void RemoveDocument(const occ::handle<TDocStd_Document>& theDoc); 0112 0113 //! Returns the added documents to the transaction manager. 0114 const NCollection_Sequence<occ::handle<TDocStd_Document>>& Documents() const; 0115 0116 //! Sets nested transaction mode if isAllowed == true 0117 //! NOTE: field myIsNestedTransactionMode exists only for synchronization 0118 //! between several documents and has no effect on transactions 0119 //! of multitransaction manager. 0120 Standard_EXPORT void SetNestedTransactionMode(const bool isAllowed = true); 0121 0122 //! Returns true if NestedTransaction mode is set. 0123 //! Methods for protection of changes outside transactions 0124 bool IsNestedTransactionMode() const; 0125 0126 //! If theTransactionOnly is True, denies all changes outside transactions. 0127 Standard_EXPORT void SetModificationMode(const bool theTransactionOnly); 0128 0129 //! Returns True if changes are allowed only inside transactions. 0130 bool ModificationMode() const; 0131 0132 //! Clears undos in the manager and in documents. 0133 Standard_EXPORT void ClearUndos(); 0134 0135 //! Clears redos in the manager and in documents. 0136 Standard_EXPORT void ClearRedos(); 0137 0138 DEFINE_STANDARD_RTTIEXT(TDocStd_MultiTransactionManager, Standard_Transient) 0139 0140 private: 0141 NCollection_Sequence<occ::handle<TDocStd_Document>> myDocuments; 0142 NCollection_Sequence<occ::handle<TDocStd_ApplicationDelta>> myUndos; 0143 NCollection_Sequence<occ::handle<TDocStd_ApplicationDelta>> myRedos; 0144 int myUndoLimit; 0145 bool myOpenTransaction; 0146 bool myIsNestedTransactionMode; 0147 bool myOnlyTransactionModification; 0148 }; 0149 0150 #include <TDocStd_MultiTransactionManager.lxx> 0151 0152 #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 |
|