comparison transform/TransformFactory.cpp @ 33:544ab25d2372

* Add support for plugin classification using category files. Add separate menus listing plugins by category, maker, and plugin name.
author Chris Cannam
date Thu, 21 Sep 2006 16:43:50 +0000
parents b5f55ea61bb8
children 8ad306d8a568
comparison
equal deleted inserted replaced
32:e3b32dc5180b 33:544ab25d2372
77 } 77 }
78 78
79 return rv; 79 return rv;
80 } 80 }
81 81
82 std::vector<QString>
83 TransformFactory::getTransformCategories(QString transformType)
84 {
85 if (m_transforms.empty()) populateTransforms();
86
87 std::set<QString> categories;
88 for (TransformDescriptionMap::const_iterator i = m_transforms.begin();
89 i != m_transforms.end(); ++i) {
90 if (i->second.type == transformType) {
91 categories.insert(i->second.category);
92 }
93 }
94
95 bool haveEmpty = false;
96
97 std::vector<QString> rv;
98 for (std::set<QString>::iterator i = categories.begin();
99 i != categories.end(); ++i) {
100 if (*i != "") rv.push_back(*i);
101 else haveEmpty = true;
102 }
103
104 if (haveEmpty) rv.push_back(""); // make sure empty category sorts last
105
106 return rv;
107 }
108
109 std::vector<QString>
110 TransformFactory::getTransformMakers(QString transformType)
111 {
112 if (m_transforms.empty()) populateTransforms();
113
114 std::set<QString> makers;
115 for (TransformDescriptionMap::const_iterator i = m_transforms.begin();
116 i != m_transforms.end(); ++i) {
117 if (i->second.type == transformType) {
118 makers.insert(i->second.maker);
119 }
120 }
121
122 bool haveEmpty = false;
123
124 std::vector<QString> rv;
125 for (std::set<QString>::iterator i = makers.begin();
126 i != makers.end(); ++i) {
127 if (*i != "") rv.push_back(*i);
128 else haveEmpty = true;
129 }
130
131 if (haveEmpty) rv.push_back(""); // make sure empty category sorts last
132
133 return rv;
134 }
135
82 void 136 void
83 TransformFactory::populateTransforms() 137 TransformFactory::populateTransforms()
84 { 138 {
85 TransformDescriptionMap transforms; 139 TransformDescriptionMap transforms;
86 140
149 std::cerr << "WARNING: TransformFactory::populateTransforms: Failed to instantiate plugin " << pluginId.toLocal8Bit().data() << std::endl; 203 std::cerr << "WARNING: TransformFactory::populateTransforms: Failed to instantiate plugin " << pluginId.toLocal8Bit().data() << std::endl;
150 continue; 204 continue;
151 } 205 }
152 206
153 QString pluginDescription = plugin->getDescription().c_str(); 207 QString pluginDescription = plugin->getDescription().c_str();
208 QString category = factory->getPluginCategory(pluginId);
209
154 Vamp::Plugin::OutputList outputs = 210 Vamp::Plugin::OutputList outputs =
155 plugin->getOutputDescriptors(); 211 plugin->getOutputDescriptors();
156 212
157 for (size_t j = 0; j < outputs.size(); ++j) { 213 for (size_t j = 0; j < outputs.size(); ++j) {
158 214
176 bool configurable = (!plugin->getPrograms().empty() || 232 bool configurable = (!plugin->getPrograms().empty() ||
177 !plugin->getParameterDescriptors().empty()); 233 !plugin->getParameterDescriptors().empty());
178 234
179 transforms[transformName] = 235 transforms[transformName] =
180 TransformDesc(tr("Analysis Plugins"), 236 TransformDesc(tr("Analysis Plugins"),
237 category,
181 transformName, 238 transformName,
182 userDescription, 239 userDescription,
183 friendlyName, 240 friendlyName,
184 plugin->getMaker().c_str(), 241 plugin->getMaker().c_str(),
185 units, 242 units,
220 descriptor->audioInputPortCount == 0) continue; 277 descriptor->audioInputPortCount == 0) continue;
221 278
222 // std::cout << "TransformFactory::populateRealTimePlugins: plugin " << pluginId.toStdString() << " has " << descriptor->controlOutputPortCount << " output ports" << std::endl; 279 // std::cout << "TransformFactory::populateRealTimePlugins: plugin " << pluginId.toStdString() << " has " << descriptor->controlOutputPortCount << " output ports" << std::endl;
223 280
224 QString pluginDescription = descriptor->name.c_str(); 281 QString pluginDescription = descriptor->name.c_str();
282 QString category = factory->getPluginCategory(pluginId);
225 283
226 for (size_t j = 0; j < descriptor->controlOutputPortCount; ++j) { 284 for (size_t j = 0; j < descriptor->controlOutputPortCount; ++j) {
227 285
228 QString transformName = QString("%1:%2").arg(pluginId).arg(j); 286 QString transformName = QString("%1:%2").arg(pluginId).arg(j);
229 QString userDescription; 287 QString userDescription;
256 314
257 bool configurable = (descriptor->parameterCount > 0); 315 bool configurable = (descriptor->parameterCount > 0);
258 316
259 transforms[transformName] = 317 transforms[transformName] =
260 TransformDesc(tr("Other Plugins"), 318 TransformDesc(tr("Other Plugins"),
319 category,
261 transformName, 320 transformName,
262 userDescription, 321 userDescription,
263 userDescription, 322 userDescription,
264 descriptor->maker.c_str(), 323 descriptor->maker.c_str(),
265 units, 324 units,