make Stateful::_id private and provide appropriate methods to set it, and use them...
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 18 Oct 2011 13:18:47 +0000 (13:18 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 18 Oct 2011 13:18:47 +0000 (13:18 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10222 d708f5d6-7413-0410-9779-e7cbd77b26cf

27 files changed:
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/editor.cc
gtk2_ardour/shuttle_control.cc
gtk2_ardour/shuttle_control.h
gtk2_ardour/time_axis_view_item.cc
libs/ardour/audio_diskstream.cc
libs/ardour/automation_list.cc
libs/ardour/crossfade.cc
libs/ardour/diskstream.cc
libs/ardour/io.cc
libs/ardour/location.cc
libs/ardour/lxvst_plugin.cc
libs/ardour/midi_diskstream.cc
libs/ardour/playlist.cc
libs/ardour/playlist_source.cc
libs/ardour/plugin_insert.cc
libs/ardour/processor.cc
libs/ardour/region.cc
libs/ardour/route.cc
libs/ardour/route_group.cc
libs/ardour/source.cc
libs/pbd/controllable.cc
libs/pbd/id.cc
libs/pbd/pbd/id.h
libs/pbd/pbd/stateful.h
libs/pbd/stateful.cc

index 5161a6626dc33e96d762c8acf98e77423ee71847..a1bbce29ee87cae16b98e81dbcd426f030b0bb35 100644 (file)
@@ -3701,12 +3701,6 @@ ARDOUR_UI::TransportControllable::get_value (void) const
        return val;
 }
 
-void
-ARDOUR_UI::TransportControllable::set_id (const string& str)
-{
-       _id = str;
-}
-
 void
 ARDOUR_UI::setup_profile ()
 {
index 08e0d42ab089dec16bca6350c5e6dce12079fba7..5c2a99290d5ba9ea7a3b6265bdcb37ddf652a02d 100644 (file)
@@ -401,8 +401,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
            void set_value (double);
            double get_value (void) const;
 
-           void set_id (const std::string&);
-
            ARDOUR_UI& ui;
            ToggleType type;
        };
index 78c6911116f25eb7ed916bcc222614df3aacaf09..08099c2972b14c4090164c6c869817f28d5501f8 100644 (file)
@@ -1244,7 +1244,7 @@ Editor::set_session (Session *t)
        }
 
        /* register for undo history */
-       _session->register_with_memento_command_factory(_id, this);
+       _session->register_with_memento_command_factory(id(), this);
 
        ActionManager::ui_manager->signal_pre_activate().connect (sigc::mem_fun (*this, &Editor::action_pre_activated));
 
@@ -2160,9 +2160,7 @@ Editor::set_state (const XMLNode& node, int /*version*/)
        int x, y;
        Gdk::Geometry g;
 
-       if ((prop = node.property ("id")) != 0) {
-               _id = prop->value ();
-       }
+       set_id (node);
 
        g.base_width = default_width;
        g.base_height = default_height;
@@ -2374,7 +2372,7 @@ Editor::get_state ()
        XMLNode* node = new XMLNode ("Editor");
        char buf[32];
 
