r42@gandalf: fugalh | 2006-06-07 17:08:39 -0600
authorHans Fugal <hans@fugal.net>
Wed, 7 Jun 2006 23:08:56 +0000 (23:08 +0000)
committerHans Fugal <hans@fugal.net>
Wed, 7 Jun 2006 23:08:56 +0000 (23:08 +0000)
 Memento skeleton. RFC
 Compiles, but obviously somewhat unimplemented.

git-svn-id: svn://localhost/ardour2/branches/undo@572 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/pbd3/pbd/undo.h

index f067635ed3a2adf3ba9c58f393e779c0e05c4288..b540179012ace7d23091023c661d0a84d7ee69a5 100644 (file)
 #include <string>
 #include <list>
 #include <sigc++/slot.h>
+#include <sigc++/bind.h>
 #include <sys/time.h>
+#include <pbd/xml++.h>
 
 using std::string;
 using std::list;
 
 typedef sigc::slot<void> UndoAction;
 
+class Serializable;
+
+class MementoBase
+{
+public:
+    MementoBase(std::string key);
+    void operator() () { return _slot(); }
+    XMLNode &serialize();
+protected:
+    sigc::slot<void> _slot;
+    std::list<Serializable> _args;
+};
+
+template <class T1=void, class T2=void, class T3=void, class T4=void>
+class Memento;
+
+template <>
+class Memento <> : public MementoBase {};
+
+template <class T1>
+class Memento <T1> : public MementoBase
+{
+public:
+    Memento(std::string key, T1 arg1) : MementoBase(key)
+    {
+       _args.push_back(arg1);
+       _slot = sigc::bind(_slot, arg1);
+    }
+};
+
 class UndoCommand 
 {
   public: