1 -- Created on: 2002-11-18
2 -- Created by: Vladimir ANIKIN
3 -- Copyright (c) 2002-2012 OPEN CASCADE SAS
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.
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.
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.
22 class MultiTransactionManager from TDocStd inherits TShared from MMgt
24 ---Purpose: Class for synchronization of transactions within multiple documents.
25 -- Each transaction of this class involvess one transaction in each modified document.
27 -- The documents to be synchronized should be added explicitly to
28 -- the manager; then its interface is uesd to ensure that all transactions
29 -- (Open/Commit, Undo/Redo) are performed synchronously in all managed documents.
31 -- The current implementation does not support nested transactions
32 -- on multitransaction manager level. It only sets the flag enabling
33 -- or disabling nested transactions in all its documents, so that
34 -- a nested transaction can be opened for each particular document
35 -- with TDocStd_Document class interface.
37 -- NOTE: When you invoke CommitTransaction of multi transaction
38 -- manager, all nested transaction of its documents will be closed (commited).
40 uses SequenceOfApplicationDelta from TDocStd,
41 ExtendedString from TCollection,
42 Document from TDocStd,
43 SequenceOfDocument from TDocStd
47 Create returns MultiTransactionManager from TDocStd;
48 ---Purpose: Constructor
50 SetUndoLimit (me : mutable;
51 theLimit : Integer from Standard);
52 ---Purpose: Sets undo limit for the manager and all documents.
55 returns Integer from Standard;
56 ---Purpose: Returns undo limit for the manager.
61 ---Purpose: Undoes the current transaction of the manager.
62 -- It calls the Undo () method of the document being
63 -- on top of the manager list of undos (list.First())
64 -- and moves the list item to the top of the list of manager
65 -- redos (list.Prepend(item)).
68 ---Purpose: Redoes the current transaction of the application. It calls
69 -- the Redo () method of the document being on top of the
70 -- manager list of redos (list.First()) and moves the list
71 -- item to the top of the list of manager undos (list.Prepend(item)).
73 GetAvailableUndos (me)
74 returns SequenceOfApplicationDelta from TDocStd;
75 ---Purpose: Returns available manager undos.
77 ---C++: return const &
79 GetAvailableRedos (me)
80 returns SequenceOfApplicationDelta from TDocStd;
81 ---Purpose: Returns available manager redos.
83 ---C++: return const &
85 OpenCommand (me : mutable);
86 ---Purpose: Opens transaction in each document and sets the flag that
87 -- transaction is opened. If there are already opened transactions in the documents,
88 -- these transactions will be aborted before openning new ones.
90 AbortCommand (me : mutable);
91 ---Purpose: Unsets the flag of started manager transaction and aborts
92 -- transaction in each document.
94 CommitCommand (me : mutable) returns Boolean;
95 ---Purpose: Commits transaction in all documents and fills the transaction manager
96 -- with the documents that have been changed during the transaction.
97 -- Returns True if new data has been added to myUndos.
98 -- NOTE: All nested transactions in the documents will be commited.
100 CommitCommand (me : mutable;
101 theName : ExtendedString from TCollection) returns Boolean;
102 ---Purpose: Makes the same steps as the previous function but defines the name for transaction.
103 -- Returns True if new data has been added to myUndos.
106 returns Boolean from Standard;
107 ---Purpose: Returns true if a transaction is opened.
110 RemoveLastUndo (me : mutable);
111 ---Purpose: Removes undo information from the list of undos of the manager and
112 -- all documents which have been modified during the transaction.
114 DumpTransaction(me; theOS : in out OStream from Standard);
115 ---Purpose: Dumps transactions in undos and redos
117 AddDocument(me : mutable; theDoc : Document from TDocStd);
118 ---Purpose: Adds the document to the transaction manager and
119 -- checks if it has been already added
121 RemoveDocument(me : mutable; theDoc : Document from TDocStd);
122 ---Purpose: Removes the document from the transaction manager.
124 Documents(me) returns SequenceOfDocument from TDocStd;
125 ---Purpose: Returns the added documents to the transaction manager.
127 ---C++: return const &
129 SetNestedTransactionMode(me : mutable; isAllowed : Boolean = Standard_True);
130 ---Purpose: Sets nested transaction mode if isAllowed == Standard_True
131 -- NOTE: field myIsNestedTransactionMode exists only for synchronization
132 -- between several documents and has no effect on transactions
133 -- of multitransaction manager.
135 IsNestedTransactionMode (me)
136 returns Boolean from Standard;
137 ---Purpose: Returns Standard_True if NestedTransaction mode is set.
140 ---Purpose: Methods for protection of changes outside transactions
142 SetModificationMode (me : mutable; theTransactionOnly : Boolean from Standard);
143 ---Purpose: If theTransactionOnly is True, denies all changes outside transactions.
145 ModificationMode (me) returns Boolean from Standard;
146 ---Purpose: Returns True if changes are allowed only inside transactions.
149 ClearUndos (me : mutable);
150 ---Purpose: Clears undos in the manager and in documents.
152 ClearRedos (me : mutable);
153 ---Purpose: Clears redos in the manager and in documents.
157 ---Purpose: Data framework
159 myDocuments : SequenceOfDocument from TDocStd;
160 myUndos : SequenceOfApplicationDelta from TDocStd;
161 myRedos : SequenceOfApplicationDelta from TDocStd;
162 myUndoLimit : Integer from Standard;
163 myOpenTransaction : Boolean from Standard;
165 ---Purpose: A flag for nested transaction mode.
167 myIsNestedTransactionMode : Boolean from Standard;
169 ---Purpose: Data for protection of changes outside transactions.
171 myOnlyTransactionModification : Boolean from Standard;
173 end MultiTransactionManager;