#include <libsigrokdecode/libsigrokdecode.h>
#endif
-#include <boost/bind.hpp>
-
#include <algorithm>
#include <iterator>
update_device_list();
- _session.start_capture(boost::bind(&MainWindow::session_error, this,
- errorMessage, infoMessage));
+ _session.start_capture([&, errorMessage, infoMessage](QString) {
+ session_error(errorMessage, infoMessage); });
}
void MainWindow::show_session_error(
{
switch(_session.get_capture_state()) {
case SigSession::Stopped:
- _session.start_capture(
- boost::bind(&MainWindow::session_error, this,
- QString("Capture failed"), _1));
+ _session.start_capture([&](QString message) {
+ session_error("Capture failed", message); });
break;
case SigSession::AwaitingTrigger:
#include "decoderoptions.h"
-#include <boost/bind.hpp>
#include <boost/none_t.hpp>
#include <pv/data/decoderstack.h>
#include <pv/prop/int.h>
#include <pv/prop/string.h>
-using boost::bind;
using boost::none;
using std::make_pair;
using std::map;
const QString name = QString::fromUtf8(opt->desc);
- const Property::Getter getter = bind(
- &DecoderOptions::getter, this, opt->id);
- const Property::Setter setter = bind(
- &DecoderOptions::setter, this, opt->id, _1);
+ const Property::Getter get = [&, opt]() {
+ return getter(opt->id); };
+ const Property::Setter set = [&, opt](GVariant *value) {
+ setter(opt->id, value); };
shared_ptr<Property> prop;
if (opt->values)
- prop = bind_enum(name, opt, getter, setter);
+ prop = bind_enum(name, opt, get, set);
else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("d")))
prop = shared_ptr<Property>(new Double(name, 2, "",
- none, none, getter, setter));
+ none, none, get, set));
else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("x")))
prop = shared_ptr<Property>(
- new Int(name, "", none, getter, setter));
+ new Int(name, "", none, get, set));
else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("s")))
prop = shared_ptr<Property>(
- new String(name, getter, setter));
+ new String(name, get, set));
else
continue;
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <boost/bind.hpp>
-
#include <stdint.h>
#include <QDebug>
#include <libsigrok/libsigrok.h>
-using boost::bind;
-using std::function;
using boost::optional;
+using std::function;
using std::make_pair;
using std::pair;
using std::shared_ptr;
const QString name = QString::fromUtf8(info->name);
+ const Property::Getter get = [&, key]() {
+ return _dev_inst->get_config(_group, key); };
+ const Property::Setter set = [&, key](GVariant *value) {
+ _dev_inst->set_config(_group, key, value); };
+
switch(key)
{
case SR_CONF_SAMPLERATE:
break;
case SR_CONF_CAPTURE_RATIO:
- bind_int(name, key, "%", pair<int64_t, int64_t>(0, 100));
+ bind_int(name, "%", pair<int64_t, int64_t>(0, 100),
+ get, set);
break;
case SR_CONF_PATTERN_MODE:
case SR_CONF_FILTER:
case SR_CONF_COUPLING:
case SR_CONF_CLOCK_EDGE:
- bind_enum(name, key, gvar_list);
+ bind_enum(name, key, gvar_list, get, set);
break;
case SR_CONF_EXTERNAL_CLOCK:
case SR_CONF_RLE:
- bind_bool(name, key);
+ bind_bool(name, get, set);
break;
case SR_CONF_TIMEBASE:
- bind_enum(name, key, gvar_list, print_timebase);
+ bind_enum(name, key, gvar_list,
+ get, set, print_timebase);
break;
case SR_CONF_VDIV:
- bind_enum(name, key, gvar_list, print_vdiv);
+ bind_enum(name, key, gvar_list, get, set, print_vdiv);
break;
case SR_CONF_VOLTAGE_THRESHOLD:
- bind_enum(name, key, gvar_list, print_voltage_threshold);
+ bind_enum(name, key, gvar_list,
+ get, set, print_voltage_threshold);
break;
}
g_variant_unref(gvar_opts);
}
-void DeviceOptions::bind_bool(const QString &name, int key)
+void DeviceOptions::bind_bool(const QString &name,
+ Property::Getter getter, Property::Setter setter)
{
assert(_dev_inst);
- _properties.push_back(shared_ptr<Property>(new Bool(name,
- bind(&device::DevInst::get_config, _dev_inst, _group, key),
- bind(&device::DevInst::set_config, _dev_inst,
- _group, key, _1))));
+ _properties.push_back(shared_ptr<Property>(new Bool(
+ name, getter, setter)));
}
void DeviceOptions::bind_enum(const QString &name, int key,
- GVariant *const gvar_list, function<QString (GVariant*)> printer)
+ GVariant *const gvar_list, Property::Getter getter,
+ Property::Setter setter, function<QString (GVariant*)> printer)
{
GVariant *gvar;
GVariantIter iter;
values.push_back(make_pair(gvar, printer(gvar)));
_properties.push_back(shared_ptr<Property>(new Enum(name, values,
- bind(&device::DevInst::get_config, _dev_inst, _group, key),
- bind(&device::DevInst::set_config, _dev_inst,
- _group, key, _1))));
+ getter, setter)));
}
-void DeviceOptions::bind_int(const QString &name, int key, QString suffix,
- optional< std::pair<int64_t, int64_t> > range)
+void DeviceOptions::bind_int(const QString &name, QString suffix,
+ optional< std::pair<int64_t, int64_t> > range,
+ Property::Getter getter, Property::Setter setter)
{
assert(_dev_inst);
_properties.push_back(shared_ptr<Property>(new Int(name, suffix, range,
- bind(&device::DevInst::get_config, _dev_inst, _group, key),
- bind(&device::DevInst::set_config, _dev_inst, _group, key, _1))));
+ getter, setter)));
}
QString DeviceOptions::print_timebase(GVariant *const gvar)
#include <QString>
+#include <glib.h>
+
#include "binding.h"
-#include <glib.h>
+#include <pv/prop/property.h>
struct sr_dev_inst;
struct sr_channel_group;
const sr_channel_group *group = NULL);
private:
- void bind_bool(const QString &name, int key);
+ void bind_bool(const QString &name,
+ Property::Getter getter, Property::Setter setter);
void bind_enum(const QString &name, int key,
GVariant *const gvar_list,
+ Property::Getter getter, Property::Setter setter,
std::function<QString (GVariant*)> printer = print_gvariant);
- void bind_int(const QString &name, int key, QString suffix,
- boost::optional< std::pair<int64_t, int64_t> > range);
+ void bind_int(const QString &name, QString suffix,
+ boost::optional< std::pair<int64_t, int64_t> > range,
+ Property::Getter getter, Property::Setter setter);
static QString print_timebase(GVariant *const gvar);
static QString print_vdiv(GVariant *const gvar);