make all use of bind/mem_fun be explicitly sigc::
[ardour.git] / gtk2_ardour / route_processor_selection.cc
1 /*
2     Copyright (C) 2002 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #include <algorithm>
21 #include <sigc++/bind.h>
22 #include "pbd/error.h"
23
24 #include "ardour/playlist.h"
25 #include "ardour/processor.h"
26 #include "ardour/route.h"
27
28 #include "route_processor_selection.h"
29
30 #include "i18n.h"
31
32 using namespace std;
33 using namespace ARDOUR;
34 using namespace PBD;
35 using namespace sigc;
36
37 RouteRedirectSelection&
38 RouteRedirectSelection::operator= (const RouteRedirectSelection& other)
39 {
40         if (&other != this) {
41                 processors = other.processors;
42                 routes = other.routes;
43         }
44         return *this;
45 }
46
47 bool
48 operator== (const RouteRedirectSelection& a, const RouteRedirectSelection& b)
49 {
50         // XXX MUST TEST PROCESSORS SOMEHOW
51         return a.routes == b.routes;
52 }
53
54 void
55 RouteRedirectSelection::clear ()
56 {
57         clear_processors ();
58         clear_routes ();
59 }
60
61 void
62 RouteRedirectSelection::clear_processors ()
63 {
64         processors.clear ();
65         ProcessorsChanged ();
66 }
67
68 void
69 RouteRedirectSelection::clear_routes ()
70 {
71         routes.clear ();
72         RoutesChanged ();
73 }
74
75 void
76 RouteRedirectSelection::add (XMLNode* node)
77 {
78         // XXX check for duplicate
79         processors.add (node);
80         ProcessorsChanged();
81 }
82
83 void
84 RouteRedirectSelection::set (XMLNode* node)
85 {
86         clear_processors ();
87         processors.set (node);
88         ProcessorsChanged ();
89 }
90
91 void
92 RouteRedirectSelection::add (boost::shared_ptr<Route> r)
93 {
94         if (find (routes.begin(), routes.end(), r) == routes.end()) {
95                 routes.push_back (r);
96
97                 // XXX SHAREDPTR FIXME
98                 // void (RouteRedirectSelection::*pmf)(Route*) = &RouteRedirectSelection::remove;
99                 // r->GoingAway.connect (sigc::bind (sigc::mem_fun(*this, pmf), r));
100
101                 RoutesChanged();
102         }
103 }
104
105 void
106 RouteRedirectSelection::remove (boost::shared_ptr<Route> r)
107 {
108         list<boost::shared_ptr<Route> >::iterator i;
109         if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) {
110                 routes.erase (i);
111                 RoutesChanged ();
112         }
113 }
114
115 void
116 RouteRedirectSelection::set (boost::shared_ptr<Route> r)
117 {
118         clear_routes ();
119         add (r);
120 }
121
122 bool
123 RouteRedirectSelection::selected (boost::shared_ptr<Route> r)
124 {
125         return find (routes.begin(), routes.end(), r) != routes.end();
126 }
127
128 bool
129 RouteRedirectSelection::empty ()
130 {
131         return processors.empty () && routes.empty ();
132 }
133