Don't add duplicate remote_control_id to active banks. Notes and tweaks.
[ardour.git] / libs / surfaces / mackie / surface.h
1 #ifndef mackie_surface_h
2 #define mackie_surface_h
3
4 #include "controls.h"
5 #include "types.h"
6
7 namespace Mackie
8 {
9
10 class MackieButtonHandler;
11
12 /**
13         This represents an entire control surface, made up of Groups,
14         Strips and Controls. There are several collections for
15         ease of addressing in different ways, but only one collection
16         has definitive ownership.
17
18         It handles mapping button ids to press_ and release_ calls.
19
20         There are various emulations of the Mackie around, so specific
21         emulations will inherit from this to change button mapping, or 
22         have 7 fader channels instead of 8, or whatever.
23
24         Currently there are BcfSurface and MackieSurface.
25
26         TODO maybe make Group inherit from Control, for ease of ownership.
27 */
28 class Surface
29 {
30 public:
31         /**
32                 A Surface can be made up of multiple units. eg one Mackie MCU plus
33                 one or more Mackie MCU extenders.
34                 
35                 \param max_strips is the number of strips for the entire surface.
36                 \param unit_strips is the number of strips per unit.
37         */
38         Surface( uint32_t max_strips, uint32_t unit_strips = 8 );
39         virtual ~Surface();
40
41         /// Calls the virtual initialisation methods. This *must* be called after
42         /// construction, because c++ is too dumb to call virtual methods from
43         /// inside a constructor
44         void init();
45
46         typedef std::vector<Control*> Controls;
47         
48         /// This collection has ownership of all the controls
49         Controls controls;
50
51         /**
52                 These are alternative addressing schemes
53                 They use maps because the indices aren't always
54                 0-based.
55         */
56         std::map<int,Control*> faders;
57         std::map<int,Control*> pots;
58         std::map<int,Control*> buttons;
59         std::map<int,Control*> leds;
60
61         /// no strip controls in here because they usually
62         /// have the same names.
63         std::map<std::string,Control*> controls_by_name;
64
65         /// The collection of all numbered strips. No master
66         /// strip in here.
67         typedef std::vector<Strip*> Strips;
68         Strips strips;
69
70         /// This collection owns the groups
71         typedef std::map<std::string,Group*> Groups;
72         Groups groups;
73
74         uint32_t max_strips() const
75         {
76                 return _max_strips;
77         }
78         
79         /// map button ids to calls to press_ and release_ in mbh
80         virtual void handle_button( MackieButtonHandler & mbh, ButtonState bs, Button & button ) = 0;
81         
82 protected:
83         virtual void init_controls() = 0;
84         virtual void init_strips( uint32_t max_strips, uint32_t unit_strips );
85
86 private:
87         uint32_t _max_strips;
88         uint32_t _unit_strips;
89 };
90
91 }
92
93 #endif