Update core library GPL boilerplate and (C) from git log
[ardour.git] / libs / evoral / evoral / Control.hpp
1 /*
2  * Copyright (C) 2008-2014 David Robillard <d@drobilla.net>
3  * Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2010-2013 Paul Davis <paul@linuxaudiosystems.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 #ifndef EVORAL_CONTROL_HPP
22 #define EVORAL_CONTROL_HPP
23
24 #include <set>
25 #include <map>
26 #include <boost/shared_ptr.hpp>
27 #include "pbd/signals.h"
28
29 #include "evoral/visibility.h"
30 #include "evoral/Parameter.hpp"
31 #include "evoral/ParameterDescriptor.hpp"
32
33 namespace Evoral {
34
35 class ControlList;
36 class ParameterDescriptor;
37 class Transport;
38 class TypeMap;
39
40 /** Base class representing some kind of (automatable) control; a fader's gain,
41  *  for example, or a compressor plugin's threshold.
42  *
43  *  The class knows the Evoral::Parameter that it is controlling, and has
44  *  a list of values for automation.
45  */
46 class LIBEVORAL_API Control
47 {
48 public:
49         Control(const Parameter&               parameter,
50                 const ParameterDescriptor&     desc,
51                 boost::shared_ptr<ControlList> list);
52
53         virtual ~Control() {}
54
55         virtual void   set_double (double val, double frame=0, bool to_list=false);
56         virtual double get_double (bool from_list=false, double frame=0) const;
57
58         /** Get the latest user-set value
59          * (which may not equal get_value() when automation is playing back).
60          *
61          * Automation write/touch works by periodically sampling this value
62          * and adding it to the ControlList.
63          */
64         double user_double() const { return _user_value; }
65
66         void set_list(boost::shared_ptr<ControlList>);
67
68         boost::shared_ptr<ControlList>       list()       { return _list; }
69         boost::shared_ptr<const ControlList> list() const { return _list; }
70
71         inline const Parameter& parameter() const { return _parameter; }
72
73         /** Emitted when the our ControlList is marked dirty */
74         PBD::Signal0<void> ListMarkedDirty;
75
76 protected:
77         Parameter                      _parameter;
78         boost::shared_ptr<ControlList> _list;
79         double                         _user_value;
80         PBD::ScopedConnection          _list_marked_dirty_connection;
81
82 private:
83         void list_marked_dirty ();
84 };
85
86 } // namespace Evoral
87
88 #endif // EVORAL_CONTROL_HPP