-       _id.print (buf, sizeof (buf));
+       id().print (buf, sizeof (buf));
        node->add_property ("id", buf);
 
        if (is_realized()) {
index a496ddc0b25c4485daf96ca6d96625e691cea454..2fb2a3357e0ac9fdc56987ec8eb071ad864df4c2 100644 (file)
@@ -611,12 +611,6 @@ ShuttleControl::ShuttleControllable::ShuttleControllable (ShuttleControl& s)
 {
 }
 
-void
-ShuttleControl::ShuttleControllable::set_id (const std::string& str)
-{
-       _id = str;
-}
-
 void
 ShuttleControl::ShuttleControllable::set_value (double val)
 {
index 03ec0059587cea65b0e89367ec6e0f68db0127b5..ab58969743bbb5609dafeb9628b4cbb6c6134b2e 100644 (file)
@@ -49,8 +49,6 @@ class ShuttleControl : public Gtk::DrawingArea, public ARDOUR::SessionHandlePtr
                void set_value (double);
                double get_value (void) const;
 
-               void set_id (const std::string&);
-
                ShuttleControl& sc;
        };
 
index d9b0bfa2cf42c972612d6ea9953f7a898df24afa..9df586bf7f2de7d75074214afe30b2122713e0f9 100644 (file)
@@ -109,7 +109,8 @@ TimeAxisViewItem::TimeAxisViewItem(
 }
 
 TimeAxisViewItem::TimeAxisViewItem (const TimeAxisViewItem& other)
-       : Selectable (other)
+       : trackable (other)
+       , Selectable (other)
        , PBD::ScopedConnectionList()
        , trackview (other.trackview)
        , _recregion (other._recregion)
index 243ccdb9d15bfbc9d62789c5acf0cc94e98de7b5..436506c857ebee22aa867cfed52781339e684a56 100644 (file)
@@ -773,7 +773,7 @@ AudioDiskstream::overwrite_existing_buffers ()
 
                if (read ((*chan)->playback_buf->buffer() + overwrite_offset, mixdown_buffer, gain_buffer, start, to_read, *chan, n, reversed)) {
                        error << string_compose(_("AudioDiskstream %1: when refilling, cannot read %2 from playlist at frame %3"),
-                                        _id, size, playback_sample) << endmsg;
+                                               id(), size, playback_sample) << endmsg;
                        goto out;
                }
 
@@ -784,7 +784,7 @@ AudioDiskstream::overwrite_existing_buffers ()
                        if (read ((*chan)->playback_buf->buffer(), mixdown_buffer, gain_buffer,
                                  start, cnt, *chan, n, reversed)) {
                                error << string_compose(_("AudioDiskstream %1: when refilling, cannot read %2 from playlist at frame %3"),
-                                                _id, size, playback_sample) << endmsg;
+                                                       id(), size, playback_sample) << endmsg;
                                goto out;
                        }
                }
@@ -933,7 +933,7 @@ AudioDiskstream::read (Sample* buf, Sample* mixdown_buffer, float* gain_buffer,
                this_read = min(cnt,this_read);
 
                if (audio_playlist()->read (buf+offset, mixdown_buffer, gain_buffer, start, this_read, channel) != this_read) {
-                       error << string_compose(_("AudioDiskstream %1: cannot read %2 from playlist at frame %3"), _id, this_read,
+                       error << string_compose(_("AudioDiskstream %1: cannot read %2 from playlist at frame %3"), id(), this_read,
                                         start) << endmsg;
                        return -1;
                }
@@ -1302,7 +1302,7 @@ AudioDiskstream::do_flush (RunContext /*context*/, bool force_flush)
                }
 
                if ((!(*chan)->write_source) || (*chan)->write_source->write (vector.buf[0], to_write) != to_write) {
-                       error << string_compose(_("AudioDiskstream %1: cannot write to disk"), _id) << endmsg;
+                       error << string_compose(_("AudioDiskstream %1: cannot write to disk"), id()) << endmsg;
                        return -1;
                }
 
@@ -1319,7 +1319,7 @@ AudioDiskstream::do_flush (RunContext /*context*/, bool force_flush)
                        to_write = min ((framecnt_t)(disk_io_chunk_frames - to_write), (framecnt_t) vector.len[1]);
 
                        if ((*chan)->write_source->write (vector.buf[1], to_write) != to_write) {
-                               error << string_compose(_("AudioDiskstream %1: cannot write to disk"), _id) << endmsg;
+                               error << string_compose(_("AudioDiskstream %1: cannot write to disk"), id()) << endmsg;
                                return -1;
                        }
 
index b2bda4a20302dd572de6d15fafc674ebb8874874..2e28bb8bb16bb82acd835b0af440ac0a406d3b52 100644 (file)
@@ -270,7 +270,7 @@ AutomationList::state (bool full)
 
        root->add_property ("automation-id", EventTypeMap::instance().to_symbol(_parameter));
 
-       root->add_property ("id", _id.to_s());
+       root->add_property ("id", id().to_s());
 
        snprintf (buf, sizeof (buf), "%.12g", _default_value);
        root->add_property ("default", buf);
@@ -437,8 +437,7 @@ AutomationList::set_state (const XMLNode& node, int version)
                return -1;
        }
 
