]> sigrok.org Git - pulseview.git/commitdiff
Renamed pv::prop::binding::HwCap to DeviceOptions
authorJoel Holdsworth <redacted>
Sun, 27 Jan 2013 09:40:29 +0000 (09:40 +0000)
committerJoel Holdsworth <redacted>
Sun, 27 Jan 2013 11:21:37 +0000 (11:21 +0000)
CMakeLists.txt
pv/dialogs/hwcap.cpp
pv/dialogs/hwcap.h
pv/prop/binding/deviceoptions.cpp [new file with mode: 0644]
pv/prop/binding/deviceoptions.h [new file with mode: 0644]
pv/prop/binding/hwcap.cpp [deleted file]
pv/prop/binding/hwcap.h [deleted file]

index ebe156d56e5dc902480bbeff3794ba4ab7d831e3..8dd7c259bd80475cfa07f1e981b2c2f86a94fc31 100644 (file)
@@ -104,7 +104,7 @@ set(pulseview_SOURCES
        pv/prop/enum.cpp
        pv/prop/property.cpp
        pv/prop/binding/binding.cpp
-       pv/prop/binding/hwcap.cpp
+       pv/prop/binding/deviceoptions.cpp
        pv/view/analogsignal.cpp
        pv/view/cursor.cpp
        pv/view/header.cpp
index 03255f9da4cec11a03ad82788fc4d4667493e3c8..f3b9400ab3182a2725f74ff0e0154693972347e4 100644 (file)
@@ -28,7 +28,7 @@ HwCap::HwCap(QWidget *parent, struct sr_dev_inst *sdi) :
        _layout(this),
        _button_box(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
                Qt::Horizontal, this),
-       _hw_cap_binding(sdi)
+       _device_options_binding(sdi)
 {
        setWindowTitle(tr("Configure Device"));
 
@@ -37,7 +37,7 @@ HwCap::HwCap(QWidget *parent, struct sr_dev_inst *sdi) :
 
        setLayout(&_layout);
 
-       QWidget *const form = _hw_cap_binding.get_form(this);
+       QWidget *const form = _device_options_binding.get_form(this);
        _layout.addWidget(form);
 
        _layout.addWidget(&_button_box);
@@ -46,7 +46,7 @@ HwCap::HwCap(QWidget *parent, struct sr_dev_inst *sdi) :
 void HwCap::accept()
 {
        QDialog::accept();
-       _hw_cap_binding.commit();
+       _device_options_binding.commit();
 }
 
 } // namespace dialogs
index 771c89712010785426718bd9deae25bf69961e59..692b743e794360b7b3bf84bb81f4da9ba6075551 100644 (file)
@@ -25,7 +25,7 @@
 #include <QDialogButtonBox>
 #include <QVBoxLayout>
 
-#include <pv/prop/binding/hwcap.h>
+#include <pv/prop/binding/deviceoptions.h>
 
 namespace pv {
 namespace dialogs {
@@ -42,7 +42,7 @@ private:
        QVBoxLayout _layout;
        QDialogButtonBox _button_box;
 
-       pv::prop::binding::HwCap _hw_cap_binding;
+       pv::prop::binding::DeviceOptions _device_options_binding;
 };
 
 } // namespace dialogs
diff --git a/pv/prop/binding/deviceoptions.cpp b/pv/prop/binding/deviceoptions.cpp
new file mode 100644 (file)
index 0000000..b6f2f13
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <boost/bind.hpp>
+
+#include "deviceoptions.h"
+
+#include <pv/prop/enum.h>
+
+using namespace boost;
+using namespace std;
+
+namespace pv {
+namespace prop {
+namespace binding {
+
+DeviceOptions::DeviceOptions(struct sr_dev_inst *sdi) :
+       _sdi(sdi)
+{
+       const int *options;
+
+       if ((sr_config_list(sdi->driver, SR_CONF_DEVICE_OPTIONS,
+               (const void **)&options, sdi) != SR_OK) || !options)
+               /* Driver supports no device instance options. */
+               return;
+
+       for (int cap = 0; options[cap]; cap++) {
+               const struct sr_config_info *const info =
+                       sr_config_info_get(options[cap]);
+
+               if (!info)
+                       continue;
+
+               switch(info->key)
+               {
+               case SR_CONF_PATTERN_MODE:
+                       bind_stropt(info, SR_CONF_PATTERN_MODE);
+                       break;
+
+               case SR_CONF_BUFFERSIZE:
+                       bind_buffer_size(info);
+                       break;
+
+               case SR_CONF_TIMEBASE:
+                       bind_time_base(info);
+                       break;
+
+               case SR_CONF_TRIGGER_SOURCE:
+                       bind_stropt(info, SR_CONF_TRIGGER_SOURCE);
+                       break;
+
+               case SR_CONF_FILTER:
+                       bind_stropt(info, SR_CONF_FILTER);
+                       break;
+
+               case SR_CONF_VDIV:
+                       bind_vdiv(info);
+                       break;
+
+               case SR_CONF_COUPLING:
+                       bind_stropt(info, SR_CONF_FILTER);
+                       break;
+               }
+       }
+}
+
+void DeviceOptions::expose_enum(const struct sr_config_info *info,
+       const vector< pair<const void*, QString> > &values, int key)
+{
+       _properties.push_back(shared_ptr<Property>(
+               new Enum(QString(info->name), values,
+                       function<const void* ()>(),
+                       bind(sr_config_set, _sdi, key, _1))));
+}
+
+void DeviceOptions::bind_stropt(
+       const struct sr_config_info *info, int key)
+{
+       const char **stropts;
+       if (sr_config_list(_sdi->driver, key,
+               (const void **)&stropts, _sdi) != SR_OK)
+               return;
+
+       vector< pair<const void*, QString> > values;
+       for (int i = 0; stropts[i]; i++)
+               values.push_back(make_pair(stropts[i], stropts[i]));
+
+       expose_enum(info, values, key);
+}
+
+void DeviceOptions::bind_buffer_size(const struct sr_config_info *info)
+{
+       const uint64_t *sizes;
+       if (sr_config_list(_sdi->driver, SR_CONF_BUFFERSIZE,
+                       (const void **)&sizes, _sdi) != SR_OK)
+               return;
+
+       vector< pair<const void*, QString> > values;
+       for (int i = 0; sizes[i]; i++)
+               values.push_back(make_pair(sizes + i,
+                       QString("%1").arg(sizes[i])));
+
+       expose_enum(info, values, SR_CONF_BUFFERSIZE);
+}
+
+void DeviceOptions::bind_time_base(const struct sr_config_info *info)
+{
+       struct sr_rational *timebases;
+       if (sr_config_list(_sdi->driver, SR_CONF_TIMEBASE,
+                       (const void **)&timebases, _sdi) != SR_OK)
+               return;
+
+       vector< pair<const void*, QString> > values;
+       for (int i = 0; timebases[i].p && timebases[i].q; i++)
+               values.push_back(make_pair(timebases + i,
+                       QString(sr_period_string(
+                               timebases[i].p * timebases[i].q))));
+
+       expose_enum(info, values, SR_CONF_TIMEBASE);
+}
+
+void DeviceOptions::bind_vdiv(const struct sr_config_info *info)
+{
+       struct sr_rational *vdivs;
+       if (sr_config_list(_sdi->driver, SR_CONF_VDIV,
+                       (const void **)&vdivs, _sdi) != SR_OK)
+               return;
+
+       vector< pair<const void*, QString> > values;
+       for (int i = 0; vdivs[i].p && vdivs[i].q; i++)
+               values.push_back(make_pair(vdivs + i,
+                       QString(sr_voltage_string(vdivs + i))));
+
+       expose_enum(info, values, SR_CONF_VDIV);
+}
+
+} // binding
+} // prop
+} // pv
+
diff --git a/pv/prop/binding/deviceoptions.h b/pv/prop/binding/deviceoptions.h
new file mode 100644 (file)
index 0000000..ce0799b
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#ifndef PULSEVIEW_PV_PROP_BINDING_DEVICEOPTIONS_H
+#define PULSEVIEW_PV_PROP_BINDING_DEVICEOPTIONS_H
+
+#include <QString>
+
+extern "C" {
+#include <libsigrok/libsigrok.h>
+}
+
+#include "binding.h"
+
+namespace pv {
+namespace prop {
+namespace binding {
+
+class DeviceOptions : public Binding
+{
+public:
+       DeviceOptions(struct sr_dev_inst *sdi);
+
+private:
+       void expose_enum(const struct sr_config_info *info,
+               const std::vector<std::pair<const void*, QString> > &values,
+               int opt);
+
+       void bind_stropt(const struct sr_config_info *info, int key);
+
+       void bind_buffer_size(const struct sr_config_info *info);
+       void bind_time_base(const struct sr_config_info *info);
+       void bind_vdiv(const struct sr_config_info *info);
+
+protected:
+       const struct sr_dev_inst *_sdi;
+};
+
+} // binding
+} // prop
+} // pv
+
+#endif // PULSEVIEW_PV_PROP_BINDING_DEVICEOPTIONS_H
diff --git a/pv/prop/binding/hwcap.cpp b/pv/prop/binding/hwcap.cpp
deleted file mode 100644 (file)
index cb68987..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#include <boost/bind.hpp>
-
-#include "hwcap.h"
-
-#include <pv/prop/enum.h>
-
-using namespace boost;
-using namespace std;
-
-namespace pv {
-namespace prop {
-namespace binding {
-
-HwCap::HwCap(struct sr_dev_inst *sdi) :
-       _sdi(sdi)
-{
-       const int *options;
-
-       if ((sr_config_list(sdi->driver, SR_CONF_DEVICE_OPTIONS,
-               (const void **)&options, sdi) != SR_OK) || !options)
-               /* Driver supports no device instance options. */
-               return;
-
-       for (int cap = 0; options[cap]; cap++) {
-               const struct sr_config_info *const info =
-                       sr_config_info_get(options[cap]);
-
-               if (!info)
-                       continue;
-
-               switch(info->key)
-               {
-               case SR_CONF_PATTERN_MODE:
-                       bind_stropt(info, SR_CONF_PATTERN_MODE);
-                       break;
-
-               case SR_CONF_BUFFERSIZE:
-                       bind_buffer_size(info);
-                       break;
-
-               case SR_CONF_TIMEBASE:
-                       bind_time_base(info);
-                       break;
-
-               case SR_CONF_TRIGGER_SOURCE:
-                       bind_stropt(info, SR_CONF_TRIGGER_SOURCE);
-                       break;
-
-               case SR_CONF_FILTER:
-                       bind_stropt(info, SR_CONF_FILTER);
-                       break;
-
-               case SR_CONF_VDIV:
-                       bind_vdiv(info);
-                       break;
-
-               case SR_CONF_COUPLING:
-                       bind_stropt(info, SR_CONF_FILTER);
-                       break;
-               }
-       }
-}
-
-void HwCap::expose_enum(const struct sr_config_info *info,
-       const vector< pair<const void*, QString> > &values, int key)
-{
-       _properties.push_back(shared_ptr<Property>(
-               new Enum(QString(info->name), values,
-                       function<const void* ()>(),
-                       bind(sr_config_set, _sdi, key, _1))));
-}
-
-void HwCap::bind_stropt(const struct sr_config_info *info, int key)
-{
-       const char **stropts;
-       if (sr_config_list(_sdi->driver, key,
-               (const void **)&stropts, _sdi) != SR_OK)
-               return;
-
-       vector< pair<const void*, QString> > values;
-       for (int i = 0; stropts[i]; i++)
-               values.push_back(make_pair(stropts[i], stropts[i]));
-
-       expose_enum(info, values, key);
-}
-
-void HwCap::bind_buffer_size(const struct sr_config_info *info)
-{
-       const uint64_t *sizes;
-       if (sr_config_list(_sdi->driver, SR_CONF_BUFFERSIZE,
-                       (const void **)&sizes, _sdi) != SR_OK)
-               return;
-
-       vector< pair<const void*, QString> > values;
-       for (int i = 0; sizes[i]; i++)
-               values.push_back(make_pair(sizes + i,
-                       QString("%1").arg(sizes[i])));
-
-       expose_enum(info, values, SR_CONF_BUFFERSIZE);
-}
-
-void HwCap::bind_time_base(const struct sr_config_info *info)
-{
-       struct sr_rational *timebases;
-       if (sr_config_list(_sdi->driver, SR_CONF_TIMEBASE,
-                       (const void **)&timebases, _sdi) != SR_OK)
-               return;
-
-       vector< pair<const void*, QString> > values;
-       for (int i = 0; timebases[i].p && timebases[i].q; i++)
-               values.push_back(make_pair(timebases + i,
-                       QString(sr_period_string(
-                               timebases[i].p * timebases[i].q))));
-
-       expose_enum(info, values, SR_CONF_TIMEBASE);
-}
-
-void HwCap::bind_vdiv(const struct sr_config_info *info)
-{
-       struct sr_rational *vdivs;
-       if (sr_config_list(_sdi->driver, SR_CONF_VDIV,
-                       (const void **)&vdivs, _sdi) != SR_OK)
-               return;
-
-       vector< pair<const void*, QString> > values;
-       for (int i = 0; vdivs[i].p && vdivs[i].q; i++)
-               values.push_back(make_pair(vdivs + i,
-                       QString(sr_voltage_string(vdivs + i))));
-
-       expose_enum(info, values, SR_CONF_VDIV);
-}
-
-} // binding
-} // prop
-} // pv
-
diff --git a/pv/prop/binding/hwcap.h b/pv/prop/binding/hwcap.h
deleted file mode 100644 (file)
index 1c6a747..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#ifndef PULSEVIEW_PV_PROP_BINDING_HWCAP_H
-#define PULSEVIEW_PV_PROP_BINDING_HWCAP_H
-
-#include <QString>
-
-extern "C" {
-#include <libsigrok/libsigrok.h>
-}
-
-#include "binding.h"
-
-namespace pv {
-namespace prop {
-namespace binding {
-
-class HwCap : public Binding
-{
-public:
-       HwCap(struct sr_dev_inst *sdi);
-
-private:
-       void expose_enum(const struct sr_config_info *info,
-               const std::vector<std::pair<const void*, QString> > &values,
-               int opt);
-
-       void bind_stropt(const struct sr_config_info *info, int key);
-
-       void bind_buffer_size(const struct sr_config_info *info);
-       void bind_time_base(const struct sr_config_info *info);
-       void bind_vdiv(const struct sr_config_info *info);
-
-protected:
-       const struct sr_dev_inst *_sdi;
-};
-
-} // binding
-} // prop
-} // pv
-
-#endif // PULSEVIEW_PV_PROP_BINDING_HWCAP_H