comparison 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
comparison
equal deleted inserted replaced
442:04b7fd31e1c6 443:381ec750eeee
19 #include "TransformDescription.h" 19 #include "TransformDescription.h"
20 20
21 #include <vamp-sdk/Plugin.h> 21 #include <vamp-sdk/Plugin.h>
22 22
23 #include <QObject> 23 #include <QObject>
24 #include <QStringList>
24 25
25 #include <map> 26 #include <map>
26 #include <set> 27 #include <set>
27 28
28 class TransformFactory : public QObject 29 class TransformFactory : public QObject
39 40
40 std::vector<QString> getAllTransformTypes(); 41 std::vector<QString> getAllTransformTypes();
41 std::vector<QString> getTransformCategories(QString transformType); 42 std::vector<QString> getTransformCategories(QString transformType);
42 std::vector<QString> getTransformMakers(QString transformType); 43 std::vector<QString> getTransformMakers(QString transformType);
43 44
45 struct Match
46 {
47 TransformId transform;
48 int score;
49 QStringList fragments;
50
51 Match() : score(0) { }
52 Match(const Match &m) : transform(m.transform),
53 score(m.score), fragments(m.fragments) { }
54
55 bool operator<(const Match &m) {
56 if (score != m.score) {
57 return score < m.score;
58 } else if (transform != m.transform) {
59 return transform < m.transform;
60 } else if (fragments.size() != m.fragments.size()) {
61 return fragments.size() < m.fragments.size();
62 } else {
63 for (int i = 0; i < fragments.size(); ++i) {
64 if (fragments[i] != m.fragments[i]) {
65 return fragments[i] < m.fragments[i];
66 }
67 }
68 }
69 return false;
70 }
71 };
72
73 typedef std::map<TransformId, Match> SearchResults;
74 SearchResults search(QString keyword);
75 SearchResults search(QStringList keywords);
76
44 /** 77 /**
45 * Return true if the given transform is known. 78 * Return true if the given transform is known.
46 */ 79 */
47 bool haveTransform(TransformId identifier); 80 bool haveTransform(TransformId identifier);
48 81
163 196
164 void populateTransforms(); 197 void populateTransforms();
165 void populateFeatureExtractionPlugins(TransformDescriptionMap &); 198 void populateFeatureExtractionPlugins(TransformDescriptionMap &);
166 void populateRealTimePlugins(TransformDescriptionMap &); 199 void populateRealTimePlugins(TransformDescriptionMap &);
167 200
201 void searchTest(Match &match, QStringList keywords, QString text,
202 QString textType, int score);
203
168 Vamp::PluginBase *instantiateDefaultPluginFor(TransformId id, size_t rate); 204 Vamp::PluginBase *instantiateDefaultPluginFor(TransformId id, size_t rate);
169 205
170 static TransformFactory *m_instance; 206 static TransformFactory *m_instance;
171 }; 207 };
172 208