Trim include dependency tree (particularly on evoral/Sequence.hpp).
[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 #include <boost/shared_ptr.hpp>
27 #include <evoral/ControlSet.hpp>
28 #include <ardour/types.h>
29
30 class XMLNode;
31
32 namespace ARDOUR {
33
34 class Session;
35 class AutomationControl;
36
37
38 /** Note this class is abstract, actual objects must either be
39  * an AutomatableControls or an AutomatableSequence
40  */
41 class Automatable : virtual public Evoral::ControlSet
42 {
43 public:
44         Automatable(Session&);
45         Automatable();
46
47         virtual ~Automatable() {}
48
49         boost::shared_ptr<Evoral::Control>
50         control_factory(const Evoral::Parameter& id);
51
52         boost::shared_ptr<AutomationControl>
53         automation_control (const Evoral::Parameter& id, bool create_if_missing=false);
54         
55         boost::shared_ptr<const AutomationControl>
56         automation_control (const Evoral::Parameter& id) const;
57
58         virtual void add_control(boost::shared_ptr<Evoral::Control>);
59         
60         virtual void automation_snapshot(nframes_t now, bool force);
61         virtual void transport_stopped(nframes_t now);
62
63         virtual std::string describe_parameter(Evoral::Parameter param);
64         
65         AutoState get_parameter_automation_state (Evoral::Parameter param, bool lock = true);
66         virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState);
67         
68         AutoStyle get_parameter_automation_style (Evoral::Parameter param);
69         void set_parameter_automation_style (Evoral::Parameter param, AutoStyle);
70
71         void protect_automation ();
72
73         void what_has_visible_data(std::set<Evoral::Parameter>&) const;
74         const std::set<Evoral::Parameter>& what_can_be_automated() const { return _can_automate_list; }
75
76         void mark_automation_visible(Evoral::Parameter, bool);
77         
78         inline bool should_snapshot (nframes_t now) {
79                 return (_last_automation_snapshot > now
80                                 || (now - _last_automation_snapshot) > _automation_interval);
81         }
82         
83         static void set_automation_interval (jack_nframes_t frames) {
84                 _automation_interval = frames;
85         }
86
87         static jack_nframes_t automation_interval() { 
88                 return _automation_interval;
89         }
90         
91         typedef Evoral::ControlSet::Controls Controls;
92         
93         Evoral::ControlSet&       data()       { return *this; }
94         const Evoral::ControlSet& data() const { return *this; }
95
96         int set_automation_state (const XMLNode&, Evoral::Parameter default_param);
97         XMLNode& get_automation_state();
98
99   protected:
100         Session& _a_session;
101
102         void can_automate(Evoral::Parameter);
103
104         virtual void auto_state_changed (Evoral::Parameter which) {}
105
106         
107         int load_automation (const std::string& path);
108         int old_set_automation_state(const XMLNode&);
109
110         std::set<Evoral::Parameter> _visible_controls;
111         std::set<Evoral::Parameter> _can_automate_list;
112         
113         nframes_t        _last_automation_snapshot;
114         static nframes_t _automation_interval;
115 };
116
117
118 } // namespace ARDOUR
119
120 #endif /* __ardour_automatable_h__ */