From: Joel Holdsworth Date: Sun, 3 Mar 2013 15:47:43 +0000 (+0000) Subject: Implemented getter behaviour in DeviceOptions X-Git-Tag: pulseview-0.1.0~110 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d71bca8b719331690455e3b3aa8aeeba350c9d3a;p=pulseview.git Implemented getter behaviour in DeviceOptions --- diff --git a/pv/prop/binding/deviceoptions.cpp b/pv/prop/binding/deviceoptions.cpp index b6f2f136..bc367673 100644 --- a/pv/prop/binding/deviceoptions.cpp +++ b/pv/prop/binding/deviceoptions.cpp @@ -20,6 +20,8 @@ #include +#include + #include "deviceoptions.h" #include @@ -86,7 +88,7 @@ void DeviceOptions::expose_enum(const struct sr_config_info *info, { _properties.push_back(shared_ptr( new Enum(QString(info->name), values, - function(), + 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 diff --git a/pv/prop/binding/deviceoptions.h b/pv/prop/binding/deviceoptions.h index c2c29175..b622d937 100644 --- a/pv/prop/binding/deviceoptions.h +++ b/pv/prop/binding/deviceoptions.h @@ -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; };