summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorHans Fugal <hans@fugal.net>2006-06-22 22:37:08 +0000
committerHans Fugal <hans@fugal.net>2006-06-22 22:37:08 +0000
commit4078b9ec645f4fc71dc3693c7ee70354183393d5 (patch)
tree1b06a2ae8fd664d2b43dbcc15c0526ddf98edcf9 /libs
parent7c9361b8657a4deafcb7cffcdf4584a441fd9ce6 (diff)
r80@gandalf: fugalh | 2006-06-22 16:37:01 -0600
reworked templatization of UndoCommand git-svn-id: svn://localhost/ardour2/branches/undo@636 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/pbd3/pbd/serializable.h32
-rw-r--r--libs/pbd3/pbd/undo.h37
-rw-r--r--libs/pbd3/pbd/undo_command.h80
3 files changed, 113 insertions, 36 deletions
diff --git a/libs/pbd3/pbd/serializable.h b/libs/pbd3/pbd/serializable.h
new file mode 100644
index 0000000000..8032f0038a
--- /dev/null
+++ b/libs/pbd3/pbd/serializable.h
@@ -0,0 +1,32 @@
+/*
+ Copyright (C) 2006 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ $Id: /local/undo/libs/pbd3/pbd/undo.h 59 2006-06-15T18:16:20.960977Z fugalh $
+*/
+
+#ifndef __lib_pbd_serializable_h__
+#define __lib_pbd_serializable_h__
+
+#include <pbd/xml++.h>
+
+class Serializable
+{
+public:
+ XMLNode &serialize();
+};
+
+#endif // __lib_pbd_serializable_h__
diff --git a/libs/pbd3/pbd/undo.h b/libs/pbd3/pbd/undo.h
index 488e896706..d2ad6088cd 100644
--- a/libs/pbd3/pbd/undo.h
+++ b/libs/pbd3/pbd/undo.h
@@ -27,48 +27,13 @@
#include <sigc++/slot.h>
#include <sigc++/bind.h>
#include <sys/time.h>
-#include <pbd/xml++.h>
+#include <pbd/undo_command.h>
using std::string;
using std::list;
typedef sigc::slot<void> UndoAction;
-// TODO stick this in its own file, and make the arguments multiply-inherit it
-class Serializable
-{
-public:
- XMLNode &serialize();
-};
-
-class UndoCommand
-{
-public:
- UndoCommand(id_t object_id, std::string method_name);
- void operator() () { return _slot(); }
- XMLNode &serialize();
-protected:
- sigc::slot<void> _slot;
-};
-
-template <class T1=void, class T2=void, class T3=void, class T4=void>
-class SlotCommand;
-
-template <>
-class SlotCommand <> : public UndoCommand {};
-
-template <class T1>
-class SlotCommand <T1> : public UndoCommand
-{
- T1 _arg1;
-public:
- SlotCommand(id_t object_id, std::string key, T1 arg1)
- : UndoCommand(object_id, key), _arg1(arg1)
- {
- _slot = sigc::bind(_slot, arg1);
- }
-};
-
class UndoTransaction
{
public:
diff --git a/libs/pbd3/pbd/undo_command.h b/libs/pbd3/pbd/undo_command.h
new file mode 100644
index 0000000000..2f45e2799a
--- /dev/null
+++ b/libs/pbd3/pbd/undo_command.h
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) 2006 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ $Id: /local/undo/libs/pbd3/pbd/undo.h 59 2006-06-15T18:16:20.960977Z fugalh $
+*/
+
+#ifndef __lib_pbd_undo_command_h__
+#define __lib_pbd_undo_command_h__
+
+#include <pbd/serializable.h>
+
+using sigc::nil;
+using sigc::slot;
+using std::list;
+using std::string;
+
+template <class T1=nil, class T2=nil, class T3=nil, class T4=nil>
+class UndoCommand
+{
+ public:
+ /* It only makes sense to use the constructor corresponding to the
+ * template given. e.g.
+ *
+ * UndoCommand<Foo> cmd(id, key, foo_instance);
+ */
+ UndoCommand(id_t object_id, string key)
+ : _obj_id(object_id), _key(key) {}
+ UndoCommand(id_t object_id, string key, T1 arg1)
+ : _obj_id(object_id), _key(key)
+ {
+ _args.push_back(arg1);
+ }
+ UndoCommand(id_t object_id, string key, T1 arg1, T2 arg2)
+ : _obj_id(object_id), _key(key)
+ {
+ _args.push_back(arg1);
+ _args.push_back(arg2);
+ }
+ UndoCommand(id_t object_id, string key, T1 arg1, T2 arg2, T3 arg3)
+ : _obj_id(object_id), _key(key)
+ {
+ _args.push_back(arg1);
+ _args.push_back(arg2);
+ _args.push_back(arg3);
+ }
+ UndoCommand(id_t object_id, string key, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
+ : _obj_id(object_id), _key(key)
+ {
+ _args.push_back(arg1);
+ _args.push_back(arg2);
+ _args.push_back(arg3);
+ _args.push_back(arg4);
+ }
+
+ void operator() () { return _slot(); }
+ XMLNode &serialize();
+ protected:
+ id_t _obj_id;
+ string _key;
+ slot<void> _slot;
+ // Note that arguments must be instances of Serializable or this will
+ // rightly cause a compiler error when compiling the constructor.
+ list<Serializable*> _args;
+};
+
+#endif // __lib_pbd_undo_command_h__