Make DnD copy processors using their XML representations. Remove unused
authorCarl Hetherington <carl@carlh.net>
Sat, 14 Feb 2009 19:45:30 +0000 (19:45 +0000)
committerCarl Hetherington <carl@carlh.net>
Sat, 14 Feb 2009 19:45:30 +0000 (19:45 +0000)
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

15 files changed:
gtk2_ardour/processor_box.cc
gtk2_ardour/processor_box.h
libs/ardour/ardour/io_processor.h
libs/ardour/ardour/meter.h
libs/ardour/ardour/panner.h
libs/ardour/ardour/plugin_insert.h
libs/ardour/ardour/port_insert.h
libs/ardour/ardour/processor.h
libs/ardour/ardour/route.h
libs/ardour/ardour/send.h
libs/ardour/plugin_insert.cc
libs/ardour/port_insert.cc
libs/ardour/processor.cc
libs/ardour/route.cc
libs/ardour/send.cc

index 34e4f27ae000deebebf975c1eae0de5b872b45e9..ce7d0f5567ff5bc931813848c669b0c2f93c9a3c 100644 (file)
@@ -171,7 +171,14 @@ ProcessorBox::route_going_away ()
 void
 ProcessorBox::object_drop (const list<boost::shared_ptr<Processor> >& procs)
 {
-       paste_processor_list (procs);
+       for (std::list<boost::shared_ptr<Processor> >::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<boost::shared_ptr<Processor> >& processors)
+ProcessorBox::paste_processor_state (const XMLNodeList& nlist)
 {
-       list<boost::shared_ptr<Processor> > copies;
-       
-       for (list<boost::shared_ptr<Processor> >::const_iterator i = processors.begin(); i != processors.end(); ++i) {
-               
-               boost::shared_ptr<Processor> 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<boost::shared_ptr<Processor> > 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<Processor> p;
                try {
                        if (type->value() == "send") {
                                XMLNode n (**niter);
                                Send::make_unique (n, _session);
-                               copies.push_back (boost::shared_ptr<Processor> (new Send (_session, n)));
+                               p.reset (new Send (_session, n));
+                               
                        } else {
-                               copies.push_back (boost::shared_ptr<Processor> (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)
 {
index 0a6399caad450e4208148b650484fcf324325c4f..76c642668600ad96c4a8c3f150d2a2d2f06dc1b6 100644 (file)
@@ -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<ARDOUR::Processor>));
        void get_selected_processors (vector<boost::shared_ptr<ARDOUR::Processor> >&);
 
        static Glib::RefPtr<Gtk::Action> paste_action;
-       void paste_processor_list (const std::list<boost::shared_ptr<ARDOUR::Processor> >& processors);
-       void paste_processor_state (const XMLNode&);
+       void paste_processor_state (const XMLNodeList&);
        
        void activate_processor (boost::shared_ptr<ARDOUR::Processor>);
        void deactivate_processor (boost::shared_ptr<ARDOUR::Processor>);
index af11e8cacf8406cf5a3734fb94e7855e78f51ff6..985a2c387cee05ad47bb362f5f99a84118e3c85f 100644 (file)
@@ -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> _io;
+
+  private:
+       /* disallow copy construction */
+       IOProcessor (const IOProcessor&);
+
 };
 
 } // namespace ARDOUR
index 112f306ccb98db6b74bbdaff70921b568f68ac92..2cf474afbaae3dfd7f9854a82486350fe6487400 100644 (file)
@@ -63,6 +63,8 @@ public:
        }
 
 private:
+       /* disallow copy construction */
+       PeakMeter (PeakMeter const &);
        
        friend class IO;
        void meter();
index 34b99e63bfee9545719767d56e4d25f98049b591..f6839f6d29e36c8a7baa92829c0f9e54e7f9214e 100644 (file)
@@ -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<StreamPanner*> _streampanners;
        uint32_t     current_outs;
index 2583728ef347c4eb4304bb57f3e46c618389369e..ee5c7405fb8964924c92dc6f1c9f98f666f84ed9 100644 (file)
@@ -46,7 +46,6 @@ class PluginInsert : public Processor
   public:
        PluginInsert (Session&, boost::shared_ptr<Plugin>, 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);
        
index 55f91569d5b5ac40483449f1963cec04322c0e4e..78ff09124bb5707736f99e6b4112298b2f157e92 100644 (file)
@@ -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;
 };
 
index 5a1011966ce3e704d24c5d8839a6d4ac7a8aa974..83d6be0df959cebbd95feadb4301eb0b899e2762 100644 (file)
@@ -53,8 +53,6 @@ class Processor : public SessionObject, public AutomatableControls, public Laten
        
        virtual ~Processor() { }
        
-       static boost::shared_ptr<Processor> clone (boost::shared_ptr<const Processor>);
-
        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
index cbf49108991b3ea7be3cb3abf4a48c3cd4a71fb4..5e83bd2f1e9f077766777ad2f29a979c1217a47f 100644 (file)
@@ -176,7 +176,6 @@ class Route : public IO
        int add_processor (boost::shared_ptr<Processor>, ProcessorStreams* err = 0);
        int add_processors (const ProcessorList&, ProcessorStreams* err = 0);
        int remove_processor (boost::shared_ptr<Processor>, 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 ();
index b65675dc2ca5050c979053792792df3b7f611bdc..dc1cbb820951f66f7ed89ea935368f7c6adbce21 100644 (file)
@@ -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;
index 431c91762e283d52e1f64865135acd2eef82277b..2256afb782aaa47afa3bc8c01bb1553e1ba6bf66 100644 (file)
@@ -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)
 {
index 2e7f20ba6654b25ce5353b981c5fd52f430da58e..cbbf66b40f7b261a73353cde8c89575b5795df77 100644 (file)
@@ -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 ()
 {
index a528a4587cc7a4e1d3d97ef297bb5cfdbca22a7d..085a27b58135561d610b12d81004aad936a454f3 100644 (file)
@@ -69,27 +69,6 @@ Processor::Processor(Session& session, const string& name, Placement p)
 {
 }
 
-boost::shared_ptr<Processor>
-Processor::clone (boost::shared_ptr<const Processor> other)
-{
-       boost::shared_ptr<const Send> send;
-       boost::shared_ptr<const PortInsert> port_insert;
-       boost::shared_ptr<const PluginInsert> plugin_insert;
-
-       if ((send = boost::dynamic_pointer_cast<const Send>(other)) != 0) {
-               return boost::shared_ptr<Processor> (new Send (*send));
-       } else if ((port_insert = boost::dynamic_pointer_cast<const PortInsert>(other)) != 0) {
-               return boost::shared_ptr<Processor> (new PortInsert (*port_insert));
-       } else if ((plugin_insert = boost::dynamic_pointer_cast<const PluginInsert>(other)) != 0) {
-               return boost::shared_ptr<Processor> (new PluginInsert (*plugin_insert));
-       } else {
-               fatal << _("programming error: unknown Processor type in Processor::Clone!\n")
-                     << endmsg;
-               /*NOTREACHED*/
-       }
-       return boost::shared_ptr<Processor>();
-}
-
 void
 Processor::set_sort_key (uint32_t key)
 {
index 6f031acd1261fa5748ecbb5da066106ec66138c4..21b7876aca4e0da309a58c2fe052aa40651d3b69 100644 (file)
@@ -1762,87 +1762,6 @@ Route::check_some_processor_counts (list<ProcessorCount>& 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 ()
 {
index 252ca691befb27026f49a7b40fdd4d2a13237fdd..bdd75494fbe71b479ad1f06cfa2487325bde51d4 100644 (file)
@@ -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<std::string> 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 ();