comparison transform/FeatureExtractionModelTransformer.cpp @ 1752:6d09d68165a4 by-id

Further review of ById: make IDs only available when adding a model to the ById store, not by querying the item directly. This means any id encountered in the wild must have been added to the store at some point (even if later released), which simplifies reasoning about lifecycles
author Chris Cannam
date Fri, 05 Jul 2019 15:28:07 +0100
parents b92bdcd4954b
children fd7f127ecd89
comparison
equal deleted inserted replaced
1751:77543124651b 1752:6d09d68165a4
515 out->setRDFTypeURI(outputSignalTypeURI); 515 out->setRDFTypeURI(outputSignalTypeURI);
516 } 516 }
517 517
518 if (out) { 518 if (out) {
519 out->setSourceModel(getInputModel()); 519 out->setSourceModel(getInputModel());
520 ModelById::add(out); 520 m_outputs.push_back(ModelById::add(out));
521 m_outputs.push_back(out->getId());
522 } 521 }
523 } 522 }
524 523
525 void 524 void
526 FeatureExtractionModelTransformer::awaitOutputModels() 525 FeatureExtractionModelTransformer::awaitOutputModels()
602 false); 601 false);
603 602
604 additional->setScaleUnits(baseModel->getScaleUnits()); 603 additional->setScaleUnits(baseModel->getScaleUnits());
605 additional->setRDFTypeURI(baseModel->getRDFTypeURI()); 604 additional->setRDFTypeURI(baseModel->getRDFTypeURI());
606 605
607 ModelId additionalId = additional->getId(); 606 ModelId additionalId = ModelById::add
608 ModelById::add(std::shared_ptr<SparseTimeValueModel>(additional)); 607 (std::shared_ptr<SparseTimeValueModel>(additional));
609 m_additionalModels[n][binNo] = additionalId; 608 m_additionalModels[n][binNo] = additionalId;
610 return additionalId; 609 return additionalId;
611 } 610 }
612 611
613 void 612 void
646 usleep(500000); 645 usleep(500000);
647 } 646 }
648 } 647 }
649 if (m_abandoned) return; 648 if (m_abandoned) return;
650 649
651 auto input = ModelById::getAs<DenseTimeValueModel>(getInputModel()); 650 ModelId inputId = getInputModel();
651 auto input = ModelById::getAs<DenseTimeValueModel>(inputId);
652 if (!input) { 652 if (!input) {
653 abandon(); 653 abandon();
654 return; 654 return;
655 } 655 }
656 656
675 std::vector<FFTModel *> fftModels; 675 std::vector<FFTModel *> fftModels;
676 676
677 if (frequencyDomain) { 677 if (frequencyDomain) {
678 for (int ch = 0; ch < channelCount; ++ch) { 678 for (int ch = 0; ch < channelCount; ++ch) {
679 FFTModel *model = new FFTModel 679 FFTModel *model = new FFTModel
680 (input->getId(), 680 (inputId,
681 channelCount == 1 ? m_input.getChannel() : ch, 681 channelCount == 1 ? m_input.getChannel() : ch,
682 primaryTransform.getWindowType(), 682 primaryTransform.getWindowType(),
683 blockSize, 683 blockSize,
684 stepSize, 684 stepSize,
685 blockSize); 685 blockSize);