a) completely refactor abstract UI code
[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 <pbd/lockmonitor.h>
10
11 #include <ardour/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 };
26
27  class ControlProtocolManager : public sigc::trackable, public Stateful
28 {
29   public:
30         ControlProtocolManager ();
31         ~ControlProtocolManager ();
32
33         static ControlProtocolManager& instance() { return *_instance; }
34
35         void set_session (Session&);
36         void discover_control_protocols (std::string search_path);
37         void foreach_known_protocol (sigc::slot<void,const ControlProtocolInfo*>);
38
39         ControlProtocol* instantiate (ControlProtocolInfo&);
40         int              teardown (ControlProtocolInfo&);
41
42         std::list<ControlProtocolInfo*> control_protocol_info;
43
44         static const std::string state_node_name;
45
46         int set_state (const XMLNode&);
47         XMLNode& get_state (void);
48
49   private:
50         static ControlProtocolManager* _instance;
51
52         Session* _session;
53         PBD::Lock protocols_lock;
54         std::list<ControlProtocol*>    control_protocols;
55
56         void drop_session ();
57
58         int control_protocol_discover (std::string path);
59         ControlProtocolDescriptor* get_descriptor (std::string path);
60         ControlProtocolInfo* cpi_by_name (std::string);
61 };
62
63 } // namespace
64
65 #endif // ardour_control_protocol_manager_h