void RuntimeSystem::setInputValue(int moduleID,int inputIndex, const utils::Buffer& buf, IControlValueReceiver* cvr) { ControlBlockMap::const_iterator it = m_modules.find(moduleID); if (it == m_modules.end()) { throw std::runtime_error("Module does not exist at " "RuntimeSystem::setInputValue()"); } ModuleControlBlockPtr block = it->second; IModule* n = block->module(); if (inputIndex < 0 || static_cast<unsigned int>(inputIndex) >= n->getInputs().size()) { throw std::runtime_error("Input does not exist at " "RuntimeSystem::setInputValue()"); } block->setChanged(inputIndex); IModule::IInputPtr in = n->getInputs()[inputIndex]; in->setValue(buf); if (cvr != 0) cvr->controlValueChanged(moduleID,inputIndex,buf); }
void RuntimeSystem::disconnect(int moduleID,int inputNumber) { ControlBlockMap::iterator i = m_modules.find(moduleID); if (i == m_modules.end()) throw std::runtime_error("module does not exist " "(RuntimeSystem::disconnect)"); IModule* m = i->second->module(); //TODO: input number is unchecked IModule::IInputPtr in = m->getInputs()[inputNumber]; in->unPlug(); i->second->hasChanged(inputNumber); }
void RuntimeSystem::syncInputValue(int moduleID, int inputIndex, IControlValueReceiver* cvr) const { if (!cvr) return; ControlBlockMap::const_iterator it = m_modules.find(moduleID); if (it == m_modules.end()) { throw std::runtime_error("Module does not exist at " "RuntimeSystem::syncInputValue()"); } DoSync sync(cvr); ModuleControlBlockPtr block = it->second; IModule* n = block->module(); IModule::IInputPtr in = n->getInputs()[inputIndex]; sync(in); }
void RuntimeSystem::deleteModule(int moduleID) { // get the control block for the moduleid ControlBlockMap::iterator it = m_modules.find(moduleID); if (it == m_modules.end()) { // a module with that id doesnt exist throw std::runtime_error("Module does not exist at " "RuntimeSystem::deleteModule()"); } // a module with that id must exist assert(it != m_modules.end()); ModuleControlBlockPtr block = it->second; IModule* n = block->module(); // disconnect all modules that are connected to an output for (ControlBlockMap::iterator i = m_modules.begin(); i != m_modules.end(); ++i) { // is this possible? // if (i->second == 0) continue; assert(i->second != 0); ModuleControlBlockPtr block = i->second; IModule* m = block->module(); // check all inputs of that module for (unsigned int j = 0; j < m->getInputs().size(); ++j) { IModule::IInputPtr in = m->getInputs()[j]; // is it connected? if (in->getConnectedModule() == n) { // yes, the unplug it in->unPlug(); // and signal change block->hasChanged(j); } } } // disconnect all modules that are connected to an input for (unsigned int j = 0; j < n->getInputs().size(); ++j) { IModule::IInputPtr in = n->getInputs()[j]; if (in->getConnectedModule() != 0) in->unPlug(); } // remove the module from the sink list if (n->getOutputs().size() == 0 || !n->isDeterministic()) m_sinks.remove(block); // remove it from the module set // the module control block should be deleted here by its autoptr m_modules.erase(it); #if (ENGINE_VERBOSITY > 0) std::cout << "Deleted Module # " << moduleID << std::endl; #endif }