Web Analytics Made Easy - Statcounter
Skip to content

Class SBCUndoStack#

ClassList > SBCUndoStack

This class describes an undo stack.

  • #include <SBCUndoStack.hpp>

Public Functions#

Type Name
SBCUndoStack ()
Constructors and destructors.
void beginHolding (const std::string & name)
Begins holding.
void beginUndoCommandGroup (const std::string & name)
Begins a new command group to the current command group.
void clear ()
Clears the stack.
void connectUndoSignalToSlot (SBCReferenceTarget * observer, void(SBCReferenceTarget::*)(SBCUndoEvent *) functionPointer)
Connects the undo signal to the slot of the observer.
void disableHolding ()
Pauses holding.
void disableUndoRedo ()
Disables undo and redo.
void disconnectUndoSignalFromSlot (SBCReferenceTarget * observer, void(SBCReferenceTarget::*)(SBCUndoEvent *) functionPointer)
Disconnects the undo signal to the slot of the observer.
void enableHolding ()
Resumes holding.
void enableUndoRedo ()
Enables undo and redo.
void endHolding ()
Ends holding.
void endUndoCommandGroup ()
Ends a new command group to the current command group.
SBCContainerVector< SBCUndoCommand * > * getCommandVector () const
Returns a vector of undo commands.
unsigned int getDisablingUndoRedoCounter ()
Returns the counter for disabling undo and redo.
unsigned int getNextRedoIndex () const
Returns the next redo index.
void hold (SBCUndoCommand * undoCommand)
Adds a new command to the current command group.
void hold (void * object)
Holds an object allocated on the heap.
void hold (SBPointerTarget * pointerTarget)
Holds a pointer target allocated on the heap.
void holdArray (void * array)
Holds an array allocated on the heap.
bool isHolding () const
Storing commands.
bool isRedoing () const
Returns true while redoing.
bool isUndoing () const
Returns true while undoing.
virtual void print (unsigned int offset=0) const
Prints debugging information.
void redo ()
Redo one command.
void undo ()
Undo and redo.
bool undoSignalIsConnectedToSlot (SBCReferenceTarget * observer, void(SBCReferenceTarget::*)(SBCUndoEvent *) functionPointer) const
Returns whether the undo signal is connected to the slot of the observer.
virtual ~SBCUndoStack ()
Destructor.

Protected Attributes#

Type Name
SBCUndoStackData * dataPointer
A pointer to the private data.

Public Functions Documentation#

function SBCUndoStack#

Constructors and destructors.

SBCUndoStack::SBCUndoStack () 

Constructs a new SBCUndoStack object.

Default constructor

The stack is initialized with an empty command history.


function beginHolding#

Begins holding.

void SBCUndoStack::beginHolding (
    const std::string & name
) 

Begins a holding block with the given name.

Commands added after this call will be grouped together until endHolding is called.

Parameters:

  • name The name of the holding block.

function beginUndoCommandGroup#

Begins a new command group to the current command group.

void SBCUndoStack::beginUndoCommandGroup (
    const std::string & name
) 

Begins a new undo command group within the current holding block.

The new group allows commands to be nested hierarchically.

Parameters:

  • name The name of the command group.

function clear#

Clears the stack.

void SBCUndoStack::clear () 

Clears all commands from the undo stack.

All commands are deleted and the stack becomes empty.


function connectUndoSignalToSlot#

Connects the undo signal to the slot of the observer.

void SBCUndoStack::connectUndoSignalToSlot (
    SBCReferenceTarget * observer,
    void(SBCReferenceTarget::*)( SBCUndoEvent *) functionPointer
) 

Connects the undo signal to a slot on a reference target.

This function registers the observer's slot to receive undo events, creating the signal object if it does not already exist.

Parameters:

  • referenceTarget The object whose slot will receive undo events.
  • functionPointer Pointer to the member function to be called when an undo event occurs.

function disableHolding#

Pauses holding.

void SBCUndoStack::disableHolding () 

Disables holding temporarily.

Subsequent calls to beginHolding will have no effect until enableHolding is called.


function disableUndoRedo#

Disables undo and redo.

void SBCUndoStack::disableUndoRedo () 

Increments the counter that disables undo and redo operations.


function disconnectUndoSignalFromSlot#

Disconnects the undo signal to the slot of the observer.

void SBCUndoStack::disconnectUndoSignalFromSlot (
    SBCReferenceTarget * observer,
    void(SBCReferenceTarget::*)( SBCUndoEvent *) functionPointer
) 

Disconnects the undo signal from the specified slot of the observer.

This function unregisters the observer's slot so that it no longer receives undo events.

Parameters:

  • referenceTarget The observer whose slot connection should be removed.
  • functionPointer Pointer to the observer's member function that receives the undo event.

function enableHolding#

Resumes holding.

void SBCUndoStack::enableHolding () 

