# HG changeset patch # User Chris Cannam # Date 1227274655 0 # Node ID c45e6c6722e0477769349167b42d04713aadbab5 # Parent 4c000e196bf13ef059d3d276eccd48219119abfe * Use enum for transform type instead of trying to do dumb things like compare translated strings diff -r 4c000e196bf1 -r c45e6c6722e0 transform/TransformDescription.h --- a/transform/TransformDescription.h Thu Nov 20 14:58:52 2008 +0000 +++ b/transform/TransformDescription.h Fri Nov 21 13:37:35 2008 +0000 @@ -45,8 +45,16 @@ struct TransformDescription { + enum Type { + Analysis, // e.g. vamp plugin output + Effects, // e.g. ladspa plugin with audio in and out + EffectsData, // e.g. control output of ladspa plugin + Generator, // e.g. audio out of ladspa plugin with no audio in + UnknownType + }; + TransformDescription() { } - TransformDescription(QString _type, QString _category, + TransformDescription(Type _type, QString _category, TransformId _identifier, QString _name, QString _friendlyName, QString _description, QString _longDescription, @@ -57,7 +65,7 @@ longDescription(_longDescription), maker(_maker), units(_units), configurable(_configurable) { } - QString type; // e.g. feature extraction plugin + Type type; QString category; // e.g. time > onsets TransformId identifier; // e.g. vamp:vamp-aubio:aubioonset QString name; // plugin's name if 1 output, else "name: output" diff -r 4c000e196bf1 -r c45e6c6722e0 transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Thu Nov 20 14:58:52 2008 +0000 +++ b/transform/TransformFactory.cpp Fri Nov 21 13:37:35 2008 +0000 @@ -212,19 +212,19 @@ } -std::vector +std::vector TransformFactory::getAllTransformTypes() { populateTransforms(); - std::set types; + std::set types; for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); i != m_transforms.end(); ++i) { types.insert(i->second.type); } - std::vector rv; - for (std::set::iterator i = types.begin(); i != types.end(); ++i) { + std::vector rv; + for (std::set::iterator i = types.begin(); i != types.end(); ++i) { rv.push_back(*i); } @@ -232,7 +232,7 @@ } std::vector -TransformFactory::getTransformCategories(QString transformType) +TransformFactory::getTransformCategories(TransformDescription::Type transformType) { populateTransforms(); @@ -259,7 +259,7 @@ } std::vector -TransformFactory::getTransformMakers(QString transformType) +TransformFactory::getTransformMakers(TransformDescription::Type transformType) { populateTransforms(); @@ -285,6 +285,18 @@ return rv; } +QString +TransformFactory::getTransformTypeName(TransformDescription::Type type) const +{ + switch (type) { + case TransformDescription::Analysis: return tr("Analysis"); + case TransformDescription::Effects: return tr("Effects"); + case TransformDescription::EffectsData: return tr("Effects Data"); + case TransformDescription::Generator: return tr("Generator"); + case TransformDescription::UnknownType: return tr("Other"); + } +} + void TransformFactory::populateTransforms() { @@ -436,7 +448,7 @@ // cerr << "Feature extraction plugin transform: " << transformId.toStdString() << " friendly name: " << friendlyName.toStdString() << endl; transforms[transformId] = - TransformDescription(tr("Analysis"), + TransformDescription(TransformDescription::Analysis, category, transformId, userName, @@ -539,7 +551,7 @@ } transforms[transformId] = - TransformDescription(tr("Effects Data"), + TransformDescription(TransformDescription::EffectsData, category, transformId, userName, @@ -557,14 +569,14 @@ if (descriptor->audioOutputPortCount > 0) { QString transformId = QString("%1:A").arg(pluginId); - QString type = tr("Effects"); + TransformDescription::Type type = TransformDescription::Effects; QString description = tr("Transform audio signal with \"%1\" effect plugin (from %2)") .arg(pluginName) .arg(maker); if (descriptor->audioInputPortCount == 0) { - type = tr("Generators"); + type = TransformDescription::Generator; QString description = tr("Generate audio signal using \"%1\" plugin (from %2)") .arg(pluginName) .arg(maker); @@ -641,7 +653,7 @@ if (oname == "") oname = *j; TransformDescription td; - td.type = tr("Analysis"); //!!! should be enum or something + td.type = TransformDescription::Analysis; td.category = ""; td.identifier = tid; @@ -1063,7 +1075,10 @@ match.key = i->first; - matcher.test(match, keywords, i->second.type, tr("Plugin type"), 5); + matcher.test(match, keywords, + getTransformTypeName(i->second.type), + tr("Plugin type"), 5); + matcher.test(match, keywords, i->second.category, tr("Category"), 20); matcher.test(match, keywords, i->second.identifier, tr("System Identifier"), 6); matcher.test(match, keywords, i->second.name, tr("Name"), 30); @@ -1098,7 +1113,10 @@ match.key = i->first; - matcher.test(match, keywords, i->second.type, tr("Plugin type"), 2); + matcher.test(match, keywords, + getTransformTypeName(i->second.type), + tr("Plugin type"), 2); + matcher.test(match, keywords, i->second.category, tr("Category"), 10); matcher.test(match, keywords, i->second.identifier, tr("System Identifier"), 3); matcher.test(match, keywords, i->second.name, tr("Name"), 15); diff -r 4c000e196bf1 -r c45e6c6722e0 transform/TransformFactory.h --- a/transform/TransformFactory.h Thu Nov 20 14:58:52 2008 +0000 +++ b/transform/TransformFactory.h Fri Nov 21 13:37:35 2008 +0000 @@ -68,9 +68,10 @@ TransformInstallStatus getTransformInstallStatus(TransformId id); - std::vector getAllTransformTypes(); - std::vector getTransformCategories(QString transformType); - std::vector getTransformMakers(QString transformType); + std::vector getAllTransformTypes(); + std::vector getTransformCategories(TransformDescription::Type); + std::vector getTransformMakers(TransformDescription::Type); + QString getTransformTypeName(TransformDescription::Type) const; typedef std::map SearchResults; SearchResults search(QString keyword);