changeset 1180:98664afd518b pluginscan

Update for adjusted checker layout, and tidy
author Chris Cannam
date Thu, 14 Apr 2016 16:52:55 +0100
parents 6b1af0f05f06
children 2f628dc9a0b0
files plugin/DSSIPluginFactory.h plugin/FeatureExtractionPluginFactory.cpp plugin/LADSPAPluginFactory.h plugin/PluginScan.cpp plugin/PluginScan.h svcore.pro
diffstat 6 files changed, 43 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/plugin/DSSIPluginFactory.h	Thu Apr 14 14:03:18 2016 +0100
+++ b/plugin/DSSIPluginFactory.h	Thu Apr 14 16:52:55 2016 +0100
@@ -48,8 +48,8 @@
     DSSIPluginFactory();
     friend class RealTimePluginFactory;
 
-    virtual KnownPlugins::PluginType getPluginType() const {
-        return KnownPlugins::DSSIPlugin;
+    virtual PluginScan::PluginType getPluginType() const {
+        return PluginScan::DSSIPlugin;
     }
 
     virtual std::vector<QString> getPluginPath();
--- a/plugin/FeatureExtractionPluginFactory.cpp	Thu Apr 14 14:03:18 2016 +0100
+++ b/plugin/FeatureExtractionPluginFactory.cpp	Thu Apr 14 16:52:55 2016 +0100
@@ -119,8 +119,8 @@
 
     vector<QString> rv;
 
-    QStringList candidates =
-        PluginScan::getInstance()->getCandidateVampLibraries();
+    QStringList candidates = PluginScan::getInstance()->getCandidateLibrariesFor
+        (PluginScan::VampPlugin);
     
     for (QString soname : candidates) {
 
--- a/plugin/LADSPAPluginFactory.h	Thu Apr 14 14:03:18 2016 +0100
+++ b/plugin/LADSPAPluginFactory.h	Thu Apr 14 16:52:55 2016 +0100
@@ -65,8 +65,8 @@
     LADSPAPluginFactory();
     friend class RealTimePluginFactory;
 
-    virtual KnownPlugins::PluginType getPluginType() const {
-        return KnownPlugins::LADSPAPlugin;
+    virtual PluginScan::PluginType getPluginType() const {
+        return PluginScan::LADSPAPlugin;
     }
 
     virtual std::vector<QString> getPluginPath();
--- a/plugin/PluginScan.cpp	Thu Apr 14 14:03:18 2016 +0100
+++ b/plugin/PluginScan.cpp	Thu Apr 14 16:52:55 2016 +0100
@@ -16,11 +16,22 @@
 
 #include "base/Debug.h"
 
+#include "checker/knownplugins.h"
+
 #include <QMutex>
 
 using std::string;
 
-PluginScan *PluginScan::getInstance() {
+class PluginScan::Logger : public PluginCandidates::LogCallback
+{
+protected:
+    void log(std::string message) {
+        SVDEBUG << "PluginScan: " << message;
+    }
+};
+
+PluginScan *PluginScan::getInstance()
+{
     static QMutex mutex;
     static PluginScan *m_instance = 0;
     mutex.lock();
@@ -29,17 +40,12 @@
     return m_instance;
 }
 
-PluginScan::PluginScan() : m_kp(0), m_succeeded(false) {
+PluginScan::PluginScan() : m_kp(0), m_succeeded(false), m_logger(new Logger) {
 }
 
 PluginScan::~PluginScan() {
     delete m_kp;
-}
-
-void
-PluginScan::log(string message)
-{
-    SVDEBUG << "PluginScan: " << message;
+    delete m_logger;
 }
 
 void
@@ -48,7 +54,7 @@
     delete m_kp;
     m_succeeded = false;
     try {
-	m_kp = new KnownPlugins("./helper", this); //!!!
+	m_kp = new KnownPlugins("./helper", m_logger); //!!!
 	m_succeeded = true;
     } catch (const std::exception &e) {
 	cerr << "ERROR: PluginScan::scan: " << e.what() << endl;
@@ -57,33 +63,23 @@
 }
 
 QStringList
-PluginScan::getCandidateLibrariesFor(KnownPlugins::PluginType type) const
+PluginScan::getCandidateLibrariesFor(PluginType type) const
 {
+    KnownPlugins::PluginType kpt;
+    switch (type) {
+    case VampPlugin: kpt = KnownPlugins::VampPlugin; break;
+    case LADSPAPlugin: kpt = KnownPlugins::LADSPAPlugin; break;
+    case DSSIPlugin: kpt = KnownPlugins::DSSIPlugin; break;
+    default: throw std::logic_error("Inconsistency in plugin type enums");
+    }
+    
     QStringList candidates;
     if (!m_kp) return candidates;
-    auto c = m_kp->getCandidateLibrariesFor(type);
+    auto c = m_kp->getCandidateLibrariesFor(kpt);
     for (auto s: c) candidates.push_back(s.c_str());
     return candidates;
 }
 
-QStringList
-PluginScan::getCandidateVampLibraries() const
-{
-    return getCandidateLibrariesFor(KnownPlugins::VampPlugin);
-}
-
-QStringList
-PluginScan::getCandidateLADSPALibraries() const
-{
-    return getCandidateLibrariesFor(KnownPlugins::LADSPAPlugin);
-}
-
-QStringList
-PluginScan::getCandidateDSSILibraries() const
-{
-    return getCandidateLibrariesFor(KnownPlugins::DSSIPlugin);
-}
-
 QString
 PluginScan::getStartupFailureReport() const
 {
--- a/plugin/PluginScan.h	Thu Apr 14 14:03:18 2016 +0100
+++ b/plugin/PluginScan.h	Thu Apr 14 16:52:55 2016 +0100
@@ -17,9 +17,9 @@
 
 #include <QStringList>
 
-#include "../vamp-plugin-load-checker/knownplugins.h" //!!!
+class KnownPlugins;
 
-class PluginScan : public PluginCandidates::LogCallback
+class PluginScan
 {
 public:
     static PluginScan *getInstance();
@@ -28,21 +28,23 @@
 
     bool scanSucceeded() const;
     
-    QStringList getCandidateVampLibraries() const;
-    QStringList getCandidateLADSPALibraries() const;
-    QStringList getCandidateDSSILibraries() const;
-    QStringList getCandidateLibrariesFor(KnownPlugins::PluginType) const;
+    enum PluginType {
+	VampPlugin,
+	LADSPAPlugin,
+	DSSIPlugin
+    };
+    QStringList getCandidateLibrariesFor(PluginType) const;
 
     QString getStartupFailureReport() const;
 
-protected:
-    void log(std::string);
-
 private:
     PluginScan();
     ~PluginScan();
     KnownPlugins *m_kp;
     bool m_succeeded;
+
+    class Logger;
+    Logger *m_logger;
 };
 
 #endif
--- a/svcore.pro	Thu Apr 14 14:03:18 2016 +0100
+++ b/svcore.pro	Thu Apr 14 16:52:55 2016 +0100
@@ -39,7 +39,7 @@
 TARGET = svcore
 
 DEPENDPATH += . data plugin plugin/api/alsa
-INCLUDEPATH += . data plugin plugin/api/alsa ../dataquay
+INCLUDEPATH += . data plugin plugin/api/alsa ../dataquay ../checker
 OBJECTS_DIR = o
 MOC_DIR = o