OpenLexocad
28.0
|
Helper class to manager transaction (i.e. undo/redo) More...
#include <AutoTransaction.h>
Public Member Functions | |
AutoTransaction (const char *name=0, bool tmpName=false) | |
~AutoTransaction () | |
void | close (bool abort=false) |
Static Public Member Functions | |
static void | setEnable (bool enable) |
Helper class to manager transaction (i.e. undo/redo)
Core::AutoTransaction::AutoTransaction | ( | const char * | name = 0 , |
bool | tmpName = false |
||
) |
Constructor
name | optional new transaction name on construction |
tmpName | if true and a new transaction is setup, the name given is considered as temporary, and subsequent construction of this class (or calling Application::setActiveTransaction()) can override the transaction name. |
The constructor increments an internal counter (Application::_activeTransactionGuard). The counter prevents any new active transaction being setup. It also prevents close (i.e. commits) the current active transaction until it reaches zero. It does not have any effect on aborting transaction, though.
Core::AutoTransaction::~AutoTransaction | ( | ) |
Destructor
This destructor decrease an internal counter (Application::_activeTransactionGuard), and will commit any current active transaction when the counter reaches zero.
void Core::AutoTransaction::close | ( | bool | abort = false | ) |
Close or abort the transaction
This function can be used to explicitly close (i.e. commit) the transaction, if the current transaction ID matches the one created inside the constructor. For aborting, it will abort any current transaction
|
static |
Enable/Disable any AutoTransaction instance in the current stack
Once disabled, any empty temporary named transaction is closed. If there are non-empty or non-temporary named active transaction, it will not be auto closed.
This function may be used in, for example, Gui::Document::setEdit() to allow a transaction live past any command scope.