~ubuntu-branches/ubuntu/utopic/ardour3/utopic

« back to all changes in this revision

Viewing changes to libs/ardour/ardour/control_protocol_manager.h

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2013-09-21 19:05:02 UTC
  • Revision ID: package-import@ubuntu.com-20130921190502-8gsftrku6jnzhd7v
Tags: upstream-3.4~dfsg
ImportĀ upstreamĀ versionĀ 3.4~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#include "ardour/session_handle.h"
 
31
 
 
32
namespace ARDOUR {
 
33
 
 
34
class ControlProtocol;
 
35
class ControlProtocolDescriptor;
 
36
class Session;
 
37
 
 
38
class ControlProtocolInfo {
 
39
public:
 
40
    ControlProtocolDescriptor* descriptor;
 
41
    ControlProtocol* protocol;
 
42
    std::string name;
 
43
    std::string path;
 
44
    bool requested;
 
45
    bool mandatory;
 
46
    bool supports_feedback;
 
47
    XMLNode* state;
 
48
 
 
49
    ControlProtocolInfo() : descriptor (0), protocol (0), requested(false),
 
50
                mandatory(false), supports_feedback(false), state (0)
 
51
        {}
 
52
    ~ControlProtocolInfo() { delete state; }
 
53
};
 
54
 
 
55
class ControlProtocolManager : public PBD::Stateful, public ARDOUR::SessionHandlePtr
 
56
{
 
57
  public:
 
58
        ~ControlProtocolManager ();
 
59
 
 
60
        static ControlProtocolManager& instance();
 
61
 
 
62
        void set_session (Session*);
 
63
        void discover_control_protocols ();
 
64
        void foreach_known_protocol (boost::function<void(const ControlProtocolInfo*)>);
 
65
        void load_mandatory_protocols ();
 
66
        void midi_connectivity_established ();
 
67
 
 
68
        ControlProtocol* instantiate (ControlProtocolInfo&);
 
69
        int              teardown (ControlProtocolInfo&);
 
70
        
 
71
        std::list<ControlProtocolInfo*> control_protocol_info;
 
72
 
 
73
        static const std::string state_node_name;
 
74
 
 
75
        int set_state (const XMLNode&, int version);
 
76
        XMLNode& get_state (void);
 
77
 
 
78
        PBD::Signal1<void,ControlProtocolInfo*> ProtocolStatusChange;
 
79
 
 
80
  private:
 
81
        ControlProtocolManager ();
 
82
        static ControlProtocolManager* _instance;
 
83
 
 
84
        Glib::Threads::Mutex protocols_lock;
 
85
        std::list<ControlProtocol*>    control_protocols;
 
86
 
 
87
        void session_going_away ();
 
88
 
 
89
        int control_protocol_discover (std::string path);
 
90
        ControlProtocolDescriptor* get_descriptor (std::string path);
 
91
        ControlProtocolInfo* cpi_by_name (std::string);
 
92
};
 
93
 
 
94
} // namespace
 
95
 
 
96
#endif // ardour_control_protocol_manager_h