2 Copyright (C) 2000-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 v 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.
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.
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.
20 #ifndef __pbd_controllable_h__
21 #define __pbd_controllable_h__
27 #include "pbd/signals.h"
28 #include <glibmm/thread.h>
30 #include "pbd/statefuldestructible.h"
36 class Controllable : public PBD::StatefulDestructible {
45 Controllable (const std::string& name, Flag f = Flag (0));
46 virtual ~Controllable() { Destroyed (this); }
48 virtual void set_value (double) = 0;
49 virtual double get_value (void) const = 0;
51 PBD::Signal0<void> LearningFinished;
52 static PBD::Signal3<void,PBD::Controllable*,int,int> CreateBinding;
53 static PBD::Signal1<void,PBD::Controllable*> DeleteBinding;
55 static PBD::Signal1<bool,PBD::Controllable*> StartLearning;
56 static PBD::Signal1<void,PBD::Controllable*> StopLearning;
58 static PBD::Signal1<void,Controllable*> Destroyed;
60 PBD::Signal0<void> Changed;
62 int set_state (const XMLNode&, int version);
63 XMLNode& get_state ();
65 std::string name() const { return _name; }
67 bool touching () const { return _touching; }
68 void set_touching (bool yn) { _touching = yn; }
70 bool is_toggle() const { return _flags & Toggle; }
71 bool is_discrete() const { return _flags & Discrete; }
72 bool is_gain_like() const { return _flags & GainLike; }
73 bool is_integral_only() const { return _flags & IntegerOnly; }
75 virtual double lower() const { return 0.0; }
76 virtual double upper() const { return 1.0; }
78 Flag flags() const { return _flags; }
79 void set_flags (Flag f);
81 virtual uint32_t get_discrete_values (std::list<float>&) { return 0; /* no values returned */ }
83 static Controllable* by_id (const PBD::ID&);
84 static Controllable* by_name (const std::string&);
85 static const std::string xml_node_name;
92 static void add (Controllable&);
93 static void remove (Controllable*);
95 typedef std::set<PBD::Controllable*> Controllables;
96 static Glib::StaticRWLock registry_lock;
97 static Controllables registry;
100 /* a utility class for the occasions when you need but do not have
104 class IgnorableControllable : public Controllable
107 IgnorableControllable () : PBD::Controllable ("ignoreMe") {}
108 ~IgnorableControllable () {}
110 void set_value (double /*v*/) {}
111 double get_value () const { return 0.0; }
116 #endif /* __pbd_controllable_h__ */