13
0

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
This commit is contained in:
Carl Hetherington 2009-02-14 19:45:30 +00:00
parent b35f308894
commit 9a3734a6bd
15 changed files with 41 additions and 221 deletions

View 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)
{

View 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>);

View 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

View File

@ -63,6 +63,8 @@ public:
}
private:
/* disallow copy construction */
PeakMeter (PeakMeter const &);
friend class IO;
void meter();

View 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;

View 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);

View 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;
};

View 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

View 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 ();

View 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;

View 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)
{

View 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 ()
{

View 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)
{

View 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 ()
{

View 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 ();