Mercurial > hg > svcore
diff plugin/FeatureExtractionPluginFactory.cpp @ 1182:a1f410f895d3 3.0-integration
Merge from branch pluginscan
author | Chris Cannam |
---|---|
date | Fri, 15 Apr 2016 16:26:15 +0100 |
parents | 98664afd518b |
children | 385deb828b4a |
line wrap: on
line diff
--- a/plugin/FeatureExtractionPluginFactory.cpp Fri Mar 18 14:25:05 2016 +0000 +++ b/plugin/FeatureExtractionPluginFactory.cpp Fri Apr 15 16:26:15 2016 +0100 @@ -21,6 +21,8 @@ #include "system/System.h" +#include "PluginScan.h" + #include <QDir> #include <QFile> #include <QFileInfo> @@ -111,87 +113,14 @@ } vector<QString> -FeatureExtractionPluginFactory::getPluginCandidateFiles() -{ - vector<QString> path = getPluginPath(); - vector<QString> candidates; - - for (QString dirname : path) { - -#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << dirname << endl; -#endif - - QDir pluginDir(dirname, PLUGIN_GLOB, - QDir::Name | QDir::IgnoreCase, - QDir::Files | QDir::Readable); - - for (unsigned int j = 0; j < pluginDir.count(); ++j) { - QString soname = pluginDir.filePath(pluginDir[j]); - candidates.push_back(soname); - } - } - - return candidates; -} - -vector<QString> -FeatureExtractionPluginFactory::winnowPluginCandidates(vector<QString> candidates, - QString &warningMessage) -{ - vector<QString> good, bad; - vector<PluginLoadStatus> badStatuses; - - for (QString c: candidates) { - - PluginLoadStatus status = - TestPluginLoadability(c, "vampGetPluginDescriptor"); - - if (status == PluginLoadOK) { - good.push_back(c); - } else if (status == UnknownPluginLoadStatus) { - cerr << "WARNING: Unknown load status for plugin candidate \"" - << c << "\", continuing" << endl; - good.push_back(c); - } else { - bad.push_back(c); - badStatuses.push_back(status); - } - } - - if (!bad.empty()) { - warningMessage = - QObject::tr("<b>Failed to load plugins</b>" - "<p>Failed to load one or more plugin libraries:</p>\n"); - warningMessage += "<ul>"; - for (int i = 0; in_range_for(bad, i); ++i) { - QString m; - if (badStatuses[i] == PluginLoadFailedToLoadLibrary) { - m = QObject::tr("Failed to load library"); - } else if (badStatuses[i] == PluginLoadFailedToFindDescriptor) { - m = QObject::tr("Failed to query plugins from library after loading"); - } else if (badStatuses[i] == PluginLoadFailedElsewhere) { - m = QObject::tr("Unknown failure"); - } else { - m = QObject::tr("Success: internal error?"); - } - warningMessage += QString("<li>%1 (%2)</li>\n") - .arg(bad[i]) - .arg(m); - } - warningMessage += "</ul>"; - } - return good; -} - -vector<QString> FeatureExtractionPluginFactory::getPluginIdentifiers() { Profiler profiler("FeatureExtractionPluginFactory::getPluginIdentifiers"); vector<QString> rv; - vector<QString> candidates = winnowPluginCandidates(getPluginCandidateFiles(), - m_pluginScanError); + + QStringList candidates = PluginScan::getInstance()->getCandidateLibrariesFor + (PluginScan::VampPlugin); for (QString soname : candidates) {