MLProcPtr MLProcFactory::create(const ml::Symbol className, MLDSPContext* context) { MLProcCreateFnT fn; MLProcPtr resultProc; // get named entry from registry FnRegistryT::const_iterator regEntry = procRegistry.find(className); if (regEntry != procRegistry.end()) { // get creator fn from entry fn = regEntry->second; // call creator fn returning new MLProc subclass instance resultProc = fn(); resultProc->setContext(context); // give root context pointer to new containers if(resultProc->isContainer()) { MLProcContainer& resultContainer = static_cast<MLProcContainer&>(*resultProc); resultContainer.setRootContext(context->getRootContext()); } } else { // TODO anything? debug() << "MLProcFactory::create: class " << className << " not found!!"; } return resultProc; }
MLProcContainer* MLMultProxy::getCopyAsContainer(int c) { MLProcPtr p = mCopies[c]; if (p->isContainer()) { return static_cast<MLProcContainer*>(&(*p)); } else { debug() << "MLMultProxy::getCopyAsContainer: error, copy " << c << " of template " << mTemplate->getName() << "is not container!\n"; return 0; } }
MLProc::err MLMultiContainer::buildProc(juce::XmlElement* parent) { err e = OK; const int copies = (int)mCopies.size(); const MLSymbol className(parent->getStringAttribute("class").toUTF8()); const MLSymbol procName(parent->getStringAttribute("name").toUTF8()); // debug() << "MLMultiContainer::buildProc (class=" << className << ", name=" << procName << ")\n"; for(int i=0; i<copies; i++) { // add the specified proc to all subcontainers. MLProcContainer* pCopy = getCopyAsContainer(i); if(pCopy != nullptr) { e = pCopy->addProc(className, procName); if (e == MLProc::OK) { MLPath procPath(procName); pCopy->setProcParams(procPath, parent); pCopy->setCopyIndex(i + 1); MLProcPtr p = pCopy->getProc(procPath); if(p) { p->setup(); if (p->isContainer()) { MLProcContainer* pc = static_cast<MLProcContainer*>(&(*p)); pc->buildGraph(parent); } } else { debug() << "MLMultiContainer::buildProc: getProc failed for new proc!\n"; } } } else { debug() << "MLMultiContainer: null copy in buildProc ()!\n"; } } return e; }