From: Carl Hetherington Date: Sat, 14 Feb 2009 19:45:30 +0000 (+0000) Subject: Make DnD copy processors using their XML representations. Remove unused X-Git-Tag: 3.0-alpha5~3703 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=9a3734a6bd0450faf92a8b1add2d5e052a4534ca;p=ardour.git Make DnD copy processors using their XML representations. Remove unused copy constructors from the Processor hierarchy, and declare them private to explicitly disallow copy construction. git-svn-id: svn://localhost/ardour2/branches/3.0@4556 d708f5d6-7413-0410-9779-e7cbd77b26cf --- diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 34e4f27ae0..ce7d0f5567 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -171,7 +171,14 @@ ProcessorBox::route_going_away () void ProcessorBox::object_drop (const list >& procs) { - paste_processor_list (procs); + for (std::list >::const_iterator i = procs.begin(); i != procs.end(); ++i) { + + XMLNode& state = (*i)->get_state (); + XMLNodeList nlist; + nlist.push_back (&state); + paste_processor_state (nlist); + delete &state; + } } void @@ -920,42 +927,15 @@ ProcessorBox::paste_processors () cerr << "paste from node called " << _rr_selection.processors.get_node().name() << endl; - paste_processor_state (_rr_selection.processors.get_node()); + paste_processor_state (_rr_selection.processors.get_node().children()); } void -ProcessorBox::paste_processor_list (const list >& processors) +ProcessorBox::paste_processor_state (const XMLNodeList& nlist) { - list > copies; - - for (list >::const_iterator i = processors.begin(); i != processors.end(); ++i) { - - boost::shared_ptr copy = Processor::clone (*i); - - copy->set_placement (_placement); - copies.push_back (copy); - } - - if (_route->add_processors (copies)) { - - string msg = _( - "Copying the set of processors on the clipboard failed,\n\ -probably because the I/O configuration of the plugins\n\ -could not match the configuration of this track."); - MessageDialog am (msg); - am.run (); - } -} - -void -ProcessorBox::paste_processor_state (const XMLNode& node) -{ - XMLNodeList nlist; XMLNodeConstIterator niter; list > copies; - nlist = node.children(); - cerr << "Pasting processor selection containing " << nlist.size() << endl; if (nlist.empty()) { @@ -966,14 +946,20 @@ ProcessorBox::paste_processor_state (const XMLNode& node) cerr << "try using " << (*niter)->name() << endl; XMLProperty const * type = (*niter)->property ("type"); assert (type); + + boost::shared_ptr p; try { if (type->value() == "send") { XMLNode n (**niter); Send::make_unique (n, _session); - copies.push_back (boost::shared_ptr (new Send (_session, n))); + p.reset (new Send (_session, n)); + } else { - copies.push_back (boost::shared_ptr (new PluginInsert (_session, **niter))); + p.reset (new PluginInsert (_session, **niter)); } + + p->set_placement (_placement); + copies.push_back (p); } catch (...) { cerr << "plugin insert constructor failed\n"; @@ -1024,23 +1010,6 @@ ProcessorBox::for_selected_processors (void (ProcessorBox::*method)(boost::share } } -void -ProcessorBox::clone_processors () -{ - RouteSelection& routes (_rr_selection.routes); - - if (!routes.empty()) { - if (_route->copy_processors (*routes.front(), _placement)) { - string msg = _( -"Copying the set of processors on the clipboard failed,\n\ -probably because the I/O configuration of the plugins\n\ -could not match the configuration of this track."); - MessageDialog am (msg); - am.run (); - } - } -} - void ProcessorBox::all_processors_active (bool state) { diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h index 0a6399caad..76c6426686 100644 --- a/gtk2_ardour/processor_box.h +++ b/gtk2_ardour/processor_box.h @@ -182,15 +182,13 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject void paste_processors (); void delete_processors (); void clear_processors (); - void clone_processors (); void rename_processors (); void for_selected_processors (void (ProcessorBox::*pmf)(boost::shared_ptr)); void get_selected_processors (vector >&); static Glib::RefPtr paste_action; - void paste_processor_list (const std::list >& processors); - void paste_processor_state (const XMLNode&); + void paste_processor_state (const XMLNodeList&); void activate_processor (boost::shared_ptr); void deactivate_processor (boost::shared_ptr); diff --git a/libs/ardour/ardour/io_processor.h b/libs/ardour/ardour/io_processor.h index af11e8cacf..985a2c387c 100644 --- a/libs/ardour/ardour/io_processor.h +++ b/libs/ardour/ardour/io_processor.h @@ -48,7 +48,6 @@ class IOProcessor : public Processor IOProcessor (Session&, const string& name, Placement, int input_min = -1, int input_max = -1, int output_min = -1, int output_max = -1, ARDOUR::DataType default_type = DataType::AUDIO); - IOProcessor (const IOProcessor&); virtual ~IOProcessor (); virtual ChanCount output_streams() const; @@ -74,6 +73,11 @@ class IOProcessor : public Processor protected: boost::shared_ptr _io; + + private: + /* disallow copy construction */ + IOProcessor (const IOProcessor&); + }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/meter.h b/libs/ardour/ardour/meter.h index 112f306ccb..2cf474afba 100644 --- a/libs/ardour/ardour/meter.h +++ b/libs/ardour/ardour/meter.h @@ -63,6 +63,8 @@ public: } private: + /* disallow copy construction */ + PeakMeter (PeakMeter const &); friend class IO; void meter(); diff --git a/libs/ardour/ardour/panner.h b/libs/ardour/ardour/panner.h index 34b99e63bf..f6839f6d29 100644 --- a/libs/ardour/ardour/panner.h +++ b/libs/ardour/ardour/panner.h @@ -298,6 +298,9 @@ class Panner : public Processor } private: + /* disallow copy construction */ + Panner (Panner const &); + void distribute_no_automation(BufferSet& src, BufferSet& dest, nframes_t nframes, nframes_t offset, gain_t gain_coeff); std::vector _streampanners; uint32_t current_outs; diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h index 2583728ef3..ee5c7405fb 100644 --- a/libs/ardour/ardour/plugin_insert.h +++ b/libs/ardour/ardour/plugin_insert.h @@ -46,7 +46,6 @@ class PluginInsert : public Processor public: PluginInsert (Session&, boost::shared_ptr, Placement); PluginInsert (Session&, const XMLNode&); - PluginInsert (const PluginInsert&); ~PluginInsert (); static const string port_automation_node_name; @@ -117,6 +116,8 @@ class PluginInsert : public Processor } private: + /* disallow copy construction */ + PluginInsert (const PluginInsert&); void parameter_changed (Evoral::Parameter, float); diff --git a/libs/ardour/ardour/port_insert.h b/libs/ardour/ardour/port_insert.h index 55f91569d5..78ff09124b 100644 --- a/libs/ardour/ardour/port_insert.h +++ b/libs/ardour/ardour/port_insert.h @@ -42,7 +42,6 @@ class PortInsert : public IOProcessor public: PortInsert (Session&, Placement); PortInsert (Session&, const XMLNode&); - PortInsert (const PortInsert&); ~PortInsert (); XMLNode& state(bool full); @@ -64,6 +63,9 @@ class PortInsert : public IOProcessor uint32_t bit_slot() const { return bitslot; } private: + /* disallow copy construction */ + PortInsert (const PortInsert&); + uint32_t bitslot; }; diff --git a/libs/ardour/ardour/processor.h b/libs/ardour/ardour/processor.h index 5a1011966c..83d6be0df9 100644 --- a/libs/ardour/ardour/processor.h +++ b/libs/ardour/ardour/processor.h @@ -53,8 +53,6 @@ class Processor : public SessionObject, public AutomatableControls, public Laten virtual ~Processor() { } - static boost::shared_ptr clone (boost::shared_ptr); - uint32_t sort_key() const { return _sort_key; } void set_sort_key (uint32_t key); @@ -117,6 +115,10 @@ protected: Placement _placement; uint32_t _sort_key; void* _gui; /* generic, we don't know or care what this is */ + +private: + /* disallow copy construction */ + Processor (Processor const &); }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index cbf4910899..5e83bd2f1e 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -176,7 +176,6 @@ class Route : public IO int add_processor (boost::shared_ptr, ProcessorStreams* err = 0); int add_processors (const ProcessorList&, ProcessorStreams* err = 0); int remove_processor (boost::shared_ptr, ProcessorStreams* err = 0); - int copy_processors (const Route&, Placement, ProcessorStreams* err = 0); int sort_processors (ProcessorStreams* err = 0); void disable_processors (Placement); void disable_processors (); diff --git a/libs/ardour/ardour/send.h b/libs/ardour/ardour/send.h index b65675dc2c..dc1cbb8209 100644 --- a/libs/ardour/ardour/send.h +++ b/libs/ardour/ardour/send.h @@ -36,7 +36,6 @@ class Send : public IOProcessor public: Send (Session&, Placement); Send (Session&, const XMLNode&); - Send (const Send&); virtual ~Send (); uint32_t bit_slot() const { return bitslot; } @@ -65,6 +64,9 @@ class Send : public IOProcessor static void make_unique (XMLNode &, Session &); private: + /* disallow copy construction */ + Send (const Send&); + bool _metering; ChanCount expected_inputs; uint32_t bitslot; diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 431c91762e..2256afb782 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -96,23 +96,6 @@ PluginInsert::PluginInsert (Session& s, const XMLNode& node) } } -PluginInsert::PluginInsert (const PluginInsert& other) - : Processor (other._session, other._name, other.placement()), - _signal_analysis_collected_nframes(0), - _signal_analysis_collect_nframes_max(0) -{ - uint32_t count = other._plugins.size(); - - /* make as many copies as requested */ - for (uint32_t n = 0; n < count; ++n) { - _plugins.push_back (plugin_factory (other.plugin (n))); - } - - init (); - - ProcessorCreated (this); /* EMIT SIGNAL */ -} - bool PluginInsert::set_count (uint32_t num) { diff --git a/libs/ardour/port_insert.cc b/libs/ardour/port_insert.cc index 2e7f20ba66..cbbf66b40f 100644 --- a/libs/ardour/port_insert.cc +++ b/libs/ardour/port_insert.cc @@ -47,13 +47,6 @@ PortInsert::PortInsert (Session& s, Placement p) ProcessorCreated (this); /* EMIT SIGNAL */ } -PortInsert::PortInsert (const PortInsert& other) - : IOProcessor (other._session, string_compose (_("insert %1"), (bitslot = other._session.next_insert_id()) + 1), other.placement(), 1, -1, 1, -1) -{ - init (); - ProcessorCreated (this); /* EMIT SIGNAL */ -} - void PortInsert::init () { diff --git a/libs/ardour/processor.cc b/libs/ardour/processor.cc index a528a4587c..085a27b581 100644 --- a/libs/ardour/processor.cc +++ b/libs/ardour/processor.cc @@ -69,27 +69,6 @@ Processor::Processor(Session& session, const string& name, Placement p) { } -boost::shared_ptr -Processor::clone (boost::shared_ptr other) -{ - boost::shared_ptr send; - boost::shared_ptr port_insert; - boost::shared_ptr plugin_insert; - - if ((send = boost::dynamic_pointer_cast(other)) != 0) { - return boost::shared_ptr (new Send (*send)); - } else if ((port_insert = boost::dynamic_pointer_cast(other)) != 0) { - return boost::shared_ptr (new PortInsert (*port_insert)); - } else if ((plugin_insert = boost::dynamic_pointer_cast(other)) != 0) { - return boost::shared_ptr (new PluginInsert (*plugin_insert)); - } else { - fatal << _("programming error: unknown Processor type in Processor::Clone!\n") - << endmsg; - /*NOTREACHED*/ - } - return boost::shared_ptr(); -} - void Processor::set_sort_key (uint32_t key) { diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 6f031acd12..21b7876aca 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1762,87 +1762,6 @@ Route::check_some_processor_counts (list& iclist, ChanCount requ return false; } -int -Route::copy_processors (const Route& other, Placement placement, ProcessorStreams* err) -{ - ChanCount old_pmo = processor_max_outs; - - ProcessorList to_be_deleted; - - { - Glib::RWLock::WriterLock lm (_processor_lock); - ProcessorList::iterator tmp; - ProcessorList the_copy; - - the_copy = _processors; - - /* remove all relevant processors */ - - for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ) { - tmp = i; - ++tmp; - - if ((*i)->placement() == placement) { - to_be_deleted.push_back (*i); - _processors.erase (i); - } - - i = tmp; - } - - /* now copy the relevant ones from "other" */ - - for (ProcessorList::const_iterator i = other._processors.begin(); i != other._processors.end(); ++i) { - if ((*i)->placement() == placement) { - _processors.push_back (IOProcessor::clone (*i)); - } - } - - /* reset plugin stream handling */ - - if (_reset_processor_counts (err)) { - - /* FAILED COPY ATTEMPT: we have to restore order */ - - /* delete all cloned processors */ - - for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ) { - - tmp = i; - ++tmp; - - if ((*i)->placement() == placement) { - _processors.erase (i); - } - - i = tmp; - } - - /* restore the natural order */ - - _processors = the_copy; - processor_max_outs = old_pmo; - - /* we failed, even though things are OK again */ - - return -1; - - } else { - - /* SUCCESSFUL COPY ATTEMPT: delete the processors we removed pre-copy */ - to_be_deleted.clear (); - _user_latency = 0; - } - } - - if (processor_max_outs != old_pmo || old_pmo == ChanCount::ZERO) { - reset_panner (); - } - - processors_changed (); /* EMIT SIGNAL */ - return 0; -} - void Route::all_processors_flip () { diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc index 252ca691be..bdd75494fb 100644 --- a/libs/ardour/send.cc +++ b/libs/ardour/send.cc @@ -54,42 +54,6 @@ Send::Send (Session& s, const XMLNode& node) ProcessorCreated (this); /* EMIT SIGNAL */ } -Send::Send (const Send& other) - : IOProcessor (other._session, string_compose (_("send %1"), (bitslot = other._session.next_send_id()) + 1), other.placement()) -{ - _metering = false; - - expected_inputs.set (DataType::AUDIO, 0); - - /* set up the same outputs, and connect them to the same places */ - - _io->defer_pan_reset (); - - for (uint32_t i = 0; i < other._io->n_outputs().get (_io->default_type()); ++i) { - _io->add_output_port ("", 0); - Port* p = other._io->output (i); - if (p) { - /* this is what the other send's output is connected to */ - std::vector connections; - p->get_connections (connections); - for (uint32_t j = 0; j < connections.size(); ++j) { - _io->connect_output (_io->output (i), connections[j], 0); - } - } - } - - /* setup panner */ - - _io->allow_pan_reset (); - - XMLNode& other_state (other._io->panner().get_state ()); - _io->panner().set_state (other_state); - - delete &other_state; - - ProcessorCreated (this); /* EMIT SIGNAL */ -} - Send::~Send () { GoingAway ();