Jameo Core Library
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
jm::UndoManager Class Reference

This class represents the manager for undo operations. More...

Inheritance diagram for jm::UndoManager:
jm::Object

Public Member Functions

 UndoManager ()
 Constructor.
 
 ~UndoManager () override
 Destructor.
 
void setDocument (jm::Document *document)
 Sets the document associated with this manager. This enables automatic tracking of changes.
 
void setActive (bool status)
 Sets whether changes should be tracked or not.
 
bool isActive () const
 Returns the status of the manager, indicating whether changes are being tracked.
 
bool hasOpenUndoStep () const
 Returns true, if a undo step is open.
 
bool undo ()
 Undoes the last editing step on the file and pushes the change to the RedoStack.
 
bool redo ()
 Repeats the last editing step, undoing previous "undos".
 
void close ()
 This method finalizes the current editing step. Programmers must explicitly mark the completion of an editing step that should be undone as a whole.
 
void clearStacks ()
 This method clears the Undo-Stack and the Redo-Stack manually.
 
void clearUndoStack ()
 This method clears the Undo-Stack manually.
 
void clearRedoStack ()
 This method clears the Redo-Stack manually.
 
unsigned int undoCount () const
 Returns the number of elements on the Undo-Stack.
 
unsigned int redoCount () const
 Returns the number of elements on the Redo-Stack.
 
void registerChange (Object *object, float *pointer)
 This method registers a change in the file where a float value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, double *pointer)
 This method registers a change in the file where a double value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, bool *pointer)
 This method registers a change in the file where a boolean value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, int8 *pointer)
 This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, uint8 *pointer)
 This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, int16 *pointer)
 This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, uint16 *pointer)
 This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, int32 *pointer)
 This method registers a change in the file where an int32 value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, uint32 *pointer)
 This method registers a change in the file where an uint32 value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, Integer *pointer)
 This method registers a change in the file where a Integer value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, int64 *pointer)
 This method registers a change in the file where a int64 value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, uint64 *pointer)
 This method registers a change in the file where a long value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, Vertex2 *pointer)
 This method registers a change in the file where a Vertex3 value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, Vertex3 *pointer)
 This method registers a change in the file where a Vertex3 value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, String *pointer)
 This method registers a change in the file where a string value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, Date *pointer)
 This method registers a change in the file where a Date value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, Color *pointer)
 This method registers a change in the file where a color value of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (UndoChange *change)
 This method registers a general change in the file. This method is used when the user derives their own custom change steps.
 
void registerChange (Object *object, Object **pointer)
 This method registers a change in the file where an object reference of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerChange (Object *object, uint8 **pointer, uint64 length)
 This method registers a change in the file where an object reference of an object is modified. If the UndoManager is not active, nothing happens.
 
void registerRegenerationMarker (EditableObject *object)
 This method registers a regeneration marker that is triggered at every undo/redo step to regenerate objects in the view.
 
void registerRelease (Object *object)
 
void registerRetain (Object *object)
 
void openTransaction ()
 Begin a transaction.
 
void commit ()
 Commit the content of the transaction to the current undo step.
 
void rollback ()
 Rollback all changes of the transaction.
 
Status closeTransaction ()
 Closes the transaction.
 
bool hasOpenTransaction () const
 Returns true, if a transaction is open.
 
void registerTransactionStatus (Status status)
 This method registers the status of operations during a transaction. As long as status is eOK, nothing happens. If status is not eOk, we register a transaction error.
 
Status transactionStatus () const
 Returns the transaction status.
 
UndoStepopenStep ()
 
- Public Member Functions inherited from jm::Object
 Object () noexcept
 Constructor.
 
virtual ~Object () noexcept
 Destructor.
 
void release () noexcept
 Decreases the reference counter and releases the object immediately when the reference counter becomes 0.
 
Objectretain () noexcept
 Increases the reference counter of this object by 1.
 
Objectautorelease () noexcept
 Same function as release(), but releases the object with a delay if the reference counter is 0. AutoreleasePool::drain() must be called in the to release the object.
 
int32 referenceCount () const noexcept
 Returns the value of the reference counter.
 
virtual bool equals (const Object *other) const
 Comparison of objects.
 
