globally remove all trailing whitespace from ardour code base.
[ardour.git] / libs / ardour / ardour / midiport_manager.h
1 /*
2     Copyright (C) 1998 Paul Barton-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 #ifndef __midiport_manager_h__
21 #define __midiport_manager_h__
22
23 #include <list>
24
25 #include <string>
26
27 #include "pbd/rcu.h"
28
29 #include "midi++/types.h"
30 #include "midi++/port.h"
31
32 #include "ardour/libardour_visibility.h"
33 #include "ardour/midi_port.h"
34 #include "ardour/types.h"
35
36 namespace ARDOUR {
37
38 class MidiPort;
39 class Port;
40
41 class LIBARDOUR_API MidiPortManager {
42   public:
43     MidiPortManager();
44     virtual ~MidiPortManager ();
45         
46     /* Ports used for control. These are read/written to outside of the
47      * process callback (asynchronously with respect to when data
48      * actually arrives).
49      *
50      * More detail: we do actually read/write data for these ports
51      * inside the process callback, but incoming data is only parsed
52      * and outgoing data is only generated *outside* the process
53      * callback.
54      */
55
56     MIDI::Port* midi_input_port () const { return _midi_input_port; }
57     MIDI::Port* midi_output_port () const { return _midi_output_port; }
58     MIDI::Port* mmc_input_port () const { return _mmc_input_port; }
59     MIDI::Port* mmc_output_port () const { return _mmc_output_port; }
60     MIDI::Port* scene_input_port () const { return _scene_input_port; }
61     MIDI::Port* scene_output_port () const { return _scene_output_port; }
62
63     boost::shared_ptr<MidiPort> mmc_in() const { return boost::dynamic_pointer_cast<MidiPort>(_mmc_in); }
64     boost::shared_ptr<MidiPort> mmc_out() const { return boost::dynamic_pointer_cast<MidiPort>(_mmc_out); }
65
66     boost::shared_ptr<MidiPort> scene_in() const { return boost::dynamic_pointer_cast<MidiPort>(_scene_in); }
67     boost::shared_ptr<MidiPort> scene_out() const { return boost::dynamic_pointer_cast<MidiPort>(_scene_out); }
68
69     /* Ports used for synchronization. These have their I/O handled inside the
70      * process callback.
71      */
72
73     boost::shared_ptr<MidiPort> mtc_input_port() const { return _mtc_input_port; }
74     boost::shared_ptr<MidiPort> mtc_output_port() const { return _mtc_output_port; }
75     boost::shared_ptr<MidiPort> midi_clock_input_port() const { return _midi_clock_input_port; }
76     boost::shared_ptr<MidiPort> midi_clock_output_port() const { return _midi_clock_output_port; }
77
78     void set_midi_port_states (const XMLNodeList&);
79     std::list<XMLNode*> get_midi_port_states () const;
80
81     PBD::Signal0<void> PortsChanged;
82
83   protected:
84     /* asynchronously handled ports: MIDI::Port */
85     MIDI::Port* _midi_input_port;
86     MIDI::Port* _midi_output_port;
87     MIDI::Port* _mmc_input_port;
88     MIDI::Port* _mmc_output_port;
89     MIDI::Port* _scene_input_port;
90     MIDI::Port* _scene_output_port;
91     /* these point to the same objects as the members above,
92        but cast to their ARDOUR::Port base class
93     */
94     boost::shared_ptr<Port> _midi_in;
95     boost::shared_ptr<Port> _midi_out;
96     boost::shared_ptr<Port> _mmc_in;
97     boost::shared_ptr<Port> _mmc_out;
98     boost::shared_ptr<Port> _scene_in;
99     boost::shared_ptr<Port> _scene_out;
100
101     /* synchronously handled ports: ARDOUR::MidiPort */
102     boost::shared_ptr<MidiPort> _mtc_input_port;
103     boost::shared_ptr<MidiPort> _mtc_output_port;
104     boost::shared_ptr<MidiPort> _midi_clock_input_port;
105     boost::shared_ptr<MidiPort> _midi_clock_output_port;
106
107     void create_ports ();
108
109 };
110
111 } // namespace MIDI
112
113 #endif  // __midi_port_manager_h__