FX::Generic::DoUndo< obj, doaddr, undoaddr > Class Template Reference
[Generic Tools in TnFOX]

#include <FXGenericTools.h>

Inheritance diagram for FX::Generic::DoUndo< obj, doaddr, undoaddr >:

FX::FXPython_CtxHold FX::QThread_DTHold List of all members.

Detailed Description

template<class obj = NullType, typename doaddr = NullType, typename undoaddr = NullType>
class FX::Generic::DoUndo< obj, doaddr, undoaddr >

Performs an action on construction and another action on destruction.

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.

See also:
FX::FXRBObj, FX::FXRBFunc

Definition at line 2343 of file FXGenericTools.h.

Public Member Functions

 DoUndo (obj *_instance, doaddr _doa, undoaddr _undoa)
 ~DoUndo ()
void undo ()
void redo ()


The documentation for this class was generated from the following file:
(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:37:58 2009 for TnFOX by doxygen v1.4.7