rearrange inheritance so that Automatable IS-A Slavable
[ardour.git] / libs / ardour / ardour / automatable.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_automatable_h__
21 #define __ardour_automatable_h__
22
23 #include <map>
24 #include <set>
25 #include <string>
26
27 #include <boost/shared_ptr.hpp>
28
29 #include "pbd/signals.h"
30
31 #include "evoral/ControlSet.hpp"
32
33 #include "ardour/libardour_visibility.h"
34 #include "ardour/slavable.h"
35 #include "ardour/types.h"
36
37 class XMLNode;
38
39 namespace ARDOUR {
40
41 class Session;
42 class AutomationControl;
43
44 /* The inherited ControlSet is virtual because AutomatableSequence inherits
45  * from this AND EvoralSequence, which is also a ControlSet
46  */
47 class LIBARDOUR_API Automatable : virtual public Evoral::ControlSet, public Slavable
48 {
49 public:
50         Automatable(Session&);
51         Automatable (const Automatable& other);
52
53         virtual ~Automatable();
54
55         boost::shared_ptr<Evoral::Control> control_factory(const Evoral::Parameter& id);
56
57         boost::shared_ptr<AutomationControl> automation_control (const Evoral::Parameter& id) {
58                 return automation_control (id, false);
59         }
60
61         boost::shared_ptr<AutomationControl> automation_control (const Evoral::Parameter& id, bool create_if_missing);
62         boost::shared_ptr<const AutomationControl> automation_control (const Evoral::Parameter& id) const;
63
64         virtual void add_control(boost::shared_ptr<Evoral::Control>);
65         virtual bool find_next_event (double start, double end, Evoral::ControlEvent& ev, bool only_active = true) const;
66         void clear_controls ();
67
68         virtual void transport_located (framepos_t now);
69         virtual void transport_stopped (framepos_t now);
70
71         virtual std::string describe_parameter(Evoral::Parameter param);
72         virtual std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
73
74         AutoState get_parameter_automation_state (Evoral::Parameter param);
75         virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState);
76
77         AutoStyle get_parameter_automation_style (Evoral::Parameter param);
78         void set_parameter_automation_style (Evoral::Parameter param, AutoStyle);
79
80         void protect_automation ();
81
82         const std::set<Evoral::Parameter>& what_can_be_automated() const { return _can_automate_list; }
83         void what_has_existing_automation (std::set<Evoral::Parameter>&) const;
84
85         static const std::string xml_node_name;
86
87         int set_automation_xml_state (const XMLNode&, Evoral::Parameter default_param);
88         XMLNode& get_automation_xml_state();
89
90         PBD::Signal0<void> AutomationStateChanged;
91
92   protected:
93         Session& _a_session;
94
95         void can_automate(Evoral::Parameter);
96
97         virtual void automation_list_automation_state_changed (Evoral::Parameter, AutoState) {}
98
99         int load_automation (const std::string& path);
100         int old_set_automation_state(const XMLNode&);
101
102         std::set<Evoral::Parameter> _can_automate_list;
103
104         framepos_t _last_automation_snapshot;
105
106 private:
107         PBD::ScopedConnectionList _control_connections; ///< connections to our controls' signals
108 };
109
110
111 } // namespace ARDOUR
112
113 #endif /* __ardour_automatable_h__ */