From 941e22a645e89e7253f0faeb63b74ee97201dd91 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Sun, 11 Jun 2017 11:10:33 +0200 Subject: [PATCH] device manager: Move filter for supported devices to the scan routine Move the check for supported monotonic rate devices from the call site into the actual scan routine. The scan routine already used to (store and) return a variable length set of found devices including none, and call sites can cope with this situation. Pending extensions may call the scan routine several times, and callers shall not duplicate the extra test condition. While we expect the specific test for what's supported to change in the future. --- pv/devicemanager.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/pv/devicemanager.cpp b/pv/devicemanager.cpp index 540f8815..ac6ce6fb 100644 --- a/pv/devicemanager.cpp +++ b/pv/devicemanager.cpp @@ -68,20 +68,7 @@ DeviceManager::DeviceManager(shared_ptr context) : progress->setLabelText(QObject::tr("Scanning for %1...") .arg(QString::fromStdString(entry.first))); - /** - * We currently only support devices that can deliver - * samples at a fixed samplerate i.e. oscilloscopes and - * logic analysers. - * @todo Add support for non-monotonic devices i.e. DMMs - * and sensors. - */ - const auto keys = (entry.second)->config_keys(); - - bool supported_device = keys.count(ConfigKey::LOGIC_ANALYZER) | - keys.count(ConfigKey::OSCILLOSCOPE); - - if (supported_device) - driver_scan(entry.second, map()); + driver_scan(entry.second, map()); progress->setValue(entry_num++); QApplication::processEvents(); @@ -114,6 +101,18 @@ DeviceManager::driver_scan( assert(driver); + /* + * We currently only support devices that can deliver samples at + * a fixed samplerate (i.e. oscilloscopes and logic analysers). + * + * @todo Add support for non-monotonic devices (DMMs, sensors, etc). + */ + const auto keys = driver->config_keys(); + bool supported_device = keys.count(ConfigKey::LOGIC_ANALYZER) | + keys.count(ConfigKey::OSCILLOSCOPE); + if (!supported_device) + return driver_devices; + // Remove any device instances from this driver from the device // list. They will not be valid after the scan. devices_.remove_if([&](shared_ptr device) { -- 2.30.2