Mercurial > hg > svcore
diff plugin/FeatureExtractionPluginFactory.cpp @ 165:5ae5885d6ce3
* Add support for plugin classification using category files.
Add separate menus listing plugins by category, maker, and plugin name.
author | Chris Cannam |
---|---|
date | Thu, 21 Sep 2006 16:43:50 +0000 |
parents | 4b2ea82fd0ed |
children | 06ad01f3e553 |
line wrap: on
line diff
--- a/plugin/FeatureExtractionPluginFactory.cpp Thu Sep 21 11:17:19 2006 +0000 +++ b/plugin/FeatureExtractionPluginFactory.cpp Thu Sep 21 16:43:50 2006 +0000 @@ -24,6 +24,7 @@ #include <QDir> #include <QFile> #include <QFileInfo> +#include <QTextStream> #include <iostream> @@ -171,6 +172,8 @@ } } + generateTaxonomy(); + return rv; } @@ -294,3 +297,54 @@ return rv; } +QString +FeatureExtractionPluginFactory::getPluginCategory(QString identifier) +{ + return m_taxonomy[identifier]; +} + +void +FeatureExtractionPluginFactory::generateTaxonomy() +{ + std::vector<QString> pluginPath = getPluginPath(); + std::vector<QString> path; + + for (size_t i = 0; i < pluginPath.size(); ++i) { + if (pluginPath[i].contains("/lib/")) { + QString p(pluginPath[i]); + path.push_back(p); + p.replace("/lib/", "/share/"); + path.push_back(p); + } + path.push_back(pluginPath[i]); + } + + for (size_t i = 0; i < path.size(); ++i) { + + QDir dir(path[i], "*.cat"); + +// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: directory " << path[i].toStdString() << " has " << dir.count() << " .cat files" << std::endl; + for (unsigned int j = 0; j < dir.count(); ++j) { + + QFile file(path[i] + "/" + dir[j]); + +// std::cerr << "LADSPAPluginFactory::generateFallbackCategories: about to open " << (path[i].toStdString() + "/" + dir[j].toStdString()) << std::endl; + + if (file.open(QIODevice::ReadOnly)) { +// std::cerr << "...opened" << std::endl; + QTextStream stream(&file); + QString line; + + while (!stream.atEnd()) { + line = stream.readLine(); +// std::cerr << "line is: \"" << line.toStdString() << "\"" << std::endl; + QString id = PluginIdentifier::canonicalise + (line.section("::", 0, 0)); + QString cat = line.section("::", 1, 1); + m_taxonomy[id] = cat; +// std::cerr << "FeatureExtractionPluginFactory: set id \"" << id.toStdString() << "\" to cat \"" << cat.toStdString() << "\"" << std::endl; + } + } + } + } +}