summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-08-22 23:53:00 +0000
committerCarl Hetherington <carl@carlh.net>2010-08-22 23:53:00 +0000
commit74801c321279d166cd1e47e79ffdfd9b33e08ccc (patch)
treea60fe1fc9ca2a8720ba1de9dbec24028b8cc9b9d /libs
parent71a4796dc3dbf8a7fe1df5c5d7acea388b40eae0 (diff)
Move some RegionListProperty methods up to SequenceProperty.
git-svn-id: svn://localhost/ardour2/branches/3.0@7668 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/playlist.h15
-rw-r--r--libs/ardour/playlist.cc36
-rw-r--r--libs/pbd/pbd/sequence_property.h45
3 files changed, 50 insertions, 46 deletions
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 450e1dc75f..d87c6cb3a0 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -59,28 +59,19 @@ namespace Properties {
extern PBD::PropertyDescriptor<bool> regions;
}
-class RegionListProperty : public PBD::SequenceProperty<std::list<boost::shared_ptr<Region > > >
+class RegionListProperty : public PBD::SequenceProperty<std::list<boost::shared_ptr<Region> > >
{
public:
RegionListProperty (Playlist&);
boost::shared_ptr<Region> lookup_id (const PBD::ID& id);
- void diff (PBD::PropertyList& undo, PBD::PropertyList& redo, Command*) const;
- bool involves (boost::shared_ptr<Region>);
private:
- friend class Playlist;
- std::list<boost::shared_ptr<Region> > rlist() { return _val; }
+ PBD::SequenceProperty<std::list<boost::shared_ptr<Region> > >* create () const;
+ friend class Playlist;
/* we live and die with our playlist, no lifetime management needed */
Playlist& _playlist;
-
- /* create a copy of this RegionListProperty that only
- has what is needed for use in a history list command. This
- means that it won't contain the actual region list but
- will have the added/removed list.
- */
- RegionListProperty* copy_for_history () const;
};
class Playlist : public SessionObject
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 8ea84b96bf..851cf8596e 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -124,41 +124,9 @@ RegionListProperty::lookup_id (const ID& id)
return ret;
}
-RegionListProperty*
-RegionListProperty::copy_for_history () const
+SequenceProperty<std::list<boost::shared_ptr<Region> > >* RegionListProperty::create () const
{
- RegionListProperty* copy = new RegionListProperty (_playlist);
- /* this is all we need */
- copy->_change = _change;
- return copy;
-}
-
-void
-RegionListProperty::diff (PropertyList& undo, PropertyList& redo, Command* cmd) const
-{
- if (changed()) {
- /* list of the removed/added regions since clear_history() was last called */
- RegionListProperty* a = copy_for_history ();
-
- /* the same list, but with removed/added lists swapped (for undo purposes) */
- RegionListProperty* b = copy_for_history ();
- b->invert_changes ();
-
- if (cmd) {
- /* whenever one of the regions emits DropReferences, make sure
- that the Destructible we've been told to notify hears about
- it. the Destructible is likely to be the Command being built
- with this diff().
- */
-
- for (set<boost::shared_ptr<Region> >::iterator i = a->change().added.begin(); i != a->change().added.end(); ++i) {
- (*i)->DropReferences.connect_same_thread (*cmd, boost::bind (&Destructible::drop_references, cmd));
- }
- }
-
- undo.add (b);
- redo.add (a);
- }
+ return new RegionListProperty (_playlist);
}
Playlist::Playlist (Session& sess, string nom, DataType type, bool hide)
diff --git a/libs/pbd/pbd/sequence_property.h b/libs/pbd/pbd/sequence_property.h
index b12578837a..38a7c27f45 100644
--- a/libs/pbd/pbd/sequence_property.h
+++ b/libs/pbd/pbd/sequence_property.h
@@ -30,6 +30,7 @@
#include "pbd/convert.h"
#include "pbd/id.h"
#include "pbd/property_basics.h"
+#include "pbd/property_list.h"
namespace PBD {
@@ -193,6 +194,34 @@ class SequenceProperty : public PropertyBase
_update_callback (cr);
}
+ void diff (PBD::PropertyList& undo, PBD::PropertyList& redo, Command* cmd) const {
+ if (changed ()) {
+ /* list of the removed/added items since clear_history() was last called */
+ SequenceProperty<Container>* a = copy_for_history ();
+
+ /* the same list, but with removed/added lists swapped (for undo purposes) */
+ SequenceProperty<Container>* b = copy_for_history ();
+ b->invert_changes ();
+
+ if (cmd) {
+ /* whenever one of the items emits DropReferences, make sure
+ that the Destructible we've been told to notify hears about
+ it. the Destructible is likely to be the Command being built
+ with this diff().
+ */
+
+ for (typename ChangeContainer::iterator i = a->change().added.begin(); i != a->change().added.end(); ++i) {
+ (*i)->DropReferences.connect_same_thread (*cmd, boost::bind (&Destructible::drop_references, cmd));
+ }
+ }
+
+ undo.add (b);
+ redo.add (a);
+ }
+ }
+
+ Container rlist() { return _val; }
+
/* Wrap salient methods of Sequence
*/
@@ -332,6 +361,22 @@ class SequenceProperty : public PropertyBase
return true;
}
+
+private:
+ virtual SequenceProperty<Container>* create () const = 0;
+
+ /* create a copy of this ListSequenceProperty that only
+ has what is needed for use in a history list command. This
+ means that it won't contain the actual item list but
+ will have the added/removed list.
+ */
+
+ SequenceProperty<Container>* copy_for_history () const {
+ SequenceProperty<Container>* copy = create ();
+ /* this is all we need */
+ copy->_change = _change;
+ return copy;
+ }
};
}