PluginLoader::PluginCategoryHierarchy PluginLoader::Impl::getPluginCategory(PluginKey plugin) { if (m_taxonomy.empty()) generateTaxonomy(); if (m_taxonomy.find(plugin) == m_taxonomy.end()) { return PluginCategoryHierarchy(); } return m_taxonomy[plugin]; }
std::vector<QString> FeatureExtractionPluginFactory::getPluginIdentifiers() { Profiler profiler("FeatureExtractionPluginFactory::getPluginIdentifiers"); std::vector<QString> rv; std::vector<QString> path = getPluginPath(); for (std::vector<QString>::iterator i = path.begin(); i != path.end(); ++i) { #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << i->toStdString() << std::endl; #endif QDir pluginDir(*i, 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]); #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname.toStdString() << std::endl; #endif void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL); if (!libraryHandle) { std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to load library " << soname.toStdString() << ": " << DLERROR() << std::endl; continue; } #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << std::endl; #endif VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction) DLSYM(libraryHandle, "vampGetPluginDescriptor"); if (!fn) { std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: No descriptor function in " << soname.toStdString() << std::endl; if (DLCLOSE(libraryHandle) != 0) { std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname.toStdString() << std::endl; } continue; } #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << std::endl; #endif const VampPluginDescriptor *descriptor = 0; int index = 0; std::map<std::string, int> known; bool ok = true; while ((descriptor = fn(VAMP_API_VERSION, index))) { if (known.find(descriptor->identifier) != known.end()) { std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Plugin library " << soname.toStdString() << " returns the same plugin identifier \"" << descriptor->identifier << "\" at indices " << known[descriptor->identifier] << " and " << index << std::endl; std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << std::endl; ok = false; break; } else { known[descriptor->identifier] = index; } ++index; } if (ok) { index = 0; while ((descriptor = fn(VAMP_API_VERSION, index))) { QString id = PluginIdentifier::createIdentifier ("vamp", soname, descriptor->identifier); rv.push_back(id); #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id.toStdString() << " at index " << index << std::endl; #endif ++index; } } if (DLCLOSE(libraryHandle) != 0) { std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname.toStdString() << std::endl; } } } generateTaxonomy(); return rv; }