Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes
SimpleTransaction Class Reference
Inheritance diagram for SimpleTransaction:
Inheritance graph
[legend]
Collaboration diagram for SimpleTransaction:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SimpleTransaction (PRInt32 aFlags=NONE_FLAG)
virtual ~SimpleTransaction ()
NS_IMETHOD DoTransaction ()
NS_IMETHOD UndoTransaction ()
NS_IMETHOD RedoTransaction ()
NS_IMETHOD GetIsTransient (PRBool *aIsTransient)
NS_IMETHOD Merge (nsITransaction *aTransaction, PRBool *aDidMerge)
void doTransaction ()
 Executes the transaction.
void undoTransaction ()
 Restores the state to what it was before the transaction was executed.
void redoTransaction ()
 Executes the transaction again.
boolean merge (in nsITransaction aTransaction)
 Attempts to merge a transaction into "this" transaction.

Public Attributes

PRInt32 mVal
PRInt32 mFlags
readonly attribute boolean isTransient
 The transaction's transient state.

Detailed Description

Definition at line 450 of file TestTXMgr.cpp.


Constructor & Destructor Documentation

Definition at line 466 of file TestTXMgr.cpp.

virtual SimpleTransaction::~SimpleTransaction ( ) [inline, virtual]

Definition at line 470 of file TestTXMgr.cpp.

  {
    //
    // Make sure transactions are being destroyed in the order we expect!
    // Notice that we don't check to see if we go past the end of the array.
    // This is done on purpose since we want to crash if the order array is out
    // of date.
    //
    if (sDestructorOrderArr && mVal != sDestructorOrderArr[sDestructorCount]) {
      printf("ERROR: ~SimpleTransaction expected %d got %d.\n",
             mVal, sDestructorOrderArr[sDestructorCount]);
      exit(NS_ERROR_FAILURE);
    }

    ++sDestructorCount;

#ifdef ENABLE_DEBUG_PRINTFS
    printf("\n~SimpleTransaction: %d - 0x%.8x\n", mVal, (PRInt32)this);
#endif // ENABLE_DEBUG_PRINTFS

    mVal = -1;
  }

Here is the call graph for this function:


Member Function Documentation

Executes the transaction.

Reimplemented in AggregateTransaction.

Definition at line 493 of file TestTXMgr.cpp.

  {
    //
    // Make sure DoTransaction() is called in the order we expect!
    // Notice that we don't check to see if we go past the end of the array.
    // This is done on purpose since we want to crash if the order array is out
    // of date.
    //
    if (sDoOrderArr && mVal != sDoOrderArr[sDoCount]) {
      printf("ERROR: ~SimpleTransaction expected %d got %d.\n",
             mVal, sDoOrderArr[sDoCount]);
      exit(NS_ERROR_FAILURE);
    }

    ++sDoCount;

#ifdef ENABLE_DEBUG_PRINTFS
    printf("\nSimpleTransaction.DoTransaction: %d - 0x%.8x\n", mVal, (PRInt32)this);
#endif // ENABLE_DEBUG_PRINTFS

    return (mFlags & THROWS_DO_ERROR_FLAG) ? NS_ERROR_FAILURE : NS_OK;
  }

Here is the call graph for this function:

NS_IMETHOD SimpleTransaction::GetIsTransient ( PRBool aIsTransient) [inline]

Definition at line 562 of file TestTXMgr.cpp.

  {
    if (aIsTransient)
      *aIsTransient = (mFlags & TRANSIENT_FLAG) ? PR_TRUE : PR_FALSE;

    return NS_OK;
  }
boolean nsITransaction::merge ( in nsITransaction  aTransaction) [inherited]

Attempts to merge a transaction into "this" transaction.

Both transactions must be in their undo state, doTransaction() methods already called. The transaction manager calls this method to coalesce a new transaction with the transaction on the top of the undo stack. This method returns a boolean value that indicates the merge result. A true value indicates that the transactions were merged successfully, a false value if the merge was not possible or failed. If true, the transaction manager will Release() the new transacton instead of pushing it on the undo stack.

Parameters:
aTransactionthe previously executed transaction to merge.
NS_IMETHOD SimpleTransaction::Merge ( nsITransaction aTransaction,
PRBool aDidMerge 
) [inline]

Definition at line 570 of file TestTXMgr.cpp.

  {
    if (aDidMerge)
      *aDidMerge = (mFlags & MERGE_FLAG) ? PR_TRUE : PR_FALSE;

    return NS_OK;
  }

Executes the transaction again.

Can only be called on a transaction that was previously undone.

In most cases, the redoTransaction() method will actually call the doTransaction() method to execute the transaction again.

Definition at line 539 of file TestTXMgr.cpp.

  {
    //
    // Make sure RedoTransaction() is called in the order we expect!
    // Notice that we don't check to see if we go past the end of the array.
    // This is done on purpose since we want to crash if the order array is out
    // of date.
    //
    if (sRedoOrderArr && mVal != sRedoOrderArr[sRedoCount]) {
      printf("ERROR: ~SimpleTransaction expected %d got %d.\n",
             mVal, sRedoOrderArr[sRedoCount]);
      exit(NS_ERROR_FAILURE);
    }

    ++sRedoCount;

#ifdef ENABLE_DEBUG_PRINTFS
    printf("\nSimpleTransaction.Redo: %d - 0x%.8x\n", mVal, (PRInt32)this);
#endif // ENABLE_DEBUG_PRINTFS

    return (mFlags & THROWS_REDO_ERROR_FLAG) ? NS_ERROR_FAILURE : NS_OK;
  }

Here is the call graph for this function:

Restores the state to what it was before the transaction was executed.

Definition at line 516 of file TestTXMgr.cpp.

  {
    //
    // Make sure UndoTransaction() is called in the order we expect!
    // Notice that we don't check to see if we go past the end of the array.
    // This is done on purpose since we want to crash if the order array is out
    // of date.
    //
    if (sUndoOrderArr && mVal != sUndoOrderArr[sUndoCount]) {
      printf("ERROR: ~SimpleTransaction expected %d got %d.\n",
             mVal, sUndoOrderArr[sUndoCount]);
      exit(NS_ERROR_FAILURE);
    }

    ++sUndoCount;

#ifdef ENABLE_DEBUG_PRINTFS
    printf("\nSimpleTransaction.Undo: %d - 0x%.8x\n", mVal, (PRInt32)this);
#endif // ENABLE_DEBUG_PRINTFS

    return (mFlags & THROWS_UNDO_ERROR_FLAG) ? NS_ERROR_FAILURE : NS_OK;
  }

Here is the call graph for this function:


Member Data Documentation

The transaction's transient state.

This attribute is checked by the transaction manager after the transaction's Execute() method is called. If the transient state is false, a reference to the transaction is held by the transaction manager so that the transactions' undoTransaction() and redoTransaction() methods can be called. If the transient state is true, the transaction manager returns immediately after the transaction's doTransaction() method is called, no references to the transaction are maintained. Transient transactions cannot be undone or redone by the transaction manager.

Definition at line 79 of file nsITransaction.idl.

Definition at line 464 of file TestTXMgr.cpp.

Definition at line 463 of file TestTXMgr.cpp.


The documentation for this class was generated from the following file: