Scid  4.7.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | List of all members
UndoRedo< TElem, UNDOMAX > Class Template Reference

A container useful for implementing a undo-redo behavior. More...

#include <containers.h>

Public Member Functions

 ~UndoRedo ()
 
void clear ()
 
size_t undoSize () const
 
size_t redoSize () const
 
void store (TElem *current)
 Stores a copy of an element into the undo queue. More...
 
TElem * undo (TElem *current)
 Retrieve the last element from the undo queue. More...
 
TElem * redo (TElem *current)
 Retrieve the last element from the redo queue. More...
 

Detailed Description

template<class TElem, size_t UNDOMAX>
class UndoRedo< TElem, UNDOMAX >

A container useful for implementing a undo-redo behavior.

UNDOMAX: max number of copies to store. Typical use: store(obj_ptr); // (1) modify obj; obj_ptr = undo(obj_ptr); // obj_ptr now contains the copy of (1)

Definition at line 33 of file containers.h.

Constructor & Destructor Documentation

◆ ~UndoRedo()

template<class TElem, size_t UNDOMAX>
UndoRedo< TElem, UNDOMAX >::~UndoRedo ( )
inline

Definition at line 38 of file containers.h.

Member Function Documentation

◆ clear()

template<class TElem, size_t UNDOMAX>
void UndoRedo< TElem, UNDOMAX >::clear ( )
inline

Definition at line 39 of file containers.h.

◆ redo()

template<class TElem, size_t UNDOMAX>
TElem* UndoRedo< TElem, UNDOMAX >::redo ( TElem *  current)
inline

Retrieve the last element from the redo queue.

Parameters
currentpointer to the current element; it will be stored into the undo queue.
Returns
the pointer to the last element of the redo queue (the pointer will be removed from the queue). If the queue is empty returns current

Definition at line 76 of file containers.h.

◆ redoSize()

template<class TElem, size_t UNDOMAX>
size_t UndoRedo< TElem, UNDOMAX >::redoSize ( ) const
inline

Definition at line 44 of file containers.h.

◆ store()

template<class TElem, size_t UNDOMAX>
void UndoRedo< TElem, UNDOMAX >::store ( TElem *  current)
inline

Stores a copy of an element into the undo queue.

Deletes all the objects of the redo queue.

Parameters
currentthe element to clone and store.

Definition at line 51 of file containers.h.

◆ undo()

template<class TElem, size_t UNDOMAX>
TElem* UndoRedo< TElem, UNDOMAX >::undo ( TElem *  current)
inline

Retrieve the last element from the undo queue.

Parameters
currentpointer to the current element; it will be stored into the redo queue.
Returns
the pointer to the last element of the undo queue (the pointer will be removed from the queue). If the queue is empty returns current

Definition at line 67 of file containers.h.

◆ undoSize()

template<class TElem, size_t UNDOMAX>
size_t UndoRedo< TElem, UNDOMAX >::undoSize ( ) const
inline

Definition at line 43 of file containers.h.


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