-       if ((prop = node.property ("id")) != 0) {
-               _id = prop->value ();
+       if (set_id (node)) {
                /* update session AL list */
                AutomationListCreated(this);
        }
index dc8d3e3c526f2ec6c2332bb2f9f6ccb13d73e5a0..f06fcfb280bb7144bbb5a5c79e52aef7a2794565 100644 (file)
@@ -778,9 +778,7 @@ Crossfade::set_state (const XMLNode& node, int /*version*/)
        PropertyChange what_changed;
        framepos_t val;
 
-       if ((prop = node.property (X_("id")))) {
-               _id = prop->value();
-       }
+       set_id (node);
 
        if ((prop = node.property ("position")) != 0) {
                sscanf (prop->value().c_str(), "%" PRId64, &val);
index 6501998171887ab2e7246351690214223f50d8a4..21bbbbd849630512f01ddc29f8473a30da91b8eb 100644 (file)
@@ -495,13 +495,9 @@ Diskstream::set_state (const XMLNode& node, int /*version*/)
        }
 
        if (deprecated_io_node) {
-               if ((prop = deprecated_io_node->property ("id")) != 0) {
-                       _id = prop->value ();
-               }
+               set_id (*deprecated_io_node);
        } else {
-               if ((prop = node.property ("id")) != 0) {
-                       _id = prop->value ();
-               }
+               set_id (node);
        }
 
        if ((prop = node.property ("flags")) != 0) {
index 6aaca08c909aed08b8993821a06423ecb19ef548..ca34b7db6191f91d7f9462a51cd0b80edfa6c933 100644 (file)
@@ -575,9 +575,7 @@ IO::set_state (const XMLNode& node, int version)
                assert(_default_type != DataType::NIL);
        }
 
-       if ((prop = node.property ("id")) != 0) {
-               _id = prop->value ();
-       }
+       set_id (node);
 
        if ((prop = node.property ("direction")) != 0) {
                _direction = (Direction) string_2_enum (prop->value(), _direction);
@@ -633,9 +631,7 @@ IO::set_state_2X (const XMLNode& node, int version, bool in)
                assert(_default_type != DataType::NIL);
        }
 
-       if ((prop = node.property ("id")) != 0) {
-               _id = prop->value ();
-       }
+       set_id (node);
 
        _direction = in ? Input : Output;
 
index b6a09d863ab189a5e3ea1a84209c6ad4ad02f366..ed9f34ff8bc147798abe76b25ae2bc3bf8cb96cd 100644 (file)
@@ -419,10 +419,8 @@ Location::set_state (const XMLNode& node, int /*version*/)
                return -1;
        }
 
