7fd59977 |
1 | -- File: TDocStd_MultiTransactionManager.cdl |
2 | -- Created: Mon Nov 18 17:52:55 2002 |
3 | -- Author: Vladimir ANIKIN |
4 | -- <van@matrox.nnov.matra-dtv.fr> |
5 | ---Copyright: Matra Datavision 2002 |
6 | |
7 | |
8 | class MultiTransactionManager from TDocStd inherits TShared from MMgt |
9 | |
10 | ---Purpose: Class for synchronization of transactions within multiple documents. |
11 | -- Each transaction of this class involvess one transaction in each modified document. |
12 | -- |
13 | -- The documents to be synchronized should be added explicitly to |
14 | -- the manager; then its interface is uesd to ensure that all transactions |
15 | -- (Open/Commit, Undo/Redo) are performed synchronously in all managed documents. |
16 | -- |
17 | -- The current implementation does not support nested transactions |
18 | -- on multitransaction manager level. It only sets the flag enabling |
19 | -- or disabling nested transactions in all its documents, so that |
20 | -- a nested transaction can be opened for each particular document |
21 | -- with TDocStd_Document class interface. |
22 | -- |
23 | -- NOTE: When you invoke CommitTransaction of multi transaction |
24 | -- manager, all nested transaction of its documents will be closed (commited). |
25 | |
26 | uses SequenceOfApplicationDelta from TDocStd, |
27 | ExtendedString from TCollection, |
28 | Document from TDocStd, |
29 | SequenceOfDocument from TDocStd |
30 | |
31 | is |
32 | |
33 | Create returns MultiTransactionManager from TDocStd; |
34 | ---Purpose: Constructor |
35 | |
36 | SetUndoLimit (me : mutable; |
37 | theLimit : Integer from Standard); |
38 | ---Purpose: Sets undo limit for the manager and all documents. |
39 | |
40 | GetUndoLimit (me) |
41 | returns Integer from Standard; |
42 | ---Purpose: Returns undo limit for the manager. |
43 | ---C++: inline |
44 | |
45 | |
46 | Undo (me : mutable); |
47 | ---Purpose: Undoes the current transaction of the manager. |
48 | -- It calls the Undo () method of the document being |
49 | -- on top of the manager list of undos (list.First()) |
50 | -- and moves the list item to the top of the list of manager |
51 | -- redos (list.Prepend(item)). |
52 | |
53 | Redo (me : mutable); |
54 | ---Purpose: Redoes the current transaction of the application. It calls |
55 | -- the Redo () method of the document being on top of the |
56 | -- manager list of redos (list.First()) and moves the list |
57 | -- item to the top of the list of manager undos (list.Prepend(item)). |
58 | |
59 | GetAvailableUndos (me) |
60 | returns SequenceOfApplicationDelta from TDocStd; |
61 | ---Purpose: Returns available manager undos. |
62 | ---C++: inline |
63 | ---C++: return const & |
64 | |
65 | GetAvailableRedos (me) |
66 | returns SequenceOfApplicationDelta from TDocStd; |
67 | ---Purpose: Returns available manager redos. |
68 | ---C++: inline |
69 | ---C++: return const & |
70 | |
71 | OpenCommand (me : mutable); |
72 | ---Purpose: Opens transaction in each document and sets the flag that |
73 | -- transaction is opened. If there are already opened transactions in the documents, |
74 | -- these transactions will be aborted before openning new ones. |
75 | |
76 | AbortCommand (me : mutable); |
77 | ---Purpose: Unsets the flag of started manager transaction and aborts |
78 | -- transaction in each document. |
79 | |
80 | CommitCommand (me : mutable) returns Boolean; |
81 | ---Purpose: Commits transaction in all documents and fills the transaction manager |
82 | -- with the documents that have been changed during the transaction. |
83 | -- Returns True if new data has been added to myUndos. |
84 | -- NOTE: All nested transactions in the documents will be commited. |
85 | |
86 | CommitCommand (me : mutable; |
87 | theName : ExtendedString from TCollection) returns Boolean; |
88 | ---Purpose: Makes the same steps as the previous function but defines the name for transaction. |
89 | -- Returns True if new data has been added to myUndos. |
90 | |
91 | HasOpenCommand (me) |
92 | returns Boolean from Standard; |
93 | ---Purpose: Returns true if a transaction is opened. |
94 | ---C++: inline |
95 | |
96 | RemoveLastUndo (me : mutable); |
97 | ---Purpose: Removes undo information from the list of undos of the manager and |
98 | -- all documents which have been modified during the transaction. |
99 | |
100 | DumpTransaction(me; theOS : in out OStream from Standard); |
101 | ---Purpose: Dumps transactions in undos and redos |
102 | |
103 | AddDocument(me : mutable; theDoc : Document from TDocStd); |
104 | ---Purpose: Adds the document to the transaction manager and |
105 | -- checks if it has been already added |
106 | |
107 | RemoveDocument(me : mutable; theDoc : Document from TDocStd); |
108 | ---Purpose: Removes the document from the transaction manager. |
109 | |
110 | Documents(me) returns SequenceOfDocument from TDocStd; |
111 | ---Purpose: Returns the added documents to the transaction manager. |
112 | ---C++: inline |
113 | ---C++: return const & |
114 | |
115 | SetNestedTransactionMode(me : mutable; isAllowed : Boolean = Standard_True); |
116 | ---Purpose: Sets nested transaction mode if isAllowed == Standard_True |
117 | -- NOTE: field myIsNestedTransactionMode exists only for synchronization |
118 | -- between several documents and has no effect on transactions |
119 | -- of multitransaction manager. |
120 | |
121 | IsNestedTransactionMode (me) |
122 | returns Boolean from Standard; |
123 | ---Purpose: Returns Standard_True if NestedTransaction mode is set. |
124 | ---C++: inline |
125 | |
126 | ---Purpose: Methods for protection of changes outside transactions |
127 | |
128 | SetModificationMode (me : mutable; theTransactionOnly : Boolean from Standard); |
129 | ---Purpose: If theTransactionOnly is True, denies all changes outside transactions. |
130 | |
131 | ModificationMode (me) returns Boolean from Standard; |
132 | ---Purpose: Returns True if changes are allowed only inside transactions. |
133 | ---C++: inline |
134 | |
135 | ClearUndos (me : mutable); |
136 | ---Purpose: Clears undos in the manager and in documents. |
137 | |
138 | ClearRedos (me : mutable); |
139 | ---Purpose: Clears redos in the manager and in documents. |
140 | |
141 | fields |
142 | |
143 | ---Purpose: Data framework |
144 | |
145 | myDocuments : SequenceOfDocument from TDocStd; |
146 | myUndos : SequenceOfApplicationDelta from TDocStd; |
147 | myRedos : SequenceOfApplicationDelta from TDocStd; |
148 | myUndoLimit : Integer from Standard; |
149 | myOpenTransaction : Boolean from Standard; |
150 | |
151 | ---Purpose: A flag for nested transaction mode. |
152 | |
153 | myIsNestedTransactionMode : Boolean from Standard; |
154 | |
155 | ---Purpose: Data for protection of changes outside transactions. |
156 | |
157 | myOnlyTransactionModification : Boolean from Standard; |
158 | |
159 | end MultiTransactionManager; |