the missing flush call for plugins
[ardour2.git] / gtk2_ardour / route_redirect_selection.cc
blob5ad795c6f5e3b781538c2493c33d6f149b8ae6ce
1 /*
2 Copyright (C) 2002 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <algorithm>
21 #include <sigc++/bind.h>
22 #include <pbd/error.h>
24 #include <ardour/playlist.h>
25 #include <ardour/redirect.h>
26 #include <ardour/route.h>
28 #include "route_redirect_selection.h"
30 #include "i18n.h"
32 using namespace ARDOUR;
33 using namespace PBD;
34 using namespace sigc;
36 RouteRedirectSelection&
37 RouteRedirectSelection::operator= (const RouteRedirectSelection& other)
39 if (&other != this) {
40 redirects = other.redirects;
41 routes = other.routes;
43 return *this;
46 bool
47 operator== (const RouteRedirectSelection& a, const RouteRedirectSelection& b)
49 return a.redirects == b.redirects &&
50 a.routes == b.routes;
53 void
54 RouteRedirectSelection::clear ()
56 clear_redirects ();
57 clear_routes ();
60 void
61 RouteRedirectSelection::clear_redirects ()
63 redirects.clear ();
64 RedirectsChanged ();
67 void
68 RouteRedirectSelection::clear_routes ()
70 routes.clear ();
71 RoutesChanged ();
74 void
75 RouteRedirectSelection::add (boost::shared_ptr<Redirect> r)
77 if (find (redirects.begin(), redirects.end(), r) == redirects.end()) {
78 redirects.push_back (r);
80 // XXX SHAREDPTR FIXME
81 // void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove;
82 // r->GoingAway.connect (mem_fun(*this, pmf));
84 RedirectsChanged();
88 void
89 RouteRedirectSelection::add (const vector<boost::shared_ptr<Redirect> >& rlist)
91 bool changed = false;
93 for (vector<boost::shared_ptr<Redirect> >::const_iterator i = rlist.begin(); i != rlist.end(); ++i) {
94 if (find (redirects.begin(), redirects.end(), *i) == redirects.end()) {
95 redirects.push_back (*i);
97 // XXX SHAREDPTR FIXME
99 //void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove;
100 // (*i)->GoingAway.connect (mem_fun(*this, pmf));
101 changed = true;
105 if (changed) {
106 RedirectsChanged();
110 void
111 RouteRedirectSelection::remove (boost::shared_ptr<Redirect> r)
113 list<boost::shared_ptr<Redirect> >::iterator i;
114 if ((i = find (redirects.begin(), redirects.end(), r)) != redirects.end()) {
115 redirects.erase (i);
116 RedirectsChanged ();
120 void
121 RouteRedirectSelection::set (boost::shared_ptr<Redirect> r)
123 clear_redirects ();
124 add (r);
127 void
128 RouteRedirectSelection::set (const vector<boost::shared_ptr<Redirect> >& rlist)
130 clear_redirects ();
131 add (rlist);
134 void
135 RouteRedirectSelection::add (boost::shared_ptr<Route> r)
137 if (find (routes.begin(), routes.end(), r) == routes.end()) {
138 routes.push_back (r);
140 // XXX SHAREDPTR FIXME
141 // void (RouteRedirectSelection::*pmf)(Route*) = &RouteRedirectSelection::remove;
142 // r->GoingAway.connect (bind (mem_fun(*this, pmf), r));
144 RoutesChanged();
148 void
149 RouteRedirectSelection::remove (boost::shared_ptr<Route> r)
151 list<boost::shared_ptr<Route> >::iterator i;
152 if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) {
153 routes.erase (i);
154 RoutesChanged ();
158 void
159 RouteRedirectSelection::set (boost::shared_ptr<Route> r)
161 clear_routes ();
162 add (r);
165 bool
166 RouteRedirectSelection::selected (boost::shared_ptr<Route> r)
168 return find (routes.begin(), routes.end(), r) != routes.end();
171 bool
172 RouteRedirectSelection::empty ()
174 return redirects.empty () && routes.empty ();