Fix binding of automation list undo records to MIDI sources. Should fix the remainde...
[ardour.git] / libs / pbd / pbd / controllable.h
index 28dd4b7a31293d738c55873474569be1aa7535d5..9f5ed5251b125294f203770c8bced207eca65398 100644 (file)
@@ -35,12 +35,16 @@ namespace PBD {
 
 class Controllable : public PBD::StatefulDestructible {
   public:
-       Controllable (const std::string& name, const std::string& uri);
+       enum Flag {
+               Toggle = 0x1,
+               Discrete = 0x2,
+               GainLike = 0x4,
+               IntegerOnly = 0x8
+       };
+
+       Controllable (const std::string& name, Flag f = Flag (0));
        virtual ~Controllable() { Destroyed (this); }
 
-       void set_uri (const std::string&);
-       const std::string& uri() const { return _uri; }
-
        virtual void set_value (float) = 0;
        virtual float get_value (void) const = 0;
 
@@ -59,27 +63,38 @@ class Controllable : public PBD::StatefulDestructible {
        XMLNode& get_state ();
 
        std::string name()      const { return _name; }
-       bool        touching () const { return _touching; }
-       
+
+       bool touching () const { return _touching; }
        void set_touching (bool yn) { _touching = yn; }
 
+       bool is_toggle() const { return _flags & Toggle; }
+       bool is_discrete() const { return _flags & Discrete; }
+       bool is_gain_like() const { return _flags & GainLike; }
+       bool is_integral_only() const { return _flags & IntegerOnly; }
+
+        virtual float lower() const { return 0.0f; }
+        virtual float upper() const { return 1.0f; }
+
+       Flag flags() const { return _flags; }
+       void set_flags (Flag f);
+
+       virtual uint32_t get_discrete_values (std::list<float>&) { return 0; /* no values returned */ }
+
        static Controllable* by_id (const PBD::ID&);
        static Controllable* by_name (const std::string&);
-       static Controllable* by_uri (const std::string&);
 
   private:
        std::string _name;
-       std::string _uri;
+
+       Flag        _flags;
        bool        _touching;
 
        static void add (Controllable&);
        static void remove (Controllable*);
 
        typedef std::set<PBD::Controllable*> Controllables;
-       typedef std::map<std::string,PBD::Controllable*> ControllablesByURI;
        static Glib::StaticRWLock registry_lock;
        static Controllables registry;
-       static ControllablesByURI registry_by_uri;
 };
 
 /* a utility class for the occasions when you need but do not have
@@ -89,7 +104,7 @@ class Controllable : public PBD::StatefulDestructible {
 class IgnorableControllable : public Controllable 
 {
   public: 
-       IgnorableControllable () : PBD::Controllable ("ignoreMe", std::string()) {}
+       IgnorableControllable () : PBD::Controllable ("ignoreMe") {}
        ~IgnorableControllable () {}
     
        void set_value (float /*v*/) {}