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 >:

Inheritance graph
[legend]

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

Public Member Functions

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

Constructor & Destructor Documentation

template<class obj = NullType, typename doaddr = NullType, typename undoaddr = NullType>
FX::Generic::DoUndo< obj, doaddr, undoaddr >::DoUndo ( obj *  _instance,
doaddr  _doa,
undoaddr  _undoa 
) [inline]

Constructs a do/undo instance, doing the action.

template<class obj = NullType, typename doaddr = NullType, typename undoaddr = NullType>
FX::Generic::DoUndo< obj, doaddr, undoaddr >::~DoUndo (  )  [inline]

Destructs a do/undo instance, undoing the action.


Member Function Documentation

template<class obj = NullType, typename doaddr = NullType, typename undoaddr = NullType>
void FX::Generic::DoUndo< obj, doaddr, undoaddr >::undo (  )  [inline]

Undoes the action.

template<class obj = NullType, typename doaddr = NullType, typename undoaddr = NullType>
void FX::Generic::DoUndo< obj, doaddr, undoaddr >::redo (  )  [inline]

Redoes the action.


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

(C) 2002-2008 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Jun 13 22:30:14 2008 for TnFOX by doxygen v1.5.6