diff options
author | Carl Hetherington <carl@carlh.net> | 2011-09-21 15:54:19 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-09-21 15:54:19 +0000 |
commit | 185b58f259d558651bc33b0b560c27fa613f4b3b (patch) | |
tree | acc62312a83f941db7c5f9a584f9d564a9d9d432 /libs/pbd/pbd/memento_command.h | |
parent | 2e59536dd8f5d65c26fa19fc643831418efca876 (diff) |
Use a MementoCommandBinder for Crossfades so that the undo record can contain details for crossfades that are subsequently deleted (#4325).
git-svn-id: svn://localhost/ardour2/branches/3.0@10104 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/pbd/memento_command.h')
-rw-r--r-- | libs/pbd/pbd/memento_command.h | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/libs/pbd/pbd/memento_command.h b/libs/pbd/pbd/memento_command.h index 8b412937ef..45cb100a36 100644 --- a/libs/pbd/pbd/memento_command.h +++ b/libs/pbd/pbd/memento_command.h @@ -34,20 +34,32 @@ /** A class that can return a Stateful object which is the subject of a MementoCommand. * * The existence of this class means that the undo record can refer to objects which - * don't exist in the session file. Currently this is just used for MIDI automation; - * when MIDI automation is edited, undo records are written for the AutomationList being - * changed. However this AutomationList is a temporary structure, built by a MidiModel, - * which doesn't get written to the session file. Hence we need to be able to go from - * a MidiSource and Parameter to an AutomationList. This Binder mechanism allows this - * through MidiAutomationListBinder; the undo record stores the source and parameter, + * don't exist in the session file. Currently this is used for + * + * 1. MIDI automation; when MIDI automation is edited, undo records are + * written for the AutomationList being changed. However this AutomationList + * is a temporary structure, built by a MidiModel, which doesn't get written + * to the session file. Hence we need to be able to go from a MidiSource and + * Parameter to an AutomationList. This Binder mechanism allows this through + * MidiAutomationListBinder; the undo record stores the source and parameter, * and these are bound to an AutomationList by the Binder. + * + * 2. Crossfades; unlike regions, these are completely removed from a session + * when they are deleted. This means that the undo record can contain + * references to non-existant crossfades. To get around this, CrossfadeBinder + * can do `just-in-time' binding from the crossfade ID. */ template <class obj_T> class MementoCommandBinder : public PBD::Destructible { public: /** @return Stateful object to operate on */ - virtual obj_T* get () = 0; + virtual obj_T* get () const = 0; + + /** @return Name of our type */ + virtual std::string type_name () const { + return PBD::demangled_name (*get ()); + } /** Add our own state to an XMLNode */ virtual void add_state (XMLNode *) = 0; @@ -64,7 +76,7 @@ public: _object.Destroyed.connect_same_thread (_object_death_connection, boost::bind (&SimpleMementoCommandBinder::object_died, this)); } - obj_T* get () { + obj_T* get () const { return &_object; } @@ -140,7 +152,7 @@ public: XMLNode* node = new XMLNode(name); _binder->add_state (node); - node->add_property("type_name", demangled_name (*_binder->get())); + node->add_property ("type_name", _binder->type_name ()); if (before) { node->add_child_copy(*before); |