Mercurial > hg > svcore
comparison transform/ModelTransformerFactory.h @ 911:73c2fd9a7dbe
Merge from branch tony_integration
author | Chris Cannam |
---|---|
date | Wed, 14 May 2014 09:54:20 +0100 |
parents | a2689db084f4 |
children | 85879408f665 06579b8ffb7b |
comparison
equal
deleted
inserted
replaced
907:a589d2201a0c | 911:73c2fd9a7dbe |
---|---|
16 #ifndef _MODEL_TRANSFORMER_FACTORY_H_ | 16 #ifndef _MODEL_TRANSFORMER_FACTORY_H_ |
17 #define _MODEL_TRANSFORMER_FACTORY_H_ | 17 #define _MODEL_TRANSFORMER_FACTORY_H_ |
18 | 18 |
19 #include "Transform.h" | 19 #include "Transform.h" |
20 #include "TransformDescription.h" | 20 #include "TransformDescription.h" |
21 #include "FeatureExtractionModelTransformer.h" | |
21 | 22 |
22 #include "ModelTransformer.h" | 23 #include "ModelTransformer.h" |
23 | 24 |
24 #include <vamp-hostsdk/PluginBase.h> | 25 #include <vamp-hostsdk/PluginBase.h> |
25 | 26 |
26 #include <QMap> | 27 #include <QMap> |
27 #include <map> | 28 #include <map> |
28 #include <set> | 29 #include <set> |
30 #include <vector> | |
29 | 31 |
30 class AudioPlaySource; | 32 class AudioPlaySource; |
31 | 33 |
32 class ModelTransformerFactory : public QObject | 34 class ModelTransformerFactory : public QObject |
33 { | 35 { |
66 Model *defaultInputModel, | 68 Model *defaultInputModel, |
67 AudioPlaySource *source = 0, | 69 AudioPlaySource *source = 0, |
68 size_t startFrame = 0, | 70 size_t startFrame = 0, |
69 size_t duration = 0, | 71 size_t duration = 0, |
70 UserConfigurator *configurator = 0); | 72 UserConfigurator *configurator = 0); |
73 | |
74 class AdditionalModelHandler { | |
75 public: | |
76 virtual ~AdditionalModelHandler() { } | |
77 | |
78 // Exactly one of these functions will be called | |
79 virtual void moreModelsAvailable(std::vector<Model *> models) = 0; | |
80 virtual void noMoreModelsAvailable() = 0; | |
81 }; | |
71 | 82 |
72 /** | 83 /** |
73 * Return the output model resulting from applying the named | 84 * Return the output model resulting from applying the named |
74 * transform to the given input model. The transform may still be | 85 * transform to the given input model. The transform may still be |
75 * working in the background when the model is returned; check the | 86 * working in the background when the model is returned; check the |
78 * If the transform is unknown or the input model is not an | 89 * If the transform is unknown or the input model is not an |
79 * appropriate type for the given transform, or if some other | 90 * appropriate type for the given transform, or if some other |
80 * problem occurs, return 0. Set message if there is any error or | 91 * problem occurs, return 0. Set message if there is any error or |
81 * warning to report. | 92 * warning to report. |
82 * | 93 * |
94 * Some transforms may return additional models at the end of | |
95 * processing. (For example, a transform that splits an output | |
96 * into multiple one-per-bin models.) If an additionalModelHandler | |
97 * is provided here, its moreModelsAvailable method will be called | |
98 * when those models become available, and ownership of those | |
99 * models will be transferred to the handler. Otherwise (if the | |
100 * handler is null) any such models will be discarded. | |
101 * | |
83 * The returned model is owned by the caller and must be deleted | 102 * The returned model is owned by the caller and must be deleted |
84 * when no longer needed. | 103 * when no longer needed. |
85 */ | 104 */ |
86 Model *transform(const Transform &transform, | 105 Model *transform(const Transform &transform, |
87 const ModelTransformer::Input &input, | 106 const ModelTransformer::Input &input, |
88 QString &message); | 107 QString &message, |
108 AdditionalModelHandler *handler = 0); | |
109 | |
110 /** | |
111 * Return the multiple output models resulting from applying the | |
112 * named transforms to the given input model. The transforms may | |
113 * differ only in output identifier for the plugin: they must all | |
114 * use the same plugin, parameters, and programs. The plugin will | |
115 * be run once only, but more than one output will be harvested | |
116 * (as appropriate). Models will be returned in the same order as | |
117 * the transforms were given. The plugin may still be working in | |
118 * the background when the model is returned; check the output | |
119 * models' isReady completion statuses for more details. | |
120 * | |
121 * If a transform is unknown or the transforms are insufficiently | |
122 * closely related or the input model is not an appropriate type | |
123 * for the given transform, or if some other problem occurs, | |
124 * return 0. Set message if there is any error or warning to | |
125 * report. | |
126 * | |
127 * Some transforms may return additional models at the end of | |
128 * processing. (For example, a transform that splits an output | |
129 * into multiple one-per-bin models.) If an additionalModelHandler | |
130 * is provided here, its moreModelsAvailable method will be called | |
131 * when those models become available, and ownership of those | |
132 * models will be transferred to the handler. Otherwise (if the | |
133 * handler is null) any such models will be discarded. | |
134 * | |
135 * The returned models are owned by the caller and must be deleted | |
136 * when no longer needed. | |
137 */ | |
138 std::vector<Model *> transformMultiple(const Transforms &transform, | |
139 const ModelTransformer::Input &input, | |
140 QString &message, | |
141 AdditionalModelHandler *handler = 0); | |
89 | 142 |
90 protected slots: | 143 protected slots: |
91 void transformerFinished(); | 144 void transformerFinished(); |
92 | 145 |
93 void modelAboutToBeDeleted(Model *); | 146 void modelAboutToBeDeleted(Model *); |
94 | 147 |
95 protected: | 148 protected: |
96 ModelTransformer *createTransformer(const Transform &transform, | 149 ModelTransformer *createTransformer(const Transforms &transforms, |
97 const ModelTransformer::Input &input); | 150 const ModelTransformer::Input &input); |
98 | 151 |
99 typedef std::map<TransformId, QString> TransformerConfigurationMap; | 152 typedef std::map<TransformId, QString> TransformerConfigurationMap; |
100 TransformerConfigurationMap m_lastConfigurations; | 153 TransformerConfigurationMap m_lastConfigurations; |
101 | 154 |
102 typedef std::set<ModelTransformer *> TransformerSet; | 155 typedef std::set<ModelTransformer *> TransformerSet; |
103 TransformerSet m_runningTransformers; | 156 TransformerSet m_runningTransformers; |
104 | 157 |
158 typedef std::map<ModelTransformer *, AdditionalModelHandler *> HandlerMap; | |
159 HandlerMap m_handlers; | |
160 | |
105 static ModelTransformerFactory *m_instance; | 161 static ModelTransformerFactory *m_instance; |
106 }; | 162 }; |
107 | 163 |
108 | 164 |
109 #endif | 165 #endif |