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