NO-OP: Consistent API name
[ardour.git] / libs / ardour / ardour / control_protocol_manager.h
1 /*
2     Copyright (C) 2000-2007 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 #ifndef ardour_control_protocol_manager_h
21 #define ardour_control_protocol_manager_h
22
23 #include <string>
24 #include <list>
25
26
27 #include <glibmm/threads.h>
28
29 #include "pbd/stateful.h"
30
31 #include "control_protocol/types.h"
32
33 #include "ardour/session_handle.h"
34
35 namespace ARDOUR {
36
37 class ControlProtocol;
38 class ControlProtocolDescriptor;
39 class Session;
40
41 class LIBARDOUR_API ControlProtocolInfo {
42         public:
43                 ControlProtocolDescriptor* descriptor;
44                 ControlProtocol* protocol;
45                 std::string name;
46                 std::string path;
47                 bool requested;
48                 bool mandatory;
49                 bool supports_feedback;
50                 XMLNode* state;
51
52                 ControlProtocolInfo() : descriptor (0), protocol (0), requested(false),
53                 mandatory(false), supports_feedback(false), state (0)
54         {}
55                 ~ControlProtocolInfo();
56
57 };
58
59 class LIBARDOUR_API ControlProtocolManager : public PBD::Stateful, public ARDOUR::SessionHandlePtr
60 {
61   public:
62         ~ControlProtocolManager ();
63
64         static ControlProtocolManager& instance();
65
66         void set_session (Session*);
67         void discover_control_protocols ();
68         void foreach_known_protocol (boost::function<void(const ControlProtocolInfo*)>);
69         void load_mandatory_protocols ();
70         void midi_connectivity_established ();
71         void drop_protocols ();
72         void register_request_buffer_factories ();
73
74         int activate (ControlProtocolInfo&);
75         int deactivate (ControlProtocolInfo&);
76
77         std::list<ControlProtocolInfo*> control_protocol_info;
78
79         static const std::string state_node_name;
80
81         int set_state (const XMLNode&, int version);
82         XMLNode& get_state (void);
83
84         PBD::Signal1<void,ControlProtocolInfo*> ProtocolStatusChange;
85
86         void stripable_selection_changed (ARDOUR::StripableNotificationListPtr);
87         static PBD::Signal1<void,ARDOUR::StripableNotificationListPtr> StripableSelectionChanged;
88
89   private:
90         ControlProtocolManager ();
91         static ControlProtocolManager* _instance;
92
93         Glib::Threads::RWLock protocols_lock;
94         std::list<ControlProtocol*>    control_protocols;
95
96         void session_going_away ();
97
98         int control_protocol_discover (std::string path);
99         ControlProtocolDescriptor* get_descriptor (std::string path);
100         ControlProtocolInfo* cpi_by_name (std::string);
101         ControlProtocol* instantiate (ControlProtocolInfo&);
102         int teardown (ControlProtocolInfo&, bool lock_required);
103 };
104
105 } // namespace
106
107 #endif // ardour_control_protocol_manager_h