Revert "C++11 Building - Use new style struct field inititializing" (this code
[ardour.git] / libs / surfaces / generic_midi / interface.cc
1 /*
2     Copyright (C) 2012 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 <pbd/failed_constructor.h>
21
22 #include "control_protocol/control_protocol.h"
23 #include "generic_midi_control_protocol.h"
24
25 using namespace ARDOUR;
26
27 ControlProtocol*
28 new_generic_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
29 {
30         GenericMidiControlProtocol* gmcp;
31                 
32         try {
33                 gmcp =  new GenericMidiControlProtocol (*s);
34         } catch (failed_constructor& err) {
35                 return 0;
36         }
37         
38         if (gmcp->set_active (true)) {
39                 delete gmcp;
40                 return 0;
41         }
42
43         return gmcp;
44 }
45
46 void
47 delete_generic_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
48 {
49         delete cp;
50 }
51
52 bool
53 probe_generic_midi_protocol (ControlProtocolDescriptor* /*descriptor*/)
54 {
55         return GenericMidiControlProtocol::probe ();
56 }
57
58 static ControlProtocolDescriptor generic_midi_descriptor = {
59         name : "Generic MIDI",
60         id : "uri://ardour.org/surfaces/generic_midi:0",
61         ptr : 0,
62         module : 0,
63         mandatory : 0,
64         supports_feedback : true,
65         probe : probe_generic_midi_protocol,
66         initialize : new_generic_midi_protocol,
67         destroy : delete_generic_midi_protocol
68 };
69         
70
71 extern "C" {
72 ControlProtocolDescriptor* 
73 protocol_descriptor () {
74         return &generic_midi_descriptor;
75 }
76 }
77