modification to make generic MIDI actually work again
[ardour.git] / libs / ardour / ardour / control_protocol_manager.h
1 #ifndef ardour_control_protocol_manager_h
2 #define ardour_control_protocol_manager_h
3
4 #include <string>
5 #include <list>
6
7 #include <sigc++/sigc++.h>
8
9 #include <glibmm/thread.h>
10
11 #include <pbd/stateful.h> 
12
13 namespace ARDOUR {
14
15 class ControlProtocol;
16 class ControlProtocolDescriptor;
17 class Session;
18
19 struct ControlProtocolInfo {
20     ControlProtocolDescriptor* descriptor;
21     ControlProtocol* protocol;
22     std::string name;
23     std::string path;
24     bool requested;
25     bool mandatory;
26     XMLNode* state;
27 };
28
29  class ControlProtocolManager : public sigc::trackable, public Stateful
30 {
31   public:
32         ControlProtocolManager ();
33         ~ControlProtocolManager ();
34
35         static ControlProtocolManager& instance() { return *_instance; }
36
37         void set_session (Session&);
38         void discover_control_protocols (std::string search_path);
39         void foreach_known_protocol (sigc::slot<void,const ControlProtocolInfo*>);
40         void load_mandatory_protocols ();
41
42         ControlProtocol* instantiate (ControlProtocolInfo&);
43         int              teardown (ControlProtocolInfo&);
44
45         std::list<ControlProtocolInfo*> control_protocol_info;
46
47         static const std::string state_node_name;
48
49         int set_state (const XMLNode&);
50         XMLNode& get_state (void);
51
52   private:
53         static ControlProtocolManager* _instance;
54
55         Session* _session;
56         Glib::Mutex protocols_lock;
57         std::list<ControlProtocol*>    control_protocols;
58
59         void drop_session ();
60
61         int control_protocol_discover (std::string path);
62         ControlProtocolDescriptor* get_descriptor (std::string path);
63         ControlProtocolInfo* cpi_by_name (std::string);
64 };
65
66 } // namespace
67
68 #endif // ardour_control_protocol_manager_h