/*!
 *  \brief Receive a deme content from an evolver node.
 *  \param ioDeme Deme to update by the receive deme.
 *  \param ioContext Current context of the evolution.
 */
void HPC::RecvDemeFromEvolverOp::operate(Deme& ioDeme, Context& ioContext)
{
	Beagle_StackTraceBeginM();

	std::string lNbrProcessed;
	std::string lDemeString;

	mComm->receive(lNbrProcessed, "NbrProcessed", "Child", ioContext.getDemeIndex());
	mComm->receive(lDemeString, "Deme", "Child", ioContext.getDemeIndex());

	Beagle_LogDetailedM(
		ioContext.getSystem().getLogger(),
		"receive", "Beagle::HPC::RecvDemeFromEvolverOp",
		std::string("Supervisor receive deme from his ")+
		uint2ordinal(ioContext.getDemeIndex()+1)+std::string(" evolver")
	);

	prepareStats(ioDeme,ioContext);
	std::istringstream lInStream(lDemeString);
	PACC::XML::Document lDocument(lInStream);

	ioDeme.readPopulation(lDocument.getFirstRoot(), ioContext);

	updateStats(str2uint(lNbrProcessed), ioContext);
	updateHallOfFameWithDeme(ioDeme,ioContext);

	Beagle_StackTraceEndM("void HPC::RecvDemeFromEvolverOp::operate(Deme& ioDeme, Context& ioContext)");
}
/*!
 *  \brief Receive a group of individuals to evaluate from the parent evolver node.
 *  \param ioDeme Current deme to evaluate the individus group.
 *  \param ioContext Current context of the evolution.
 */
void HPC::RecvIndividualsFromEvolverOp::operate(Deme& ioDeme, Context& ioContext)
{
	Beagle_StackTraceBeginM();

	std::string lPopulationString;

	mComm->receive(lPopulationString, "Individuals", "Parent");

	Beagle_LogDetailedM(
		ioContext.getSystem().getLogger(),
		"receive", "Beagle::HPC::RecvIndividualsFromEvolverOp",
		std::string("Evaluator receive individuals from his parent evolver")
	);

	std::istringstream lInStream(lPopulationString);
	PACC::XML::Document lDocument(lInStream);
	ioDeme.readPopulation(lDocument.getFirstRoot(),ioContext);

	Beagle_StackTraceEndM();
}