OpenLexocad  27.1
Core::AutoTransaction Class Reference

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)
 

Detailed Description

Helper class to manager transaction (i.e. undo/redo)

Constructor & Destructor Documentation

◆ AutoTransaction()

Core::AutoTransaction::AutoTransaction ( const char *  name = 0,
bool  tmpName = false 
)

Constructor

Parameters
nameoptional new transaction name on construction
tmpNameif 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.

◆ ~AutoTransaction()

Core::AutoTransaction::~AutoTransaction ( )

Destructor

This destructor decrease an internal counter (Application::_activeTransactionGuard), and will commit any current active transaction when the counter reaches zero.

Member Function Documentation

◆ close()

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

◆ setEnable()

static void Core::AutoTransaction::setEnable ( bool  enable)
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.


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