comparison capnproto/VampnProto.h @ 13:1d13354ddc44

Build & read config request/response etc
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 17 May 2016 16:18:24 +0100
parents c8451896c40e
children c35d0909a74e
comparison
equal deleted inserted replaced
12:828930f9a65d 13:1d13354ddc44
140 od.hasDuration = r.getHasDuration(); 140 od.hasDuration = r.getHasDuration();
141 141
142 od.hasFixedBinCount = r.getHasFixedBinCount(); 142 od.hasFixedBinCount = r.getHasFixedBinCount();
143 if (od.hasFixedBinCount) { 143 if (od.hasFixedBinCount) {
144 od.binCount = r.getBinCount(); 144 od.binCount = r.getBinCount();
145 od.binNames.clear();
145 for (const auto &n: r.getBinNames()) { 146 for (const auto &n: r.getBinNames()) {
146 od.binNames.push_back(n); 147 od.binNames.push_back(n);
147 } 148 }
148 } 149 }
149 150
199 pd.isQuantized = r.getIsQuantized(); 200 pd.isQuantized = r.getIsQuantized();
200 if (pd.isQuantized) { 201 if (pd.isQuantized) {
201 pd.quantizeStep = r.getQuantizeStep(); 202 pd.quantizeStep = r.getQuantizeStep();
202 } 203 }
203 204
205 pd.valueNames.clear();
204 for (const auto &n: r.getValueNames()) { 206 for (const auto &n: r.getValueNames()) {
205 pd.valueNames.push_back(n); 207 pd.valueNames.push_back(n);
206 } 208 }
207 } 209 }
208 210
246 readRealTime(f.duration, r.getDuration()); 248 readRealTime(f.duration, r.getDuration());
247 } 249 }
248 250
249 f.label = r.getLabel(); 251 f.label = r.getLabel();
250 252
253 f.values.clear();
251 for (auto v: r.getValues()) { 254 for (auto v: r.getValues()) {
252 f.values.push_back(v); 255 f.values.push_back(v);
253 } 256 }
254 } 257 }
255 258
273 276
274 static void 277 static void
275 readFeatureSet(Vamp::Plugin::FeatureSet &fs, 278 readFeatureSet(Vamp::Plugin::FeatureSet &fs,
276 const FeatureSet::Reader &r) { 279 const FeatureSet::Reader &r) {
277 280
281 fs.clear();
278 for (const auto &p: r.getFeaturePairs()) { 282 for (const auto &p: r.getFeaturePairs()) {
279 Vamp::Plugin::FeatureList vfl; 283 Vamp::Plugin::FeatureList vfl;
280 for (const auto &f: p.getFeatures()) { 284 for (const auto &f: p.getFeatures()) {
281 Vamp::Plugin::Feature vf; 285 Vamp::Plugin::Feature vf;
282 readFeature(vf, f); 286 readFeature(vf, f);
364 368
365 d.maker = r.getMaker(); 369 d.maker = r.getMaker();
366 d.copyright = r.getCopyright(); 370 d.copyright = r.getCopyright();
367 d.pluginVersion = r.getPluginVersion(); 371 d.pluginVersion = r.getPluginVersion();
368 372
373 d.category.clear();
369 for (auto c: r.getCategory()) { 374 for (auto c: r.getCategory()) {
370 d.category.push_back(c); 375 d.category.push_back(c);
371 } 376 }
372 377
373 d.minChannelCount = r.getMinChannelCount(); 378 d.minChannelCount = r.getMinChannelCount();
374 d.maxChannelCount = r.getMaxChannelCount(); 379 d.maxChannelCount = r.getMaxChannelCount();
375 380
381 d.parameters.clear();
376 for (auto p: r.getParameters()) { 382 for (auto p: r.getParameters()) {
377 Vamp::Plugin::ParameterDescriptor pd; 383 Vamp::Plugin::ParameterDescriptor pd;
378 readParameterDescriptor(pd, p); 384 readParameterDescriptor(pd, p);
379 d.parameters.push_back(pd); 385 d.parameters.push_back(pd);
380 } 386 }
381 387
388 d.programs.clear();
382 for (auto p: r.getPrograms()) { 389 for (auto p: r.getPrograms()) {
383 d.programs.push_back(p); 390 d.programs.push_back(p);
384 } 391 }
385 392
386 d.inputDomain = toInputDomain(r.getInputDomain()); 393 d.inputDomain = toInputDomain(r.getInputDomain());
387 394
395 d.basicOutputInfo.clear();
388 for (auto o: r.getBasicOutputInfo()) { 396 for (auto o: r.getBasicOutputInfo()) {
389 Vamp::HostExt::PluginStaticData::Basic b; 397 Vamp::HostExt::PluginStaticData::Basic b;
390 readBasicDescriptor(b, o); 398 readBasicDescriptor(b, o);
391 d.basicOutputInfo.push_back(b); 399 d.basicOutputInfo.push_back(b);
392 } 400 }
491 resp.plugin = mapper.handleToPlugin(r.getPluginHandle()); 499 resp.plugin = mapper.handleToPlugin(r.getPluginHandle());
492 readPluginStaticData(resp.staticData, r.getStaticData()); 500 readPluginStaticData(resp.staticData, r.getStaticData());
493 readPluginConfiguration(resp.defaultConfiguration, 501 readPluginConfiguration(resp.defaultConfiguration,
494 r.getDefaultConfiguration()); 502 r.getDefaultConfiguration());
495 } 503 }
504
505 static void
506 buildConfigurationRequest(ConfigurationRequest::Builder &b,
507 const Vamp::HostExt::ConfigurationRequest &cr,
508 PluginHandleMapper &mapper) {
509
510 b.setPluginHandle(mapper.pluginToHandle(cr.plugin));
511 auto c = b.initConfiguration();
512 buildPluginConfiguration(c, cr.configuration);
513 }
514
515 static void
516 readConfigurationRequest(Vamp::HostExt::ConfigurationRequest &cr,
517 const ConfigurationRequest::Reader &r,
518 PluginHandleMapper &mapper) {
519
520 auto h = r.getPluginHandle();
521 cr.plugin = mapper.handleToPlugin(h);
522 auto c = r.getConfiguration();
523 readPluginConfiguration(cr.configuration, c);
524 }
525
526 static void
527 buildConfigurationResponse(ConfigurationResponse::Builder &b,
528 const Vamp::HostExt::ConfigurationResponse &cr) {
529
530 auto olist = b.initOutputs(cr.outputs.size());
531 for (size_t i = 0; i < cr.outputs.size(); ++i) {
532 auto od = olist[i];
533 buildOutputDescriptor(od, cr.outputs[i]);
534 }
535 }
536
537 static void
538 readConfigurationResponse(Vamp::HostExt::ConfigurationResponse &cr,
539 const ConfigurationResponse::Reader &r) {
540
541 cr.outputs.clear();
542 for (const auto &o: r.getOutputs()) {
543 Vamp::Plugin::OutputDescriptor desc;
544 readOutputDescriptor(desc, o);
545 cr.outputs.push_back(desc);
546 }
547 }
496 }; 548 };
497 549
498 } 550 }
499 551
500 552