#include <FXGenericTools.h>
This is a very useful class for generically calling some function on construction and then some other on destruction (and thus is exception-safe). Obviously it is intended for usage on the stack as an auto-scoped instance. During its lifetime you can temporarily undo() and redo() the action.
Note that there are two forms of DoUndo - fast and slow. The fast takes pointers to a function or member function which has no parameters and thus costs one virtual method call per invocation. The slow takes a FX::Generic::BoundFunctor and thus costs two virtual method calls per invocation. Obviously there are two invocations per scope.
For the fast, passing void
as the object type gets you a non-member function invocation. The default parameters of all the template parameters gives you the slow type. With those taking a bound functor (slow type), DoUndo takes ownership of the pointer you pass.
Public Member Functions | |
DoUndo (obj *_instance, doaddr _doa, undoaddr _undoa) | |
~DoUndo () | |
void | undo () |
void | redo () |
FX::Generic::DoUndo< obj, doaddr, undoaddr >::DoUndo | ( | obj * | _instance, | |
doaddr | _doa, | |||
undoaddr | _undoa | |||
) | [inline] |
Constructs a do/undo instance, doing the action.
FX::Generic::DoUndo< obj, doaddr, undoaddr >::~DoUndo | ( | ) | [inline] |
Destructs a do/undo instance, undoing the action.
void FX::Generic::DoUndo< obj, doaddr, undoaddr >::undo | ( | ) | [inline] |
Undoes the action.
void FX::Generic::DoUndo< obj, doaddr, undoaddr >::redo | ( | ) | [inline] |
Redoes the action.