]> sigrok.org Git - pulseview.git/commitdiff
Implemented getter behaviour in DeviceOptions
authorJoel Holdsworth <redacted>
Sun, 3 Mar 2013 15:47:43 +0000 (15:47 +0000)
committerJoel Holdsworth <redacted>
Sun, 3 Mar 2013 16:51:21 +0000 (16:51 +0000)
pv/prop/binding/deviceoptions.cpp
pv/prop/binding/deviceoptions.h

index b6f2f13605e54b15a34330637e0cf53cf82d44e7..bc367673ed44330e8b89e0e32ae7b495d95dd3bc 100644 (file)
@@ -20,6 +20,8 @@
 
 #include <boost/bind.hpp>
 
+#include <QDebug>
+
 #include "deviceoptions.h"
 
 #include <pv/prop/enum.h>
@@ -86,7 +88,7 @@ void DeviceOptions::expose_enum(const struct sr_config_info *info,
 {
        _properties.push_back(shared_ptr<Property>(
                new Enum(QString(info->name), values,
-                       function<const void* ()>(),
+                       bind(getter, _sdi, key),
                        bind(sr_config_set, _sdi, key, _1))));
 }
 
@@ -151,6 +153,18 @@ void DeviceOptions::bind_vdiv(const struct sr_config_info *info)
        expose_enum(info, values, SR_CONF_VDIV);
 }
 
+const void* DeviceOptions::enum_getter(
+       const struct sr_dev_inst *sdi, int key)
+{
+       const void *data = NULL;
+       if(sr_config_get(sdi->driver, key, &data, sdi) != SR_OK) {
+               qDebug() <<
+                       "WARNING: Failed to get value of config id" << key;
+               return NULL;
+       }
+       return data;
+}
+
 } // binding
 } // prop
 } // pv
index c2c2917536ab019511f2c4cb71b53cea5f8165d7..b622d9379665a014283bb05eea7799907bd97910 100644 (file)
@@ -47,6 +47,10 @@ private:
        void bind_time_base(const struct sr_config_info *info);
        void bind_vdiv(const struct sr_config_info *info);
 
+private:
+       static const void* enum_getter(
+               const struct sr_dev_inst *sdi, int key);
+
 protected:
        struct sr_dev_inst *const _sdi;
 };