diff transform/TransformFactory.h @ 443:381ec750eeee

* Add beginnings of transform-search-by-text function
author Chris Cannam
date Mon, 22 Sep 2008 15:44:03 +0000
parents 370aa9714ef5
children 14521503f196
line wrap: on
line diff
--- a/transform/TransformFactory.h	Fri Sep 19 12:55:35 2008 +0000
+++ b/transform/TransformFactory.h	Mon Sep 22 15:44:03 2008 +0000
@@ -21,6 +21,7 @@
 #include <vamp-sdk/Plugin.h>
 
 #include <QObject>
+#include <QStringList>
 
 #include <map>
 #include <set>
@@ -41,6 +42,38 @@
     std::vector<QString> getTransformCategories(QString transformType);
     std::vector<QString> getTransformMakers(QString transformType);
 
+    struct Match
+    {
+        TransformId transform;
+        int score;
+        QStringList fragments;
+
+        Match() : score(0) { }
+        Match(const Match &m) : transform(m.transform),
+                                score(m.score), fragments(m.fragments) { }
+
+        bool operator<(const Match &m) {
+            if (score != m.score) {
+                return score < m.score;
+            } else if (transform != m.transform) {
+                return transform < m.transform;
+            } else if (fragments.size() != m.fragments.size()) {
+                return fragments.size() < m.fragments.size();
+            } else {
+                for (int i = 0; i < fragments.size(); ++i) {
+                    if (fragments[i] != m.fragments[i]) {
+                        return fragments[i] < m.fragments[i];
+                    }
+                }
+            }
+            return false;
+        }
+    };
+
+    typedef std::map<TransformId, Match> SearchResults;
+    SearchResults search(QString keyword);
+    SearchResults search(QStringList keywords);
+    
     /**
      * Return true if the given transform is known.
      */
@@ -165,6 +198,9 @@
     void populateFeatureExtractionPlugins(TransformDescriptionMap &);
     void populateRealTimePlugins(TransformDescriptionMap &);
 
+    void searchTest(Match &match, QStringList keywords, QString text,
+                    QString textType, int score);
+
     Vamp::PluginBase *instantiateDefaultPluginFor(TransformId id, size_t rate);
 
     static TransformFactory *m_instance;