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 <sigc++/trackable.h>
28 #include <sigc++/signal.h>
29 #include <glibmm/thread.h>
31 #include "pbd/statefuldestructible.h"
37 class Controllable : public PBD::StatefulDestructible {
39 Controllable (const std::string& name, const std::string& uri);
40 virtual ~Controllable() { Destroyed (this); }
42 void set_uri (const std::string&);
43 const std::string& uri() const { return _uri; }
45 virtual void set_value (float) = 0;
46 virtual float get_value (void) const = 0;
48 sigc::signal<void> LearningFinished;
49 static sigc::signal<void,PBD::Controllable*,int,int> CreateBinding;
50 static sigc::signal<void,PBD::Controllable*> DeleteBinding;
52 static sigc::signal<bool,PBD::Controllable*> StartLearning;
53 static sigc::signal<void,PBD::Controllable*> StopLearning;
55 static sigc::signal<void,Controllable*> Destroyed;
57 sigc::signal<void> Changed;
59 int set_state (const XMLNode&, int version);
60 XMLNode& get_state ();
62 std::string name() const { return _name; }
63 bool touching () const { return _touching; }
65 void set_touching (bool yn) { _touching = yn; }
67 static Controllable* by_id (const PBD::ID&);
68 static Controllable* by_name (const std::string&);
69 static Controllable* by_uri (const std::string&);
79 typedef std::set<PBD::Controllable*> Controllables;
80 typedef std::map<std::string,PBD::Controllable*> ControllablesByURI;
81 static Glib::StaticRWLock registry_lock;
82 static Controllables registry;
83 static ControllablesByURI registry_by_uri;
86 /* a utility class for the occasions when you need but do not have
90 class IgnorableControllable : public Controllable
93 IgnorableControllable () : PBD::Controllable ("ignoreMe", std::string()) {}
94 ~IgnorableControllable () {}
96 void set_value (float /*v*/) {}
97 float get_value () const { return 0.0; }
102 #endif /* __pbd_controllable_h__ */