Consistent use of abort() /* NOTREACHED */
[ardour.git] / libs / surfaces / mackie / surface_port.h
1 /*
2  * Copyright (C) 2006-2007 John Anderson
3  * Copyright (C) 2008-2015 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2010-2011 Carl Hetherington <carl@carlh.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 #ifndef surface_port_h
21 #define surface_port_h
22
23 #include <midi++/types.h>
24
25 #include "pbd/signals.h"
26
27
28 #include "midi_byte_array.h"
29 #include "types.h"
30
31 namespace MIDI {
32         class Parser;
33         class Port;
34 }
35
36
37 namespace ARDOUR {
38         class AsyncMIDIPort;
39         class Port;
40 }
41
42 namespace ArdourSurface {
43
44 class MackieControlProtocol;
45
46 namespace Mackie
47 {
48
49 class Surface;
50
51 /**
52    Make a relationship between a midi port and a Mackie device.
53 */
54
55 class SurfacePort
56 {
57   public:
58         SurfacePort (Mackie::Surface&);
59         virtual ~SurfacePort();
60
61         /// an easier way to output bytes via midi
62         int write (const MidiByteArray&);
63
64         MIDI::Port& input_port() const { return *_input_port; }
65         MIDI::Port& output_port() const { return *_output_port; }
66
67         ARDOUR::Port& input() const { return *_async_in; }
68         ARDOUR::Port& output() const { return *_async_out; }
69
70         std::string input_name() const;
71         std::string output_name() const;
72
73         void reconnect ();
74
75         XMLNode& get_state ();
76         int set_state (const XMLNode&, int version);
77
78   protected:
79
80   private:
81         Mackie::Surface*   _surface;
82         MIDI::Port* _input_port;
83         MIDI::Port* _output_port;
84         boost::shared_ptr<ARDOUR::Port> _async_in;
85         boost::shared_ptr<ARDOUR::Port> _async_out;
86 };
87
88 std::ostream& operator <<  (std::ostream& , const SurfacePort& port);
89
90 }
91 }
92
93 #endif