r199@gandalf: fugalh | 2006-07-26 17:22:38 -0600

Memento(Redo|Undo)Command has a noop for the undo or redo respectively, and
 we don't need both before and after state. This is primarily useful for
 drag start/finish callbacks, and really only makes sense where wrapped by
 (begin|commit)_reversible_command (a composite command).
 
 Also a few more "normal" MementoCommands.


git-svn-id: svn://localhost/ardour2/branches/undo@695 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Fugal 2006-07-26 23:28:54 +00:00
parent b7bffbe7a2
commit 8e301e875a
6 changed files with 61 additions and 23 deletions

View file

@ -51,4 +51,38 @@ class MementoCommand : public Command
XMLNode &before, &after;
};
template <class obj_T>
class MementoUndoCommand : public MementoCommand<obj_T>
{
public:
MementoUndoCommand(obj_T &obj,
XMLNode &before)
: obj(obj), before(before) {}
void operator() () { /* noop */ }
void undo() { obj.set_state(before); }
virtual XMLNode &serialize()
{
// obj.id
// key is "MementoCommand" or something
// before and after mementos
}
}
template <class obj_T>
class MementoRedoCommand : public MementoCommand<obj_T>
{
public:
MementoUndoCommand(obj_T &obj,
XMLNode &after)
: obj(obj), after(after) {}
void operator() () { obj.set_state(after); }
void undo() { /* noop */ }
virtual XMLNode &serialize()
{
// obj.id
// key is "MementoCommand" or something
// before and after mementos
}
}
#endif // __lib_pbd_memento_h__