#include <ardour/session.h>
#include <ardour/route.h>
+#include <pbd/memento_command.h>
+#include <ardour/diskstream.h>
namespace ARDOUR {
+
+Command *Session::memento_command_factory(XMLNode *n)
+{
+ PBD::ID id;
+ XMLNode *before, *after;
+ void *obj;
+
+ /* get obj_id */
+
+ /* get before and/or after */
+
+ /* get an object by id by trial and error, and use it to construct an
+ * appropriate memento command */
+ // e.g.
+ if (Diskstream *obj = diskstream_by_id(id))
+ return new MementoCommand<Diskstream>(*obj, *before, *after);
+ // etc.
+}
+
// solo
Session::GlobalSoloStateCommand::GlobalSoloStateCommand(Session &sess, void *src)
: sess(sess), src(src)
#include <pbd/command.h>
#include <pbd/xml++.h>
#include <sigc++/slot.h>
+#include <typeinfo>
/** This command class is initialized with before and after mementos
* (from Stateful::get_state()), so undo becomes restoring the before
class MementoCommand : public Command
{
public:
+ MementoCommand(XMLNode &state);
MementoCommand(obj_T &obj,
XMLNode &before,
XMLNode &after
{
XMLNode *node = new XMLNode("MementoCommand");
node->add_property("obj_id", obj.id().to_s());
- node->add_child_nocopy(before);
- node->add_child_nocopy(after);
+ node->add_property("type_name", typeid(obj).name());
+ node->add_child_copy(before);
+ node->add_child_copy(after);
return *node;
}
- // TODO does this need a copy constructor?
protected:
obj_T &obj;
XMLNode &before, &after;
class MementoUndoCommand : public Command
{
public:
+ MementoUndoCommand(XMLNode &state);
MementoUndoCommand(obj_T &obj,
XMLNode &before)
: obj(obj), before(before) {}
{
XMLNode *node = new XMLNode("MementoUndoCommand");
node->add_property("obj_id", obj.id().to_s());
- node->add_child_nocopy(before);
+ node->add_property("type_name", typeid(obj).name());
+ node->add_child_copy(before);
return *node;
}
protected:
class MementoRedoCommand : public Command
{
public:
+ MementoRedoCommand(XMLNode &state);
MementoRedoCommand(obj_T &obj,
XMLNode &after)
: obj(obj), after(after) {}
{
XMLNode *node = new XMLNode("MementoRedoCommand");
node->add_property("obj_id", obj.id().to_s());
- node->add_child_nocopy(after);
+ node->add_property("type_name", typeid(obj).name());
+ node->add_child_copy(after);
return *node;
}
protected: