summaryrefslogtreecommitdiff
path: root/libs/pbd/stateful.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-02-18 13:59:49 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-02-18 13:59:49 +0000
commitce7a5e1c9fa3edf2d9cc66875505e402a0aaa6f6 (patch)
tree8a798270cd892823c7eeef99c2f3cdd4bf657bb3 /libs/pbd/stateful.cc
parentcdcc4d3720d8168a158f6a5a5f23e9ce981bc68c (diff)
the Properties & 64bit region commit
git-svn-id: svn://localhost/ardour2/branches/3.0@6695 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/stateful.cc')
-rw-r--r--libs/pbd/stateful.cc88
1 files changed, 50 insertions, 38 deletions
diff --git a/libs/pbd/stateful.cc b/libs/pbd/stateful.cc
index a50c54d7f5..a8dd7a4177 100644
--- a/libs/pbd/stateful.cc
+++ b/libs/pbd/stateful.cc
@@ -35,27 +35,6 @@ namespace PBD {
int Stateful::current_state_version = 0;
int Stateful::loading_state_version = 0;
-PBD::Change
-new_change ()
-{
- Change c;
- static uint32_t change_bit = 1;
-
- /* catch out-of-range */
- if (!change_bit)
- {
- fatal << _("programming error: ")
- << "change_bit out of range in ARDOUR::new_change()"
- << endmsg;
- /*NOTREACHED*/
- }
-
- c = Change (change_bit);
- change_bit <<= 1; // if it shifts too far, change_bit == 0
-
- return c;
-}
-
Stateful::Stateful ()
{
_extra_xml = 0;
@@ -174,8 +153,8 @@ Stateful::instant_xml (const string& str, const sys::path& directory_path)
void
Stateful::clear_history ()
{
- for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) {
- (*i)->clear_history ();
+ for (OwnedPropertyList::iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ i->second->clear_history ();
}
}
@@ -185,42 +164,75 @@ Stateful::clear_history ()
* It is the caller's responsibility to delete the returned XMLNodes.
*/
pair<XMLNode *, XMLNode *>
-Stateful::diff ()
+Stateful::diff () const
{
XMLNode* old = new XMLNode (_xml_node_name);
XMLNode* current = new XMLNode (_xml_node_name);
- for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) {
- (*i)->diff (old, current);
+ for (OwnedPropertyList::const_iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ i->second->diff (old, current);
}
return make_pair (old, current);
}
+
+/** Modifies PropertyChange @param c to indicate what properties have changed since the last
+ time clear_history was called on this object. Note that not all properties have change
+ values - if this object has any such Property members, they will never show up in
+ the value of @param c. Note also that @param c is not cleared by this function.
+*/
+void
+Stateful::changed (PropertyChange& c) const
+{
+ for (OwnedPropertyList::const_iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ i->second->diff (c);
+ }
+}
-/** Set state of _states from an XML node.
+/** Set state of some/all _properties from an XML node.
* @param node Node.
- * @return Changes made.
+ * @return PropertyChanges made.
*/
-Change
-Stateful::set_state_using_states (XMLNode const & node)
+PropertyChange
+Stateful::set_properties (XMLNode const & node)
{
- Change c = Change (0);
-
- for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) {
- c = Change (c | (*i)->set_state (node));
+ PropertyChange c = PropertyChange (0);
+
+ for (OwnedPropertyList::iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ c = PropertyChange (c | i->second->set_state (node));
+ }
+
+ post_set ();
+
+ return c;
+}
+
+PropertyChange
+Stateful::set_properties (const PropertyList& property_list)
+{
+ PropertyChange c = PropertyChange (0);
+ PropertyList::const_iterator p;
+
+ for (OwnedPropertyList::iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ if ((p = property_list.find (i->first)) != property_list.end()) {
+ c = PropertyChange (c|set_property (*(p->second)));
+ }
}
+
+ post_set ();
return c;
}
-/** Add state of _states to an XML node.
+
+/** Add property states to an XML node.
* @param node Node.
*/
void
-Stateful::add_states (XMLNode & node)
+Stateful::add_properties (XMLNode & node)
{
- for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) {
- (*i)->add_state (node);
+ for (OwnedPropertyList::iterator i = _properties.begin(); i != _properties.end(); ++i) {
+ i->second->add_state (node);
}
}