virtual String displayName () const
 Returns the display name of the object intended to present to a user.
 
virtual void printDiffInfo (DiffOperation operation, Object *other) const
 Output method for outputting the diff results for the diff algorithm.
 
void setHighBit (bool status) noexcept
 
bool highBit () const noexcept
 

Friends

class Document
 

Detailed Description

This class represents the manager for undo operations.

Editing steps on a document are registered here, and the undo manager belongs to the corresponding document, so that each document owns its own undo manager. This makes it possible to undo editing steps on the document independently of the editing procedure.

However, it is necessary to consider by the developer the form in which processing steps are atomised.

Therefore, there is the following procedure:

To complete the current editing step, the method Close() must be called. The developer must do this manually. Otherwise, all changes are saved in one step.

Constructor & Destructor Documentation

◆ UndoManager()

jm::UndoManager::UndoManager ( )

Constructor.

◆ ~UndoManager()

jm::UndoManager::~UndoManager ( )
override

Destructor.

Member Function Documentation

◆ clearRedoStack()

void jm::UndoManager::clearRedoStack ( )

This method clears the Redo-Stack manually.

◆ clearStacks()

void jm::UndoManager::clearStacks ( )

This method clears the Undo-Stack and the Redo-Stack manually.

◆ clearUndoStack()

void jm::UndoManager::clearUndoStack ( )

This method clears the Undo-Stack manually.

◆ close()

void jm::UndoManager::close ( )

This method finalizes the current editing step. Programmers must explicitly mark the completion of an editing step that should be undone as a whole.

  • Only when a step is completed, undo or redo can be performed.
  • The step is only completed if there are changes.

◆ closeTransaction()

Status jm::UndoManager::closeTransaction ( )

Closes the transaction.

Dependent on the value of the transaction status, this method decides to call Commit() or Rollback();

If the transaction level is still > 0, nothing happens. Only if the level is back to 0 the closing actions happens.

See also
openTransaction()
EditableObject::closeTransaction();

◆ commit()

void jm::UndoManager::commit ( )

Commit the content of the transaction to the current undo step.

Each time this method is called, the transaction level decrements.

If the transaction level is still > 0, nothing happens. Only if the level is back to 0 the commit of changes happens, whether the transaction status value.

Warning
Usually you not need to call this method, because closeTransaction() is doing the necessary stuff. Probably we change this method to private in the future.

◆ hasOpenTransaction()

bool jm::UndoManager::hasOpenTransaction ( ) const

Returns true, if a transaction is open.

The transaction is open, if the transaction level is > 0.

◆ hasOpenUndoStep()

bool jm::UndoManager::hasOpenUndoStep ( ) const

Returns true, if a undo step is open.

◆ isActive()

bool jm::UndoManager::isActive ( ) const

Returns the status of the manager, indicating whether changes are being tracked.

Returns
True if changes are being tracked.

◆ openStep()

UndoStep * jm::UndoManager::openStep ( )

◆ openTransaction()

void jm::UndoManager::openTransaction ( )

Begin a transaction.

A transaction is used to change data on objects, which have a meaningful relationship and always shall be consistent. So after changing data, you have to decide of committing a transaction or rollback the data to previous state.

Each time this method is called, the transaction level increments.

See also
closeTransaction()
EditableObject::openTransaction();

◆ redo()

bool jm::UndoManager::redo ( )

Repeats the last editing step, undoing previous "undos".

Returns
True if redo was performed successfully, false otherwise.

◆ redoCount()

unsigned int jm::UndoManager::redoCount ( ) const

Returns the number of elements on the Redo-Stack.

◆ registerChange() [1/20]

void jm::UndoManager::registerChange ( Object object,
bool *  pointer 
)

This method registers a change in the file where a boolean value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [2/20]

void jm::UndoManager::registerChange ( Object object,
Color pointer 
)

This method registers a change in the file where a color value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [3/20]

void jm::UndoManager::registerChange ( Object object,
Date pointer 
)

This method registers a change in the file where a Date value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [4/20]

void jm::UndoManager::registerChange ( Object object,
double *  pointer 
)

This method registers a change in the file where a double value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [5/20]

void jm::UndoManager::registerChange ( Object object,
float *  pointer 
)

