remove using namespace sigc everywhere to ensure clarity over which bind/mem_fun...
[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
36 RouteRedirectSelection&
37 RouteRedirectSelection::operator= (const RouteRedirectSelection& other)
38 {
39         if (&other != this) {
40                 processors = other.processors;
41                 routes = other.routes;
42         }
43         return *this;
44 }
45
46 bool
47 operator== (const RouteRedirectSelection& a, const RouteRedirectSelection& b)
48 {
49         // XXX MUST TEST PROCESSORS SOMEHOW
50         return a.routes == b.routes;
51 }
52
53 void
54 RouteRedirectSelection::clear ()
55 {
56         clear_processors ();
57         clear_routes ();
58 }
59
60 void
61 RouteRedirectSelection::clear_processors ()
62 {
63         processors.clear ();
64         ProcessorsChanged ();
65 }
66
67 void
68 RouteRedirectSelection::clear_routes ()
69 {
70         routes.clear ();
71         RoutesChanged ();
72 }
73
74 void
75 RouteRedirectSelection::add (XMLNode* node)
76 {
77         // XXX check for duplicate
78         processors.add (node);
79         ProcessorsChanged();
80 }
81
82 void
83 RouteRedirectSelection::set (XMLNode* node)
84 {
85         clear_processors ();
86         processors.set (node);
87         ProcessorsChanged ();
88 }
89
90 void
91 RouteRedirectSelection::add (boost::shared_ptr<Route> r)
92 {
93         if (find (routes.begin(), routes.end(), r) == routes.end()) {
94                 routes.push_back (r);
95
96                 // XXX SHAREDPTR FIXME
97                 // void (RouteRedirectSelection::*pmf)(Route*) = &RouteRedirectSelection::remove;
98                 // r->GoingAway.connect (sigc::bind (sigc::mem_fun(*this, pmf), r));
99
100                 RoutesChanged();
101         }
102 }
103
104 void
105 RouteRedirectSelection::remove (boost::shared_ptr<Route> r)
106 {
107         list<boost::shared_ptr<Route> >::iterator i;
108         if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) {
109                 routes.erase (i);
110                 RoutesChanged ();
111         }
112 }
113
114 void
115 RouteRedirectSelection::set (boost::shared_ptr<Route> r)
116 {
117         clear_routes ();
118         add (r);
119 }
120
121 bool
122 RouteRedirectSelection::selected (boost::shared_ptr<Route> r)
123 {
124         return find (routes.begin(), routes.end(), r) != routes.end();
125 }
126
127 bool
128 RouteRedirectSelection::empty ()
129 {
130         return processors.empty () && routes.empty ();
131 }
132