summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-03-31 22:17:01 +0000
committerCarl Hetherington <carl@carlh.net>2010-03-31 22:17:01 +0000
commit7f8b337d309fe62a442ef8c3086b7eb97c7e57e9 (patch)
treecc842e1a34520822a8cb9a1b887aac093775640a /libs
parentcc227eb75e8c920424313286417d325e58efaa94 (diff)
A few small cleanups to the property code.
git-svn-id: svn://localhost/ardour2/branches/3.0@6816 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/playlist.cc2
-rw-r--r--libs/pbd/pbd/properties.h8
-rw-r--r--libs/pbd/pbd/property_basics.h14
-rw-r--r--libs/pbd/pbd/sequence_property.h14
4 files changed, 15 insertions, 23 deletions
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 35b0aedcd8..3af4d22430 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -133,7 +133,7 @@ RegionListProperty::copy_for_history () const
void
RegionListProperty::diff (PropertyList& before, PropertyList& after) const
{
- if (_have_old) {
+ if (changed()) {
RegionListProperty* a = copy_for_history ();
RegionListProperty* b = copy_for_history ();
diff --git a/libs/pbd/pbd/properties.h b/libs/pbd/pbd/properties.h
index 8d2f465ebf..691ab9c4ad 100644
--- a/libs/pbd/pbd/properties.h
+++ b/libs/pbd/pbd/properties.h
@@ -40,6 +40,7 @@ class PropertyTemplate : public PropertyBase
public:
PropertyTemplate (PropertyDescriptor<T> p, T const& v)
: PropertyBase (p.property_id)
+ , _have_old (false)
, _current (v)
{}
@@ -79,6 +80,10 @@ public:
return _current;
}
+ void clear_history () {
+ _have_old = false;
+ }
+
/** If this property has been changed since the last clear_history() call
(or its construction), add an (XML) property describing the old value
to the XMLNode @param old and another describing the current value to
@@ -112,6 +117,8 @@ public:
owner_state.add_property (property_name(), to_string (_current));
}
+ bool changed () const { return _have_old; }
+
protected:
/** Constructs a PropertyTemplate with a default
value for _old and _current.
@@ -132,6 +139,7 @@ protected:
virtual std::string to_string (T const& v) const = 0;
virtual T from_string (std::string const& s) const = 0;
+ bool _have_old;
T _current;
T _old;
};
diff --git a/libs/pbd/pbd/property_basics.h b/libs/pbd/pbd/property_basics.h
index e818e36e90..251d71dc66 100644
--- a/libs/pbd/pbd/property_basics.h
+++ b/libs/pbd/pbd/property_basics.h
@@ -77,13 +77,10 @@ class PropertyBase
public:
PropertyBase (PropertyID pid)
: _property_id (pid)
- , _have_old (false)
{}
/** Forget about any old value for this state */
- virtual void clear_history () {
- _have_old = false;
- }
+ virtual void clear_history () = 0;
virtual void add_history_state (XMLNode*) const = 0;
virtual void diff (PropertyList&, PropertyList&) const = 0;
@@ -92,10 +89,10 @@ public:
virtual bool set_state_from_owner_state (XMLNode const&) = 0;
virtual void add_state_to_owner_state (XMLNode&) const = 0;
+ virtual bool changed() const = 0;
const gchar*property_name () const { return g_quark_to_string (_property_id); }
PropertyID property_id () const { return _property_id; }
- bool changed() const { return _have_old; }
bool operator==(PropertyID pid) const {
return _property_id == pid;
@@ -103,13 +100,6 @@ public:
protected:
PropertyID _property_id;
- bool _have_old;
-};
-
-class PropertyFactory
-{
- public:
- static PropertyBase* create (const XMLNode&);
};
}
diff --git a/libs/pbd/pbd/sequence_property.h b/libs/pbd/pbd/sequence_property.h
index c2ad939b7c..8bbc7c77d2 100644
--- a/libs/pbd/pbd/sequence_property.h
+++ b/libs/pbd/pbd/sequence_property.h
@@ -113,9 +113,12 @@ class SequenceProperty : public PropertyBase
owner_state_node.add_child_nocopy ((*i)->get_state ());
}
}
+
+ bool changed () const {
+ return !_change.added.empty() || !_change.removed.empty();
+ }
void clear_history () {
- PropertyBase::clear_history();
_change.added.clear ();
_change.removed.clear ();
}
@@ -145,21 +148,18 @@ class SequenceProperty : public PropertyBase
typename Container::const_reverse_iterator rend() const { return _val.rend(); }
typename Container::iterator insert (typename Container::iterator i, const typename Container::value_type& v) {
- _have_old = true;
_change.added.insert (v);
return _val.insert (i, v);
}
typename Container::iterator erase (typename Container::iterator i) {
if (i != _val.end()) {
- _have_old = true;
_change.removed.insert (*i);
}
return _val.erase (i);
}
typename Container::iterator erase (typename Container::iterator f, typename Container::iterator l) {
- _have_old = true;
for (typename Container::const_iterator i = f; i != l; ++i) {
_change.removed.insert(*i);
}
@@ -167,20 +167,17 @@ class SequenceProperty : public PropertyBase
}
void push_back (const typename Container::value_type& v) {
- _have_old = true;
_change.added.insert (v);
_val.push_back (v);
}
void push_front (const typename Container::value_type& v) {
- _have_old = true;
_change.added.insert (v);
_val.push_front (v);
}
void pop_front () {
if (!_val.empty()) {
- _have_old = true;
_change.removed.insert (front());
}
_val.pop_front ();
@@ -188,14 +185,12 @@ class SequenceProperty : public PropertyBase
void pop_back () {
if (!_val.empty()) {
- _have_old = true;
_change.removed.insert (front());
}
_val.pop_back ();
}
void clear () {
- _have_old = true;
_change.removed.insert (_val.begin(), _val.end());
_val.clear ();
}
@@ -209,7 +204,6 @@ class SequenceProperty : public PropertyBase
}
Container& operator= (const Container& other) {
- _have_old = true;
_change.removed.insert (_val.begin(), _val.end());
_change.added.insert (other.begin(), other.end());
return _val = other;