// these commands are implemented in libs/ardour/session_command.cc
Command* memento_command_factory(XMLNode* n);
+ Command* stateful_diff_command_factory (XMLNode *);
void register_with_memento_command_factory(PBD::ID, PBD::StatefulDestructible*);
/* clicking */
#include "pbd/id.h"
#include "pbd/statefuldestructible.h"
#include "pbd/failed_constructor.h"
+#include "pbd/stateful_diff_command.h"
#include "evoral/Curve.hpp"
using namespace PBD;
return 0 ;
}
+Command *
+Session::stateful_diff_command_factory (XMLNode* n)
+{
+ PBD::ID const id (n->property("obj-id")->value ());
+
+ string const obj_T = n->property ("type-name")->value ();
+ if ((obj_T == typeid (AudioRegion).name() || obj_T == typeid (MidiRegion).name()) && regions.count(id)) {
+ return new StatefulDiffCommand (regions[id].get(), *n);
+ }
+
+ /* we failed */
+
+ error << string_compose (
+ _("could not reconstitute StatefulDiffCommand from XMLNode. object type = %1 id = %2"), obj_T, id.to_s())
+ << endmsg;
+
+ return 0;
+}
error << string_compose (_("Region command references an unknown region ID=%1"), id.to_s()) << endmsg;
}
+ } else if (n->name() == "StatefulDiffCommand") {
+ if ((c = stateful_diff_command_factory (n))) {
+ ut->add_command (c);
+ }
} else {
error << string_compose(_("Couldn't figure out how to make a Command out of a %1 XMLNode."), n->name()) << endmsg;
}
class StatefulDiffCommand : public Command
{
public:
- StatefulDiffCommand (Stateful* s);
+ StatefulDiffCommand (Stateful *);
+ StatefulDiffCommand (Stateful *, XMLNode const &);
~StatefulDiffCommand ();
void operator() ();
*/
#include "pbd/stateful_diff_command.h"
+#include "i18n.h"
using namespace std;
using namespace PBD;
_after = p.second;
}
+StatefulDiffCommand::StatefulDiffCommand (Stateful* s, XMLNode const & n)
+ : _object (s)
+{
+ _before = new XMLNode (*n.children().front());
+ _after = new XMLNode (*n.children().back());
+}
+
StatefulDiffCommand::~StatefulDiffCommand ()
{
XMLNode&
StatefulDiffCommand::get_state ()
{
- /* XXX */
+ XMLNode* node = new XMLNode (X_("StatefulDiffCommand"));
+
+ node->add_property ("obj-id", _object->id().to_s());
+ node->add_property ("type-name", typeid(*_object).name());
+ node->add_child_copy (*_before);
+ node->add_child_copy (*_after);
+
+ return *node;
}