Re-enables holding after it has been disabled.

Decrements the internal disabling counter, allowing holding to be resumed.


function enableUndoRedo#

Enables undo and redo.

void SBCUndoStack::enableUndoRedo () 

Decrements the counter that disables undo and redo operations.


function endHolding#

Ends holding.

void SBCUndoStack::endHolding () 

Ends the current holding block.

If any commands were recorded, they are added to the command history; otherwise the holding block is discarded.


function endUndoCommandGroup#

Ends a new command group to the current command group.

void SBCUndoStack::endUndoCommandGroup () 

Ends the most recently started undo command group.

Restores the parent command group as the current context, effectively closing the most recent group.


function getCommandVector#

Returns a vector of undo commands.

SBCContainerVector < SBCUndoCommand * > * SBCUndoStack::getCommandVector () const

Returns a pointer to the vector containing undo commands.

Returns:

Pointer to the command vector, or nullptr if the internal data is unavailable.


function getDisablingUndoRedoCounter#

Returns the counter for disabling undo and redo.

unsigned int SBCUndoStack::getDisablingUndoRedoCounter () 

Returns the current counter value for disabling undo and redo.

Returns:

The disabling undo/redo counter.


function getNextRedoIndex#

Returns the next redo index.

unsigned int SBCUndoStack::getNextRedoIndex () const

Returns the index of the next command that will be redone.

Returns:

The next redo index, or 0 if the internal data is unavailable.


function hold [1/3]#

Adds a new command to the current command group.

void SBCUndoStack::hold (
    SBCUndoCommand * undoCommand
) 

Adds an undo command to the current holding block.

The command is added as a child of the current command group, transferring ownership to the stack.

Parameters:

  • undoCommand Pointer to the command to be held. Ownership is transferred to the stack.

function hold [2/3]#

Holds an object allocated on the heap.

void SBCUndoStack::hold (
    void * object
) 

Holds a raw object on the heap.

The object will be deleted when the command is destroyed.

Parameters:

  • object Pointer to the object to hold.

function hold [3/3]#

Holds a pointer target allocated on the heap.

void SBCUndoStack::hold (
    SBPointerTarget * pointerTarget
) 

The pointer target will be released when the command is destroyed.

Parameters:

  • pointerTarget Pointer to the target to hold.

function holdArray#

Holds an array allocated on the heap.

void SBCUndoStack::holdArray (
    void * array
) 

The array will be deleted when the command is destroyed.

Parameters:

  • array Pointer to the array to hold.

function isHolding#

Storing commands.

bool SBCUndoStack::isHolding () const

Checks whether the stack is currently holding commands.

Returns true while holding

Returns:

true if holding is active and not disabled; otherwise false.


function isRedoing#

Returns true while redoing.

bool SBCUndoStack::isRedoing () const

Returns whether a redo operation is currently in progress.

Returns:

true if redoing; otherwise false.


function isUndoing#

Returns true while undoing.

bool SBCUndoStack::isUndoing () const

Returns whether an undo operation is currently in progress.

Returns:

true if undoing; otherwise false.


function print#

Prints debugging information.

virtual void SBCUndoStack::print (
    unsigned int offset=0
) const

Prints debugging information about the undo stack.

This function outputs the contents of the undo stack to standard output, indicating which commands are undoable and which are redoable, using the provided indentation level.

Parameters:

  • offset The indentation level (in tabs) for the printed output.

function redo#

Redo one command.

void SBCUndoStack::redo () 

Performs a redo operation on the next command, if possible.

This function verifies that redo can be performed, updates the internal state, invokes the redo operation on the next command, and emits an undo signal.


function undo#

Undo and redo.

void SBCUndoStack::undo () 

Performs an undo operation on the most recent command, if possible.

Undo one command

This function checks whether undo can be performed, updates the internal state, invokes the undo operation on the current command, and emits an undo signal.


function undoSignalIsConnectedToSlot#

Returns whether the undo signal is connected to the slot of the observer.

bool SBCUndoStack::undoSignalIsConnectedToSlot (
    SBCReferenceTarget * observer,
    void(SBCReferenceTarget::*)( SBCUndoEvent *) functionPointer
) const

Checks whether the undo signal is connected to the specified slot of the observer.

This function returns true if the given observer's slot is currently registered to receive undo events.

Parameters:

  • referenceTarget The observer whose slot connection is being queried.
  • functionPointer Pointer to the observer's member function that receives the undo event.

Returns:

true if the undo signal is connected to the slot; otherwise false.


function ~SBCUndoStack#

Destructor.

virtual SBCUndoStack::~SBCUndoStack () 

Destroys the SBCUndoStack and releases its resources.

All held commands are cleared and the internal data is deleted.


Protected Attributes Documentation#

variable dataPointer#

A pointer to the private data.

SBCUndoStackData* SBCUndoStack::dataPointer;