Beispiel #1
0
/**
* @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;
	}
}
ParameterStructure::ParameterStructure(const ConfigReader& x_configReader):
	m_configReader(x_configReader),
	m_moduleName(x_configReader.GetAttribute("name", "unnamed"))
{
	m_writeAllParamsToConfig = false;
}