aefee7c41bee0fac15be2a2d49d502220b212aca
[ardour.git] / libs / surfaces / mackie / route_signal.h
1 /*
2         Copyright (C) 2006,2007 John Anderson
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 #ifndef route_signal_h
19 #define route_signal_h
20
21 #include <sigc++/sigc++.h>
22
23 class MackieControlProtocol;
24
25 namespace ARDOUR {
26         class Route;
27 }
28         
29 namespace Mackie
30 {
31
32 class Strip;
33 class MackiePort;
34
35 /**
36   This class is intended to easily create and destroy the set of
37   connections from a route to a control surface strip. Instantiating
38   it will connect the signals, and destructing it will disconnect
39   the signals.
40
41   TODO deal with routes with >1 panner.
42 */
43 class RouteSignal
44 {
45 public:
46         RouteSignal( ARDOUR::Route & route, MackieControlProtocol & mcp, Strip & strip, MackiePort & port )
47         : _route( route ), _mcp( mcp ), _strip( strip ), _port( port )
48         {
49                 connect();
50         }
51         
52         ~RouteSignal()
53         {
54                 disconnect();
55         }
56         
57         void connect();
58         void disconnect();
59         
60         // call all signal handlers manually
61         void notify_all();
62         
63         const ARDOUR::Route & route() const { return _route; }
64         Strip & strip() { return _strip; }
65         
66 private:
67         ARDOUR::Route & _route;
68         MackieControlProtocol & _mcp;
69         Strip & _strip;
70         MackiePort & _port;     
71
72         sigc::connection _solo_changed_connection;
73         sigc::connection _mute_changed_connection;
74         sigc::connection _record_enable_changed_connection;
75         sigc::connection _gain_changed_connection;
76         sigc::connection _name_changed_connection;
77         sigc::connection _panner_changed_connection;
78 };
79
80 }
81
82 #endif