Mercurial > hg > svcore
comparison transform/ModelTransformerFactory.h @ 877:b109b88bfa85 tonioni
Callback handler for additional models at end of processing
author | Chris Cannam |
---|---|
date | Wed, 29 Jan 2014 15:58:15 +0000 |
parents | 13803edd513d |
children | a2689db084f4 |
comparison
equal
deleted
inserted
replaced
876:47aa3aeb687b | 877:b109b88bfa85 |
---|---|
68 Model *defaultInputModel, | 68 Model *defaultInputModel, |
69 AudioPlaySource *source = 0, | 69 AudioPlaySource *source = 0, |
70 size_t startFrame = 0, | 70 size_t startFrame = 0, |
71 size_t duration = 0, | 71 size_t duration = 0, |
72 UserConfigurator *configurator = 0); | 72 UserConfigurator *configurator = 0); |
73 | |
74 class AdditionalModelHandler { | |
75 public: | |
76 virtual void moreModelsAvailable(std::vector<Model *> models) = 0; | |
77 }; | |
73 | 78 |
74 /** | 79 /** |
75 * Return the output model resulting from applying the named | 80 * Return the output model resulting from applying the named |
76 * transform to the given input model. The transform may still be | 81 * transform to the given input model. The transform may still be |
77 * working in the background when the model is returned; check the | 82 * working in the background when the model is returned; check the |
80 * If the transform is unknown or the input model is not an | 85 * If the transform is unknown or the input model is not an |
81 * appropriate type for the given transform, or if some other | 86 * appropriate type for the given transform, or if some other |
82 * problem occurs, return 0. Set message if there is any error or | 87 * problem occurs, return 0. Set message if there is any error or |
83 * warning to report. | 88 * warning to report. |
84 * | 89 * |
90 * Some transforms may return additional models at the end of | |
91 * processing. (For example, a transform that splits an output | |
92 * into multiple one-per-bin models.) If an additionalModelHandler | |
93 * is provided here, its moreModelsAvailable method will be called | |
94 * when those models become available, and ownership of those | |
95 * models will be transferred to the handler. Otherwise (if the | |
96 * handler is null) any such models will be discarded. | |
97 * | |
85 * The returned model is owned by the caller and must be deleted | 98 * The returned model is owned by the caller and must be deleted |
86 * when no longer needed. | 99 * when no longer needed. |
87 */ | 100 */ |
88 Model *transform(const Transform &transform, | 101 Model *transform(const Transform &transform, |
89 const ModelTransformer::Input &input, | 102 const ModelTransformer::Input &input, |
90 QString &message); | 103 QString &message, |
104 AdditionalModelHandler *handler = 0); | |
91 | 105 |
92 /** | 106 /** |
93 * Return the multiple output models resulting from applying the | 107 * Return the multiple output models resulting from applying the |
94 * named transforms to the given input model. The transforms may | 108 * named transforms to the given input model. The transforms may |
95 * differ only in output identifier for the plugin: they must all | 109 * differ only in output identifier for the plugin: they must all |
103 * If a transform is unknown or the transforms are insufficiently | 117 * If a transform is unknown or the transforms are insufficiently |
104 * closely related or the input model is not an appropriate type | 118 * closely related or the input model is not an appropriate type |
105 * for the given transform, or if some other problem occurs, | 119 * for the given transform, or if some other problem occurs, |
106 * return 0. Set message if there is any error or warning to | 120 * return 0. Set message if there is any error or warning to |
107 * report. | 121 * report. |
108 * | 122 * |
123 * Some transforms may return additional models at the end of | |
124 * processing. (For example, a transform that splits an output | |
125 * into multiple one-per-bin models.) If an additionalModelHandler | |
126 * is provided here, its moreModelsAvailable method will be called | |
127 * when those models become available, and ownership of those | |
128 * models will be transferred to the handler. Otherwise (if the | |
129 * handler is null) any such models will be discarded. | |
130 * | |
109 * The returned models are owned by the caller and must be deleted | 131 * The returned models are owned by the caller and must be deleted |
110 * when no longer needed. | 132 * when no longer needed. |
111 */ | 133 */ |
112 std::vector<Model *> transformMultiple(const Transforms &transform, | 134 std::vector<Model *> transformMultiple(const Transforms &transform, |
113 const ModelTransformer::Input &input, | 135 const ModelTransformer::Input &input, |
114 QString &message); | 136 QString &message, |
137 AdditionalModelHandler *handler = 0); | |
115 | 138 |
116 protected slots: | 139 protected slots: |
117 void transformerFinished(); | 140 void transformerFinished(); |
118 | 141 |
119 void modelAboutToBeDeleted(Model *); | 142 void modelAboutToBeDeleted(Model *); |
126 TransformerConfigurationMap m_lastConfigurations; | 149 TransformerConfigurationMap m_lastConfigurations; |
127 | 150 |
128 typedef std::set<ModelTransformer *> TransformerSet; | 151 typedef std::set<ModelTransformer *> TransformerSet; |
129 TransformerSet m_runningTransformers; | 152 TransformerSet m_runningTransformers; |
130 | 153 |
154 typedef std::map<ModelTransformer *, AdditionalModelHandler *> HandlerMap; | |
155 HandlerMap m_handlers; | |
156 | |
131 static ModelTransformerFactory *m_instance; | 157 static ModelTransformerFactory *m_instance; |
132 }; | 158 }; |
133 | 159 |
134 | 160 |
135 #endif | 161 #endif |