/** * @brief Connect one input given the content of the config. Used by Connect * * @param x_inputConfig Config of the input * @param xr_module Module to connect * @param x_inputName Name of input */ void Manager::ConnectInput(const mkconf& x_inputConfig, Module& xr_module, const string& x_inputName) const { // Check if connected to our previous module try { string conMod = x_inputConfig.at("connected").at("module").get<string>(); string conOut = x_inputConfig.at("connected").at("output").get<string>(); // Connection of a simple input LOG_DEBUG(m_logger, "Connect input " + x_inputName + " of module " + xr_module.GetName() + " to output " + conMod + ":" + conOut); Stream& inputStream = xr_module.RefInputStreamByName(x_inputName); inputStream.SetBlocking(x_inputConfig.value<int>("block", 1)); inputStream.SetSynchronized(x_inputConfig.value<int>("sync", 1)); Stream& outputStream = RefModuleByName(conMod).RefOutputStreamByName(conOut); // Connect input and output streams inputStream.Connect(outputStream); if(xr_module.GetParameters().GetParameterByName("master").GetValue().get<string>().empty()) RefModuleByName(conMod).AddDependingModule(xr_module); } catch(MkException& e) { LOG_ERROR(m_logger, "Cannot connect input " << x_inputName << " of module " << xr_module.GetName() << ". Reason: " << string(e.what())); throw; } }
/** * @brief Connect one input given the content of the config. Used by Connect * * @param x_inputConfig Config of the input * @param xr_module Module to connect * @param x_inputId Id of input */ void Manager::ConnectInput(const ConfigReader& x_inputConfig, Module& xr_module, int x_inputId) const { // Check if connected to our previous module try { const string& tmp1 = x_inputConfig.GetAttribute("moduleid", ""); const string& tmp2 = x_inputConfig.GetAttribute("outputid", ""); const string& tmp3 = x_inputConfig.GetAttribute("block", "1"); const string& tmp4 = x_inputConfig.GetAttribute("sync", "1"); // Connection of a simple input if(tmp1 != "" && tmp2 != "") { LOG_DEBUG(m_logger, "Connect input " + to_string(x_inputId) + " of module " + xr_module.GetName() + " to output " + tmp1 + ":" + tmp2); int outputModuleId = boost::lexical_cast<int>(tmp1); int outputId = boost::lexical_cast<int>(tmp2); Stream& inputStream = xr_module.RefInputStreamById(x_inputId); inputStream.SetBlocking(boost::lexical_cast<bool>(tmp3)); inputStream.SetSynchronized(boost::lexical_cast<bool>(tmp4)); Stream& outputStream = RefModuleById(outputModuleId).RefOutputStreamById(outputId); // Connect input and output streams inputStream.Connect(&outputStream); if(xr_module.GetParameters().GetParameterByName("master").GetValueString().empty()) RefModuleById(outputModuleId).AddDependingModule(xr_module); } else if(tmp1.empty() && ! tmp2.empty()) throw MkException("Exception while connecting input: missing moduleid in config", LOC); else if(! tmp1.empty() && tmp2.empty()) throw MkException("Exception while connecting input: missing outputid in config", LOC); } catch(MkException& e) { LOG_ERROR(m_logger, "Cannot connect input "<<x_inputConfig.GetAttribute("id", "(unknown)")<<" of module "<<xr_module.GetName()); throw; } }