This method registers a change in the file where a float value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [6/20]

void jm::UndoManager::registerChange ( Object object,
int16 *  pointer 
)

This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [7/20]

void jm::UndoManager::registerChange ( Object object,
int32 *  pointer 
)

This method registers a change in the file where an int32 value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [8/20]

void jm::UndoManager::registerChange ( Object object,
int64 *  pointer 
)

This method registers a change in the file where a int64 value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [9/20]

void jm::UndoManager::registerChange ( Object object,
int8 *  pointer 
)

This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [10/20]

void jm::UndoManager::registerChange ( Object object,
Integer pointer 
)

This method registers a change in the file where a Integer value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [11/20]

void jm::UndoManager::registerChange ( Object object,
Object **  pointer 
)

This method registers a change in the file where an object reference of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [12/20]

void jm::UndoManager::registerChange ( Object object,
String pointer 
)

This method registers a change in the file where a string value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [13/20]

void jm::UndoManager::registerChange ( Object object,
uint16 *  pointer 
)

This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [14/20]

void jm::UndoManager::registerChange ( Object object,
uint32 *  pointer 
)

This method registers a change in the file where an uint32 value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [15/20]

void jm::UndoManager::registerChange ( Object object,
uint64 *  pointer 
)

This method registers a change in the file where a long value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [16/20]

void jm::UndoManager::registerChange ( Object object,
uint8 **  pointer,
uint64  length 
)

This method registers a change in the file where an object reference of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [17/20]

void jm::UndoManager::registerChange ( Object object,
uint8 *  pointer 
)

This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [18/20]

void jm::UndoManager::registerChange ( Object object,
Vertex2 pointer 
)

This method registers a change in the file where a Vertex3 value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [19/20]

void jm::UndoManager::registerChange ( Object object,
Vertex3 pointer 
)

This method registers a change in the file where a Vertex3 value of an object is modified. If the UndoManager is not active, nothing happens.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object whose value is being modified.
pointerA pointer to the value that will be modified. This method automatically saves the old value.

◆ registerChange() [20/20]

void jm::UndoManager::registerChange ( UndoChange change)

This method registers a general change in the file. This method is used when the user derives their own custom change steps.

Parameters
changeThe change to be registered.

◆ registerRegenerationMarker()

void jm::UndoManager::registerRegenerationMarker ( EditableObject object)

This method registers a regeneration marker that is triggered at every undo/redo step to regenerate objects in the view.

This method opens an undo step and also resets the RedoStack.

Parameters
objectThe object that needs to be regenerated in the view.

◆ registerRelease()

void jm::UndoManager::registerRelease ( Object object)

◆ registerRetain()

void jm::UndoManager::registerRetain ( Object object)

◆ registerTransactionStatus()

void jm::UndoManager::registerTransactionStatus ( Status  status)

This method registers the status of operations during a transaction. As long as status is eOK, nothing happens. If status is not eOk, we register a transaction error.

◆ rollback()

void jm::UndoManager::rollback ( )

Rollback all changes of the transaction.

Each time this method is called, the transaction level decrements.

If the transaction level is still > 0, nothing happens. Only if the level is back to 0 the rollback of changes happens, whether the transaction status value.

Warning
Usually you not need to call this method, because closeTransaction() is doing the necessary stuff. Probably we change this method to private in the future.

◆ setActive()

void jm::UndoManager::setActive ( bool  status)

Sets whether changes should be tracked or not.

Parameters
statusTrue if changes should be tracked.

◆ setDocument()

void jm::UndoManager::setDocument ( jm::Document document)

Sets the document associated with this manager. This enables automatic tracking of changes.

Parameters
documentThe document to be associated with this manager.

◆ transactionStatus()

Status jm::UndoManager::transactionStatus ( ) const

Returns the transaction status.

◆ undo()

bool jm::UndoManager::undo ( )

Undoes the last editing step on the file and pushes the change to the RedoStack.

Returns
Returns true if Undo was performed successfully, otherwise false.

◆ undoCount()

unsigned int jm::UndoManager::undoCount ( ) const

Returns the number of elements on the Undo-Stack.

Friends And Related Symbol Documentation

◆ Document

friend class Document
friend