2 Copyright (C) 2000-2007 Paul Davis
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.
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__
26 #include <sigc++/trackable.h>
27 #include <sigc++/signal.h>
29 #include <pbd/statefuldestructible.h>
35 class Controllable : public PBD::StatefulDestructible {
37 Controllable (std::string name);
38 virtual ~Controllable() { Destroyed (this); }
40 virtual void set_value (float) = 0;
41 virtual float get_value (void) const = 0;
43 virtual bool can_send_feedback() const { return true; }
45 sigc::signal<void> LearningFinished;
46 static sigc::signal<void,PBD::Controllable*,int,int> CreateBinding;
47 static sigc::signal<void,PBD::Controllable*> DeleteBinding;
49 static sigc::signal<bool,PBD::Controllable*> StartLearning;
50 static sigc::signal<void,PBD::Controllable*> StopLearning;
52 static sigc::signal<void,Controllable*> Destroyed;
54 sigc::signal<void> Changed;
56 int set_state (const XMLNode&);
57 XMLNode& get_state ();
59 std::string name() const { return _name; }
61 static Controllable* by_id (const PBD::ID&);
62 static Controllable* by_name (const std::string&);
70 typedef std::set<PBD::Controllable*> Controllables;
71 static Glib::Mutex* registry_lock;
72 static Controllables registry;
75 /* a utility class for the occasions when you need but do not have
79 class IgnorableControllable : public Controllable
82 IgnorableControllable () : PBD::Controllable ("ignoreMe") {}
83 ~IgnorableControllable () {}
85 void set_value (float v){}
86 float get_value () const { return 0.0; }
87 bool can_send_feedback () const { return false; }
92 #endif /* __pbd_controllable_h__ */