+Command *
+Session::stateful_diff_command_factory (XMLNode* n)
+{
+ PBD::ID const id (n->property("obj-id")->value ());
+
+ std::string const obj_T = n->property ("type-name")->value ();
+ if ((obj_T == "ARDOUR::AudioRegion" || obj_T == "ARDOUR::MidiRegion")) {
+ boost::shared_ptr<Region> r = RegionFactory::region_by_id (id);
+ if (r) {
+ return new StatefulDiffCommand (r, *n);
+ }
+
+ } else if (obj_T == "ARDOUR::AudioPlaylist" || obj_T == "ARDOUR::MidiPlaylist") {
+ boost::shared_ptr<Playlist> p = playlists->by_id (id);
+ if (p) {
+ return new StatefulDiffCommand (p, *n);
+ } else {
+ std::cerr << "Playlist with ID = " << id << " not found\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;
+}