ae53caef38b384ef7745194a0c8e71c5128fbc77
[ardour.git] / libs / ardour / ardour / slavable.h
1 /*
2     Copyright (C) 2016 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_slavable_h__
21 #define __ardour_slavable_h__
22
23 #include <set>
24 #include <string>
25 #include <stdint.h>
26
27 #include <boost/shared_ptr.hpp>
28
29 class XMLNode;
30
31 namespace ARDOUR {
32
33 class VCA;
34 class Session;
35
36 class Slavable
37 {
38     public:
39         Slavable ();
40         virtual ~Slavable() {}
41
42         XMLNode& state () const;
43         int assign (Session& s, XMLNode const&);
44
45         void assign (boost::shared_ptr<VCA>);
46         void unassign (boost::shared_ptr<VCA>);
47
48         static std::string xml_node_name;
49
50     protected:
51         virtual int assign_controls (boost::shared_ptr<VCA>) = 0;
52         virtual int unassign_controls (boost::shared_ptr<VCA>) = 0;
53
54     private:
55         mutable Glib::Threads::RWLock master_lock;
56         std::set<uint32_t> _masters;
57 };
58
59 } // namespace ARDOUR
60
61 #endif /* __ardour_slavable_h__ */