comparison transform/TransformFactory.h @ 457:ef14acd6d102

* Add beginnings of capability to search plugins that are not yet installed -- lots more work to do here, though
author Chris Cannam
date Tue, 14 Oct 2008 16:36:35 +0000
parents aa190a6a2625
children 93fb1ebff76b
comparison
equal deleted inserted replaced
456:64e64e304a12 457:ef14acd6d102
16 #ifndef _TRANSFORM_FACTORY_H_ 16 #ifndef _TRANSFORM_FACTORY_H_
17 #define _TRANSFORM_FACTORY_H_ 17 #define _TRANSFORM_FACTORY_H_
18 18
19 #include "TransformDescription.h" 19 #include "TransformDescription.h"
20 20
21 #include "base/TextMatcher.h"
22
21 #include <vamp-sdk/Plugin.h> 23 #include <vamp-sdk/Plugin.h>
22 24
23 #include <QObject> 25 #include <QObject>
24 #include <QStringList> 26 #include <QStringList>
25 27
29 class TransformFactory : public QObject 31 class TransformFactory : public QObject
30 { 32 {
31 Q_OBJECT 33 Q_OBJECT
32 34
33 public: 35 public:
36 TransformFactory();
34 virtual ~TransformFactory(); 37 virtual ~TransformFactory();
35 38
36 static TransformFactory *getInstance(); 39 static TransformFactory *getInstance();
37 40
38 TransformList getAllTransformDescriptions(); 41 TransformList getAllTransformDescriptions();
39 TransformDescription getTransformDescription(TransformId id); 42 TransformDescription getTransformDescription(TransformId id);
40 43
44 TransformList getUninstalledTransformDescriptions();
45 TransformDescription getUninstalledTransformDescription(TransformId id);
46
47 typedef enum {
48 TransformUnknown,
49 TransformInstalled,
50 TransformNotInstalled
51 } TransformInstallStatus;
52
53 TransformInstallStatus getTransformInstallStatus(TransformId id);
54
41 std::vector<QString> getAllTransformTypes(); 55 std::vector<QString> getAllTransformTypes();
42 std::vector<QString> getTransformCategories(QString transformType); 56 std::vector<QString> getTransformCategories(QString transformType);
43 std::vector<QString> getTransformMakers(QString transformType); 57 std::vector<QString> getTransformMakers(QString transformType);
44 58
45 struct Match 59 typedef std::map<TransformId, TextMatcher::Match> SearchResults;
46 {
47 TransformId transform;
48 int score;
49 typedef std::map<QString, QString> FragmentMap;
50 FragmentMap fragments;
51
52 Match() : score(0) { }
53 Match(const Match &m) :
54 transform(m.transform), score(m.score), fragments(m.fragments) { }
55
56 bool operator<(const Match &m) const; // sort by score first
57 };
58
59 typedef std::map<TransformId, Match> SearchResults;
60 SearchResults search(QString keyword); 60 SearchResults search(QString keyword);
61 SearchResults search(QStringList keywords); 61 SearchResults search(QStringList keywords);
62 62
63 /** 63 /**
64 * Return true if the given transform is known. 64 * Return true if the given transform is known.
176 void setParametersFromPluginConfigurationXml(Transform &transform, 176 void setParametersFromPluginConfigurationXml(Transform &transform,
177 QString xml); 177 QString xml);
178 178
179 protected: 179 protected:
180 typedef std::map<TransformId, TransformDescription> TransformDescriptionMap; 180 typedef std::map<TransformId, TransformDescription> TransformDescriptionMap;
181
181 TransformDescriptionMap m_transforms; 182 TransformDescriptionMap m_transforms;
183 bool m_transformsPopulated;
184
185 TransformDescriptionMap m_uninstalledTransforms;
186 bool m_uninstalledTransformsPopulated;
182 187
183 void populateTransforms(); 188 void populateTransforms();
189 void populateUninstalledTransforms();
184 void populateFeatureExtractionPlugins(TransformDescriptionMap &); 190 void populateFeatureExtractionPlugins(TransformDescriptionMap &);
185 void populateRealTimePlugins(TransformDescriptionMap &); 191 void populateRealTimePlugins(TransformDescriptionMap &);
186
187 void searchTest(Match &match, QStringList keywords, QString text,
188 QString textType, int score);
189 192
190 Vamp::PluginBase *instantiateDefaultPluginFor(TransformId id, size_t rate); 193 Vamp::PluginBase *instantiateDefaultPluginFor(TransformId id, size_t rate);
191 194
192 static TransformFactory *m_instance; 195 static TransformFactory *m_instance;
193 }; 196 };