Rename various things in the property system.
authorCarl Hetherington <carl@carlh.net>
Wed, 25 Aug 2010 17:31:33 +0000 (17:31 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 25 Aug 2010 17:31:33 +0000 (17:31 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7681 d708f5d6-7413-0410-9779-e7cbd77b26cf

17 files changed:
gtk2_ardour/add_route_dialog.cc
gtk2_ardour/editor_route_groups.cc
gtk2_ardour/group_tabs.cc
gtk2_ardour/route_group_dialog.cc
gtk2_ardour/route_group_menu.cc
libs/ardour/playlist.cc
libs/ardour/region.cc
libs/ardour/region_factory.cc
libs/ardour/route_group.cc
libs/pbd/pbd/properties.h
libs/pbd/pbd/property_basics.h
libs/pbd/pbd/property_list.h
libs/pbd/pbd/sequence_property.h
libs/pbd/pbd/stateful.h
libs/pbd/property_list.cc
libs/pbd/stateful.cc
libs/pbd/stateful_diff_command.cc

index e7ae4454aa2bfae89ff31c406e7e320bb831c011..72a19ca6efd4f5149dc4ca2876ef147a9156c718 100644 (file)
@@ -416,7 +416,7 @@ AddRouteDialog::group_changed ()
 
                PropertyList plist;
                plist.add (Properties::active, true);
-               g->set_properties (plist);
+               g->apply_changes (plist);
 
                RouteGroupDialog d (g, Gtk::Stock::NEW);
                int const r = d.do_run ();
index b66fa753da642f63847e12af4d78e2b8a920e5a1..2f9f27ae2c107372906c2ed099dbf5487e16ca2e 100644 (file)
@@ -366,7 +366,7 @@ EditorRouteGroups::row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel
        
        group->set_hidden (!(*iter)[_columns.is_visible], this);
        
-       group->set_properties (plist);
+       group->apply_changes (plist);
 }
 
 void
index de8e45e854a65a42548fa03408b212d53a1639d4..560d1f7c111bb123da79e0587dd0ef24225a180e 100644 (file)
@@ -379,7 +379,7 @@ void
 GroupTabs::run_new_group_dialog (RouteList const & rl)
 {
        RouteGroup* g = new RouteGroup (*_session, "");
-       g->set_properties (default_properties ());
+       g->apply_changes (default_properties ());
 
        RouteGroupDialog d (g, Gtk::Stock::NEW);
        int const r = d.do_run ();
@@ -402,7 +402,7 @@ GroupTabs::create_and_add_group () const
 {
        RouteGroup* g = new RouteGroup (*_session, "");
 
-       g->set_properties (default_properties ());
+       g->apply_changes (default_properties ());
 
        RouteGroupDialog d (g, Gtk::Stock::NEW);
        int const r = d.do_run ();
index 176c23d8e2ae468a069b76e2f278715002efdeaf..a65807d75da6d242b13dd6f1851339e41e8a210a 100644 (file)
@@ -140,7 +140,7 @@ RouteGroupDialog::do_run ()
                plist.add (Properties::active, _active.get_active());
                plist.add (Properties::name, string (_name.get_text()));
 
-               _group->set_properties (plist);
+               _group->apply_changes (plist);
        }
 
        return r;
index baf383be5d2f669f57431643752444cb5252f8cb..42d09ab9602f631f539996080d276637a5083c1d 100644 (file)
@@ -108,7 +108,7 @@ RouteGroupMenu::new_group ()
        }
 
        RouteGroup* g = new RouteGroup (*_session, "");
-       g->set_properties (*_default_properties);
+       g->apply_changes (*_default_properties);
 
        RouteGroupDialog d (g, Gtk::Stock::NEW);
        int const r = d.do_run ();
index 851cf8596ede7e518861cf14c8b062cc1ecf2a3e..6ff51193d911cd8c2d02fd45ef53d9155babfaf5 100644 (file)
@@ -2144,7 +2144,7 @@ Playlist::property_factory (const XMLNode& history_node) const
                         
                         RegionListProperty* rlp = new RegionListProperty (*const_cast<Playlist*> (this));
 
-                        if (rlp->load_history_state (**i)) {
+                        if (rlp->set_change (**i)) {
                                 if (!prop_list) {
                                         prop_list = new PropertyList();
                                 }
index 65f7d6fedc01110bb13777beef8d707346aefbe6..da26c87f26c41a95aa3516f1d22c4cd5cdc93da3 100644 (file)
@@ -1216,7 +1216,7 @@ Region::_set_state (const XMLNode& node, int version, PropertyChange& what_chang
 {
        const XMLProperty* prop;
 
-       what_changed = set_properties (node);
+       what_changed = set_values (node);
 
        if ((prop = node.property (X_("id")))) {
                _id = prop->value();
index b4beddfb640610a2709891373736a8885e78aa5b..a8b0d436d64ac0334ac0cb8d8ebe5f6a1baa19de 100644 (file)
@@ -123,7 +123,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, frameoffset_t offset, b
        }
 
        if (ret) {
-               ret->set_properties (plist);
+               ret->apply_changes (plist);
                map_add (ret);
 
                if (announce) {
@@ -162,7 +162,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs,
 
        if (ret) {
 
-               ret->set_properties (plist);
+               ret->apply_changes (plist);
                map_add (ret);
 
                if (announce) {
@@ -207,7 +207,7 @@ RegionFactory::create (const SourceList& srcs, const PropertyList& plist, bool a
 
        if (ret) {
 
-               ret->set_properties (plist);
+               ret->apply_changes (plist);
                map_add (ret);
 
                if (announce) {
index 0b0a07250905ac11fe6aa0dc84830335e66d6c96..f1631e4375111f4cd175105a0f11b6acd7b96434 100644 (file)
@@ -235,7 +235,7 @@ RouteGroup::set_state (const XMLNode& node, int version)
                return set_state_2X (node, version);
        }
 
-       set_properties (node);
+       set_values (node);
 
        const XMLProperty *prop;
 
@@ -260,7 +260,7 @@ RouteGroup::set_state (const XMLNode& node, int version)
 int
 RouteGroup::set_state_2X (const XMLNode& node, int /*version*/)
 {
-       set_properties (node);
+       set_values (node);
 
        if (node.name() == "MixGroup") {
                _gain = true;
index 1e17ddafb0fb67cfebc0dd98c060e7de2b4ae0e7..13790973e239950b4d82d45b78debc97551047cd 100644 (file)
@@ -85,20 +85,16 @@ public:
                _have_old = false;
        }
 
-       void add_history_state (XMLNode* history_node) const {
+       void get_change (XMLNode* history_node) const {
                /* We can get to the current state of a scalar property like this one simply
                   by knowing what the new state is.
                */
                 history_node->add_property (property_name(), to_string (_current));
        }
 
-       /** Try to set state from the property of an XML node.
-        *  @param node XML node.
-        *  @return true if the value of the property is changed
-        */
-       bool set_state_from_owner_state (XMLNode const& owner_state) {
+       bool set_value (XMLNode const & node) {
 
-               XMLProperty const* p = owner_state.property (property_name());
+               XMLProperty const* p = node.property (property_name());
 
                if (p) {
                        T const v = from_string (p->value ());
@@ -112,12 +108,13 @@ public:
                return false;
        }
 
-       void add_state_to_owner_state (XMLNode& owner_state) const {
-                owner_state.add_property (property_name(), to_string (_current));
+       void get_value (XMLNode & node) const {
+                node.add_property (property_name(), to_string (_current));
        }
 
        bool changed () const { return _have_old; }
-       void set_state_from_property (PropertyBase const * p) {
+       
+       void apply_change (PropertyBase const * p) {
                T v = dynamic_cast<const PropertyTemplate<T>* > (p)->val ();
                if (v != _current) {
                        set (v);
index 2dea20e251ff75bf9fdd5f87d7382c8c3da2f859..39a7c043e97c9afe9a3a25e1cd66f8beafedd8e2 100644 (file)
@@ -89,10 +89,8 @@ public:
        /** Forget about any old value for this state */
        virtual void clear_history () = 0;
 
-        /** Make XML that allows us to get from some previous state to the current state
-        *  of this property, and add it to @param history_node
-        */
-       virtual void add_history_state (XMLNode* history_node) const = 0;
+        /** Get any change in this property as XML and add it to a node */
+       virtual void get_change (XMLNode *) const = 0;
 
        /** Add information to two property lists: one that allows
         *  undo of the changes in this property's state betwen now and
@@ -103,19 +101,21 @@ public:
         
         virtual PropertyBase* maybe_clone_self_if_found_in_history_node (const XMLNode&) const { return 0; }
 
-       /** Set state from an XML node previously generated by add_history_state */
-       virtual bool set_state_from_owner_state (XMLNode const&) = 0;
+       /** Set our value from an XML node.
+        *  @return true if the value was set.
+        */
+       virtual bool set_value (XMLNode const &) = 0;
 
-       /** Add complete current state in XML form to an existing XML node @param node */
-       virtual void add_state_to_owner_state (XMLNode& node) const = 0;
+       /** Get our value and put it into an XML node */
+       virtual void get_value (XMLNode& node) const = 0;
 
        /** @return true if this property has changed in value since construction or since
         *  the last call to clear_history(), whichever was more recent.
         */
        virtual bool changed() const = 0;
 
-       /** Set the value of this property from another */
-       virtual void set_state_from_property (PropertyBase const *) = 0;
+       /** Apply a change contained in another Property to this one */
+       virtual void apply_change (PropertyBase const *) = 0;
 
        const gchar*property_name () const { return g_quark_to_string (_property_id); }
        PropertyID  property_id () const   { return _property_id; }
index db7d934fc0431367e7e92303b714fa25f2ced292..04112bad80001f26274349bf4ce1c98f30bf1699 100644 (file)
@@ -36,7 +36,7 @@ public:
         
        virtual ~PropertyList();
 
-        void add_history_state (XMLNode* before);
+        void get_changes (XMLNode *);
 
         /** Add a property (of some kind) to the list. Used when
             constructing PropertyLists that describe a change/operation.
index aab6a57ea1744504ad6b8c939be8a98ca571db87..1486437f58a6e2205334d146d2a7fc1052f778b5 100644 (file)
@@ -94,12 +94,8 @@ class SequenceProperty : public PropertyBase
                _change.removed.swap (_change.added);
         }
 
-       void add_history_state (XMLNode* history_node) const {
+       void get_change (XMLNode* history_node) const {
 
-               /* We could record the whole of the current state here, but its
-                  obviously more efficient just to record what has changed.
-               */
-                
                 XMLNode* child = new XMLNode (PBD::capitalize (property_name()));
                 history_node->add_child_nocopy (*child);
                 
@@ -121,14 +117,15 @@ class SequenceProperty : public PropertyBase
                }
        }
 
-       bool set_state_from_owner_state (XMLNode const& owner_state) {
+       bool set_value (XMLNode const &) {
+               /* XXX: not used, but probably should be */
                assert (false);
                return false;
        }
 
-       void add_state_to_owner_state (XMLNode& owner_state_node) const {
+       void get_value (XMLNode & node) const {
                 for (typename Container::const_iterator i = _val.begin(); i != _val.end(); ++i) {
-                        owner_state_node.add_child_nocopy ((*i)->get_state ());
+                        node.add_child_nocopy ((*i)->get_state ());
                 } 
        }
 
@@ -141,7 +138,7 @@ class SequenceProperty : public PropertyBase
                _change.removed.clear ();
        }
 
-       void set_state_from_property (PropertyBase const * p) {
+       void apply_change (PropertyBase const * p) {
                const ChangeRecord& change (dynamic_cast<const SequenceProperty*> (p)->change ());
                update (change);
        }
@@ -301,7 +298,7 @@ class SequenceProperty : public PropertyBase
          * @return true if loading succeeded, false otherwise
          */
 
-        bool load_history_state (const XMLNode& history_node) {
+       bool set_change (XMLNode const & history_node) {
 
                 const XMLNodeList& children (history_node.children());
 
index 1272a735f93d7487650ecf46795ff71a78dcc555..619de5d06f9c56ff30c703c8335bbe9836922abd 100644 (file)
@@ -48,9 +48,10 @@ class Stateful {
 
        virtual XMLNode& get_state (void) = 0;
        virtual int set_state (const XMLNode&, int version) = 0;
-       virtual bool set_property (const PropertyBase&);
 
-       PropertyChange set_properties (const PropertyList&);
+       virtual bool apply_change (PropertyBase const &);
+       PropertyChange apply_changes (PropertyList const &);
+       
         const OwnedPropertyList& properties() const { return *_properties; }
 
        void add_property (PropertyBase& s);
@@ -92,10 +93,8 @@ class Stateful {
        void add_instant_xml (XMLNode&, const sys::path& directory_path);
        XMLNode *instant_xml (const std::string& str, const sys::path& directory_path);
        void add_properties (XMLNode &);
-       /* derived types can call this from ::set_state() (or elsewhere)
-          to get basic property setting done.
-       */
-       PropertyChange set_properties (XMLNode const &);
+
+       PropertyChange set_values (XMLNode const &);
        
        /* derived classes can implement this to do cross-checking
           of property values after either a PropertyList or XML 
index ffe1170dd5b858660ff6303dc122837e5b5710b2..5c0de4bacfc776254cb7458398d01cdf9d8706de 100644 (file)
@@ -39,13 +39,13 @@ PropertyList::~PropertyList ()
 }
 
 void
-PropertyList::add_history_state (XMLNode* history_node)
+PropertyList::get_changes (XMLNode* history_node)
 {
         for (const_iterator i = begin(); i != end(); ++i) {
                 DEBUG_TRACE (DEBUG::Properties, string_compose ("Add before/after to %1 for %2\n",
                                                                 history_node->name(), 
                                                                 i->second->property_name()));
-                i->second->add_history_state (history_node);
+                i->second->get_change (history_node);
         }
 }
 
index 1c3d08b3a9c348fdf77df1a9baa090288dbc114b..f58c64603eb8c6a2ac3046c1496e47513f54aad2 100644 (file)
@@ -174,17 +174,18 @@ Stateful::diff (PropertyList& before, PropertyList& after, Command* cmd) const
        }
 }
 
-/** Set state of some/all _properties from an XML node.
- *  @param owner_state Node.
- *  @return PropertyChanges made.
+/** Set our property values from an XML node.
+ *  Derived types can call this from ::set_state() (or elsewhere)
+ *  to get basic property setting done.
+ *  @return IDs of properties that were changed.
  */
 PropertyChange
-Stateful::set_properties (XMLNode const & owner_state)
+Stateful::set_values (XMLNode const & node)
 {
        PropertyChange c;
         
        for (OwnedPropertyList::iterator i = _properties->begin(); i != _properties->end(); ++i) {
-               if (i->second->set_state_from_owner_state (owner_state)) {
+               if (i->second->set_value (node)) {
                        c.add (i->first);
                }
        }
@@ -195,7 +196,7 @@ Stateful::set_properties (XMLNode const & owner_state)
 }
 
 PropertyChange
-Stateful::set_properties (const PropertyList& property_list)
+Stateful::apply_changes (const PropertyList& property_list)
 {
        PropertyChange c;
        PropertyList::const_iterator p;
@@ -209,7 +210,7 @@ Stateful::set_properties (const PropertyList& property_list)
         for (PropertyList::const_iterator i = property_list.begin(); i != property_list.end(); ++i) {
                 if ((p = _properties->find (i->first)) != _properties->end()) {
                         DEBUG_TRACE (DEBUG::Stateful, string_compose ("actually setting property %1\n", p->second->property_name()));
-                       if (set_property (*i->second)) {
+                       if (apply_change (*i->second)) {
                                c.add (i->first);
                        }
                } else {
@@ -232,7 +233,7 @@ void
 Stateful::add_properties (XMLNode& owner_state)
 {
        for (OwnedPropertyList::iterator i = _properties->begin(); i != _properties->end(); ++i) {
-               i->second->add_state_to_owner_state (owner_state);
+               i->second->get_value (owner_state);
        }
 }
 
@@ -302,14 +303,14 @@ Stateful::changed() const
 }
 
 bool
-Stateful::set_property (const PropertyBase& prop)
+Stateful::apply_change (const PropertyBase& prop)
 {
        OwnedPropertyList::iterator i = _properties->find (prop.property_id());
        if (i == _properties->end()) {
                return false;
        }
 
-       i->second->set_state_from_property (&prop);
+       i->second->apply_change (&prop);
        return true;
 }
 
index 2c58acee142a0963ee77b134bb8e78fac6a4c50d..857235b803dd612b464b1529ac11c0e153be7dbd 100644 (file)
@@ -85,7 +85,7 @@ StatefulDiffCommand::operator() ()
        boost::shared_ptr<Stateful> s (_object.lock());
 
        if (s) {
-                s->set_properties (*_redo);
+                s->apply_changes (*_redo);
        }
 }
 
@@ -96,7 +96,7 @@ StatefulDiffCommand::undo ()
 
        if (s) {
                 std::cerr << "Undoing a stateful diff command\n";
-                s->set_properties (*_undo);
+                s->apply_changes (*_undo);
        }
 }
 
@@ -118,8 +118,8 @@ StatefulDiffCommand::get_state ()
         XMLNode* undo = new XMLNode (X_("Undo"));
         XMLNode* redo = new XMLNode (X_("Do"));
 
-        _undo->add_history_state (undo);
-        _redo->add_history_state (redo);
+        _undo->get_changes (undo);
+        _redo->get_changes (redo);
         
         node->add_child_nocopy (*undo);
         node->add_child_nocopy (*redo);