/*
- Copyright (C) 2002 Paul Davis
+ Copyright (C) 2002 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <algorithm>
#include <sigc++/bind.h>
-#include <pbd/error.h>
+#include "pbd/error.h"
-#include <ardour/playlist.h>
-#include <ardour/processor.h>
-#include <ardour/route.h>
+#include "ardour/playlist.h"
+#include "ardour/processor.h"
+#include "ardour/route.h"
#include "route_processor_selection.h"
+#include "gui_thread.h"
#include "i18n.h"
+using namespace std;
using namespace ARDOUR;
using namespace PBD;
-using namespace sigc;
RouteRedirectSelection&
RouteRedirectSelection::operator= (const RouteRedirectSelection& other)
bool
operator== (const RouteRedirectSelection& a, const RouteRedirectSelection& b)
{
- return a.processors == b.processors &&
- a.routes == b.routes;
+ // XXX MUST TEST PROCESSORS SOMEHOW
+ return a.routes == b.routes;
}
void
RouteRedirectSelection::clear_routes ()
{
routes.clear ();
+ drop_connections ();
RoutesChanged ();
}
void
-RouteRedirectSelection::add (boost::shared_ptr<Processor> r)
+RouteRedirectSelection::add (XMLNode* node)
{
- if (find (processors.begin(), processors.end(), r) == processors.end()) {
- processors.push_back (r);
-
- // XXX SHAREDPTR FIXME
- // void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove;
- // r->GoingAway.connect (mem_fun(*this, pmf));
-
- ProcessorsChanged();
- }
-}
-
-void
-RouteRedirectSelection::add (const vector<boost::shared_ptr<Processor> >& rlist)
-{
- bool changed = false;
-
- for (vector<boost::shared_ptr<Processor> >::const_iterator i = rlist.begin(); i != rlist.end(); ++i) {
- if (find (processors.begin(), processors.end(), *i) == processors.end()) {
- processors.push_back (*i);
-
- // XXX SHAREDPTR FIXME
-
- //void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove;
- // (*i)->GoingAway.connect (mem_fun(*this, pmf));
- changed = true;
- }
- }
-
- if (changed) {
- ProcessorsChanged();
- }
-}
-
-void
-RouteRedirectSelection::remove (boost::shared_ptr<Processor> r)
-{
- list<boost::shared_ptr<Processor> >::iterator i;
- if ((i = find (processors.begin(), processors.end(), r)) != processors.end()) {
- processors.erase (i);
- ProcessorsChanged ();
- }
+ // XXX check for duplicate
+ processors.add (node);
+ ProcessorsChanged();
}
void
-RouteRedirectSelection::set (boost::shared_ptr<Processor> r)
+RouteRedirectSelection::set (XMLNode* node)
{
clear_processors ();
- add (r);
-}
-
-void
-RouteRedirectSelection::set (const vector<boost::shared_ptr<Processor> >& rlist)
-{
- clear_processors ();
- add (rlist);
+ processors.set (node);
+ ProcessorsChanged ();
}
void
{
if (find (routes.begin(), routes.end(), r) == routes.end()) {
routes.push_back (r);
+ r->DropReferences.connect (*this, MISSING_INVALIDATOR, boost::bind (&RouteRedirectSelection::removed, this, boost::weak_ptr<Route>(r)), gui_context());
+ RoutesChanged();
+ }
+}
- // XXX SHAREDPTR FIXME
- // void (RouteRedirectSelection::*pmf)(Route*) = &RouteRedirectSelection::remove;
- // r->GoingAway.connect (bind (mem_fun(*this, pmf), r));
+void
+RouteRedirectSelection::removed (boost::weak_ptr<Route> wr)
+{
+ boost::shared_ptr<Route> r (wr.lock());
- RoutesChanged();
+ if (!r) {
+ return;
}
+
+ remove (r);
}
void
RouteRedirectSelection::remove (boost::shared_ptr<Route> r)
{
+ ENSURE_GUI_THREAD (*this, &RouteRedirectSelection::remove, r);
+
list<boost::shared_ptr<Route> >::iterator i;
if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) {
routes.erase (i);
{
return processors.empty () && routes.empty ();
}
-
+