You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



Date last modified: Wed Feb 10 16:03:33 PST 1999


Transaction Manager Interface Class:


class nsITransactionManager  : public nsISupports{
public:
  virtual nsresult Do(nsITransaction *aTransaction) = 0;
  virtual nsresult Undo(void) = 0;
  virtual nsresult Redo(void) = 0;
  virtual nsresult Clear(void) = 0;
  virtual nsresult BeginBatch(void) = 0;
  virtual nsresult EndBatch(void) = 0;
  virtual nsresult GetNumberOfUndoItems(PRInt32 *aNumItems) = 0;
  virtual nsresult GetNumberOfRedoItems(PRInt32 *aNumItems) = 0;
  virtual nsresult SetMaxTransactionCount(PRInt32 aMaxCount) = 0;
  virtual nsresult PeekUndoStack(nsITransaction **aTransaction) = 0;
  virtual nsresult PeekRedoStack(nsITransaction **aTransaction) = 0;
  virtual nsresult Write(nsIOutputStream *aOutputStream) = 0;
  virtual nsresult AddListener(nsITransactionListener *aListener) = 0;
  virtual nsresult RemoveListener(nsITransactionListener *aListener) = 0;
};


Transaction Manager Interface Methods:

nsresult Do(nsITransaction *aTransaction)

Calls a transaction's Do() method, then pushes it on the undo stack.

This method calls the transaction's AddRef() method. The transaction's Release() method will be called when the undo or redo stack is pruned or when the transaction manager is destroyed.

Parameter:

aTransaction - the transaction to do.

nsresult Undo(void)

Pops the topmost transaction on the undo stack, calls it's Undo() method, then pushes it on the redo stack.

nsresult Redo(void)

Pops the topmost transaction on the redo stack, calls it's Redo() method, then pushes it on the undo stack.

nsresult Clear(void)

Clears the undo and redo stacks.

nsresult BeginBatch()

Turns on the transaction manager's batch mode, forcing all transactions executed by the transaction manager's Do() method to be aggregated together until EndBatch() is called. This mode allows an application to execute and group together several independent transactions so they can be undone with a single call to Undo().

nsresult EndBatch()

Turns off the transaction manager's batch mode.

nsresult GetNumberOfUndoItems(PRInt32 *aNumItems)

Returns the number of items on the undo stack.

Parameter:

aNumItems - will contain number of items.

nsresult GetNumberOfRedoItems(PRInt32 *aNumItems)

Returns the number of items on the redo stack.

Parameter:

aNumItems - will contain number of items.

nsresult SetMaxTransactionCount(PRInt32 aMaxCount)

Sets the maximum number of transaction items the transaction manager will maintain at any time. This is commonly referred to as the number of levels of undo.

Parameter:

aMaxCount - A value of -1 means no limit. A value of zero means the transaction manager will execute each transaction, then immediately release all references it has to the transaction without pushing it on the undo stack. A value greater than zero indicates the max number of transactions that can exist at any time on both the undo and redo stacks. This method will prune the neccessary number of transactions on the undo and redo stacks if the value specified is less than the number of items that exist on both the undo and redo stacks.

nsresult PeekUndoStack(nsITransaction **aTransaction)

Returns a pointer to the transaction at the top of the undo stack.

Parameter:

aTransaction - will contain pointer to the transaction.

nsresult PeekRedoStack(nsITransaction **aTransaction)

Returns a pointer to the transaction at the top of the redo stack.

Parameter:

aTransaction - will contain pointer to the transaction.

nsresult Write(nsIOutputStream *aOutputStream)

Writes a stream representation of the transaction manager and it's execution stacks. Calls the Write() method of each transaction on the execution stacks.

Parameter:

aOutputStream - the stream to write to.

nsresult AddListener(nsITransactionListener *aListener)

Adds a listener to the transaction manager's notification list. Listeners are notified whenever a transaction is done, undone, or redone.

The listener's AddRef() method is called.

Parameter:

aListener - the lister to add.

nsresult RemoveListener(nsITransactionListener *aListener)

Removes a listener from the transaction manager's notification list.

The listener's Release() method is called.

Parameter:

aListener - the lister to remove.