-       if ((prop = node.property ("id")) == 0) {
+       if (!set_id (node)) {
                warning << _("XML node for Location has no ID information") << endmsg;
-       } else {
-               _id = prop->value ();
        }
 
        if ((prop = node.property ("name")) == 0) {
index 26136b45892f5df08399e491ccb54161a01791ab..21bfdb42f5437c8ddfd29916048323c3631505cf 100755 (executable)
@@ -366,10 +366,8 @@ LXVSTPlugin::load_user_preset (PresetRecord r)
        XMLNode* root = t->root ();
 
        for (XMLNodeList::const_iterator i = root->children().begin(); i != root->children().end(); ++i) {
-               XMLProperty* uri = (*i)->property (X_("uri"));
                XMLProperty* label = (*i)->property (X_("label"));
 
-               assert (uri);
                assert (label);
 
                if (label->value() != r.label) {
index 28ee12cc5ae3f574d0c24cf1bf4366a7883096d5..3dc54fe8625b0728d0b23e9696671eb0b3e7dcf6 100644 (file)
@@ -761,7 +761,7 @@ MidiDiskstream::read (framepos_t& start, framecnt_t dur, bool reversed)
                if (midi_playlist()->read (*_playback_buf, start, this_read) != this_read) {
                        error << string_compose(
                                        _("MidiDiskstream %1: cannot read %2 from playlist at frame %3"),
-                                       _id, this_read, start) << endmsg;
+                                       id(), this_read, start) << endmsg;
                        return -1;
                }
 
@@ -905,7 +905,7 @@ MidiDiskstream::do_flush (RunContext /*context*/, bool force_flush)
 
        if (record_enabled() && ((total > disk_io_chunk_frames) || force_flush)) {
                if (_write_source->midi_write (*_capture_buf, get_capture_start_frame (0), to_write) != to_write) {
-                       error << string_compose(_("MidiDiskstream %1: cannot write to disk"), _id) << endmsg;
+                       error << string_compose(_("MidiDiskstream %1: cannot write to disk"), id()) << endmsg;
                        return -1;
                } 
        }
index 6fad2084e4e267ae370f0fba2ee562f19179c666..0e86d72bb14ca37911f74cc96b791ed67363f1f2 100644 (file)
@@ -2213,6 +2213,8 @@ Playlist::flush_notifications (bool from_undo)
 
         plist = node.properties();
 
+        set_id (node);
+
         for (piter = plist.begin(); piter != plist.end(); ++piter) {
 
                 prop = *piter;
@@ -2220,8 +2222,6 @@ Playlist::flush_notifications (bool from_undo)
                 if (prop->name() == X_("name")) {
                         _name = prop->value();
                         _set_sort_id ();
-                } else if (prop->name() == X_("id")) {
-                        _id = prop->value();
                 } else if (prop->name() == X_("orig-diskstream-id")) {
                         _orig_diskstream_id = prop->value ();
                 } else if (prop->name() == X_("frozen")) {
index 4c01831b02380012c077a8c3203c202687879d02..7583a4e6ea1a2982a78043d8af755bb6b07dd270 100644 (file)
@@ -86,7 +86,7 @@ PlaylistSource::add_state (XMLNode& node)
        node.add_property ("offset", buf);
        snprintf (buf, sizeof (buf), "%" PRIu64, _playlist_length);
        node.add_property ("length", buf);
-       node.add_property ("original", _id.to_s());
+       node.add_property ("original", id().to_s());
 
        node.add_child_nocopy (_playlist->get_state());
 }
@@ -141,11 +141,15 @@ PlaylistSource::set_state (const XMLNode& node, int /*version*/)
 
        sscanf (prop->value().c_str(), "%" PRIu64, &_playlist_length);
 
+       /* XXX not quite sure why we set our ID back to the "original" one
+          here. october 2011, paul
+       */
+
        if ((prop = node.property (X_("original"))) == 0) {
                throw failed_constructor ();
        }
 
-       _id = prop->value();
+       set_id (prop->value());
 
        _level = _playlist->max_source_level () + 1;
 
index b44f1d01fc1dfaa900062888e0e0b1ecec604cfc..ea95ed09e56aa9873cc67a5cdc0bc4a0a78b2abe 100644 (file)
@@ -75,9 +75,6 @@ PluginInsert::PluginInsert (Session& s, boost::shared_ptr<Plugin> plug)
        if (plug) {
                add_plugin (plug);
                create_automatable_parameters ();
-
-               Glib::Mutex::Lock em (_session.engine().process_lock());
-               IO::PortCountChanged (max(input_streams(), output_streams()));
        }
 }
 
@@ -950,9 +947,7 @@ PluginInsert::set_state(const XMLNode& node, int version)
        // state. We can't call Processor::set_state() until
        // the plugins themselves are created and added.
 
-       if ((prop = node.property ("id")) != 0) {
-               _id = prop->value();
-       }
+       set_id (node);
 
        if (_plugins.empty()) {
                /* if we are adding the first plugin, we will need to set
index 8b54bd4f55bcd70aef5ab653359af7e518360e64..cf641fd7cffefa475dc1f1b9683d25cca5f89798 100644 (file)
@@ -150,9 +150,7 @@ Processor::set_state_2X (const XMLNode & node, int /*version*/)
                                set_name (prop->value ());
                        }
 
-                       if ((prop = (*i)->property ("id")) != 0) {
-                               _id = prop->value ();
-                       }
+                       set_id (**i);
 
                        if ((prop = (*i)->property ("active")) != 0) {
                                bool const a = string_is_affirmative (prop->value ());
@@ -188,10 +186,7 @@ Processor::set_state (const XMLNode& node, int version)
                Processor::set_name (prop->value());
        }
 
-       // may not exist for legacy 3.0 sessions
-       if ((prop = node.property ("id")) != 0) {
-               _id = prop->value();
-       }
+       set_id (node);
 
        XMLNodeList nlist = node.children();
        XMLNodeIterator niter;
index 2ce823777b2e308801f38208ca1ff8ae224149e6..c0156903b34cd78ca32551250e79d497287633e0 100644 (file)
@@ -1167,7 +1167,7 @@ Region::state ()
 
        add_properties (*node);
 
-       _id.print (buf, sizeof (buf));
+       id().print (buf, sizeof (buf));
        node->add_property ("id", buf);
        node->add_property ("type", _type.to_string());
 
@@ -1259,9 +1259,7 @@ Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_c
 
        what_changed = set_values (node);
 
-       if ((prop = node.property (X_("id")))) {
-               _id = prop->value();
-       }
+       set_id (node);
 
        if (_position_lock_style == MusicTime) {
                if ((prop = node.property ("bbt-position")) == 0) {
index cee897b1196560ec6fa362b5b1789039ac886b6a..a051cdb3d3725f96b9e5b401a3ee08780efd6313 100644 (file)
@@ -1886,9 +1886,7 @@ Route::_set_state (const XMLNode& node, int version, bool /*call_base*/)
                Route::set_name (prop->value());
        }
 
-       if ((prop = node.property ("id")) != 0) {
-               _id = prop->value ();
-       }
+       set_id (node);
 
        if ((prop = node.property (X_("flags"))) != 0) {
                _flags = Flag (string_2_enum (prop->value(), _flags));
@@ -2216,9 +2214,7 @@ Route::_set_state_2X (const XMLNode& node, int version)
                                Route::set_name (prop->value ());
                        }
 
-                       if ((prop = child->property (X_("id"))) != 0) {
-                               _id = prop->value ();
-                       }
+                       set_id (*child);
 
                        if ((prop = child->property (X_("active"))) != 0) {
                                bool yn = string_is_affirmative (prop->value());
index 42aa30c0f17e4d886d43828f845197f9ecf6c474..fadd436169419df7784ea163ad0493276f934175 100644 (file)
@@ -251,10 +251,7 @@ RouteGroup::set_state (const XMLNode& node, int version)
 
        const XMLProperty *prop;
 
-       if ((prop = node.property ("id")) != 0) {
-               _id = prop->value();
-       }
-
+       set_id (node);
        set_values (node);
 
        if ((prop = node.property ("routes")) != 0) {
index 35e1417fb4c14e92abc5a8af7e7b31199b1653c3..4c582f3ad741146d4af653e96ce5a5380dac5181 100644 (file)
@@ -100,7 +100,7 @@ Source::get_state ()
        node->add_property ("name", name());
        node->add_property ("type", _type.to_string());
        node->add_property (X_("flags"), enum_2_string (_flags));
-       _id.print (buf, sizeof (buf));
+       id().print (buf, sizeof (buf));
        node->add_property ("id", buf);
 
        if (_timestamp != 0) {
@@ -122,9 +122,7 @@ Source::set_state (const XMLNode& node, int version)
                return -1;
        }
 
-       if ((prop = node.property ("id")) != 0) {
-               _id = prop->value ();
-       } else {
+       if (!set_id (node)) {
                return -1;
        }
 
@@ -221,7 +219,7 @@ Source::get_transients_path () const
        s = _session.analysis_dir ();
        parts.push_back (s);
 
-       s = _id.to_s();
+       s = id().to_s();
        s += '.';
        s += TransientDetector::operational_identifier();
        parts.push_back (s);
index 959abe443d9c8e9d93b9ae3e207f3e7a9ec276a9..51877ee206a1e126d76cd2c584975265840f1692 100644 (file)
@@ -107,7 +107,7 @@ Controllable::get_state ()
        char buf[64];
 
        node->add_property (X_("name"), _name); // not reloaded from XML state, just there to look at
-       _id.print (buf, sizeof (buf));
+       id().print (buf, sizeof (buf));
        node->add_property (X_("id"), buf);
        node->add_property (X_("flags"), enum_2_string (_flags));
        snprintf (buf, sizeof (buf), "%2.12f", get_value());
@@ -129,9 +129,7 @@ Controllable::set_state (const XMLNode& node, int /*version*/)
 
        Stateful::save_extra_xml (node);
 
-       if ((prop = node.property (X_("id"))) != 0) {
-               _id = prop->value();
-       } else {
+       if (!set_id (node)) {
                error << _("Controllable state node has no ID property") << endmsg;
                return -1;
        }
index b96863b0fa7e13cec60a82f052e5260256c6f2ac..d7ac1560a1c6698f7b37f0d18ec4531b04ceace4 100644 (file)
@@ -44,8 +44,7 @@ ID::init ()
 
 ID::ID ()
 {
-       Glib::Mutex::Lock lm (*counter_lock);
-       _id = _counter++;
+       reset ();
 }
 
 ID::ID (const ID& other)
@@ -58,6 +57,13 @@ ID::ID (string str)
        string_assign (str);
 }
 
+void
+ID::reset ()
+{
+       Glib::Mutex::Lock lm (*counter_lock);
+       _id = _counter++;
+}      
+
 int
 ID::string_assign (string str)
 {
index 7a32a29002c6f24004e659f50737c0ef0866f1e7..6296fc29812520825b45ad71e03f1ed05bd8e08a 100644 (file)
@@ -33,6 +33,8 @@ class ID {
        ID (std::string);
        ID (const ID&);
 
+       void reset ();
+
        bool operator== (const ID& other) const {
                return _id == other._id; 
        }
index dd1659db556e1d1b8d3df6dcbc938c47160df744..2d5b2a0990d03dffc9d3d3813168e3db2b1fdc63 100644 (file)
@@ -65,7 +65,10 @@ class Stateful {
        void save_extra_xml (const XMLNode&);
 
        const PBD::ID& id() const { return _id; }
-        
+       bool set_id (const XMLNode&);
+       void set_id (const std::string&);
+       void reset_id ();
+
         /* history management */
 
        void clear_changes ();
@@ -106,7 +109,6 @@ class Stateful {
 
        XMLNode *_extra_xml;
        XMLNode *_instant_xml;
-       PBD::ID  _id;
         int32_t  _frozen;
        PBD::PropertyChange     _pending_changed;
         Glib::Mutex _lock;
@@ -120,6 +122,9 @@ class Stateful {
         */
         virtual void mid_thaw (const PropertyChange&) { }
         bool property_changes_suspended() const { return g_atomic_int_get (&_frozen) > 0; }
+
+  private:
+       PBD::ID  _id;
 };
 
 } // namespace PBD
index 47d1e66ef4fcf29f53da5599a73c431c688967ad..b2c76f452f4e6d03cd7b6ca012e9412396d6bf1f 100644 (file)
@@ -369,5 +369,29 @@ Stateful::clear_owned_changes ()
        }
 }
   
+bool
+Stateful::set_id (const XMLNode& node) 
+{
+       const XMLProperty* prop;
+
+       if ((prop = node.property ("id")) != 0) {
+               _id = prop->value ();
+               return true;
+       } 
+
+       return false;
+}
+
+void
+Stateful::reset_id ()
+{
+       _id = ID ();
+}
+
+void
+Stateful::set_id (const string& str)
+{
+       _id = str;
+}
 
 } // namespace PBD