MultiCoreEvaluationRunner::MultiCoreEvaluationRunner()
	: mDoShutDown(false), mShutDownEvent(0), mMessageValue(0), mMinIndex(-1), mMaxIndex(-1)
	{
		connect(this, SIGNAL(quitMainApplication()),
				QCoreApplication::instance(), SLOT(quit()));
		
		mMessageValue = new StringValue("");
		mMessageValue->setNotifyAllSetAttempts(true);
		Core::getInstance()->getValueManager()->addValue(
			"/Evaluation/Messages", mMessageValue);
		
		mNumberOfProcesses = new IntValue(4);
		Core::getInstance()->getValueManager()->addValue(
			"/Evaluation/NumberOfProcesses", mNumberOfProcesses);
		
		
		CommandLineArgument *jobFileNameArg = new CommandLineArgument("scriptFile", "scriptFile", 
									 "<absoluteFileName>", "The name of the main evaluation script",
									 1, 0, true, true);
		
		if(jobFileNameArg->getEntries().size() > 0) {
			QStringList jobScriptName = jobFileNameArg->getEntryParameters(0);
			if(jobScriptName.size() > 0) {
				mJobFile = jobScriptName.at(0);
			}
		}
		
		CommandLineArgument *indicesArg = new CommandLineArgument("index", "index",
									"<minIndex> [<maxIndex]", "The working directory indices to evaluate.\n"
									"If maxIndex is ommited, then only a single evaluation takes place.",
									1, 1, true, true);
		
		if(indicesArg->getEntries().size() > 0) {
			QStringList indicesList = indicesArg->getEntryParameters(0);
			if(indicesList.size() > 0) {
				bool ok = true;
				int index = indicesList.at(0).toInt(&ok);
				if(ok && index >= 0) {
					mMinIndex = index;
				}
			}
			if(indicesList.size() > 1) {
				bool ok = true;
				int index = indicesList.at(1).toInt(&ok);
				if(ok && index >= 0 && index >= mMinIndex) {
					mMaxIndex = index;
				}
			}
			else {
				mMaxIndex = mMinIndex;
			}
		}
		
		
		Core::getInstance()->addSystemObject(this);
	}
NeuroAndSimEvaluationBaseApplication::NeuroAndSimEvaluationBaseApplication() 
	: EvaluationBaseApplication()
{
	Physics::install();
	new ControllerFitnessFunctionParser(dynamic_cast<ControllerProvider*>(Physics::getPhysicsManager()));
	CommandLineArgument *mPlayArgument = 
		new CommandLineArgument("playKeyFrames", "play", "<agent> <file>",
			"Loads keyframe file <file> and starts to playback the keyframes on agent <agent>",
			2, 0, true);

	QStringList files = mPlayArgument->getEntries();

	for(int i = 0; i < files.size(); ++i) {
		QStringList args = files.at(i).split(" ");
		if(args.size() == 2) {
			QString keyFrameTarget(args.at(0));
			QString keyFrameFileName(args.at(1));

			KeyFramePlayer *player = new KeyFramePlayer(keyFrameTarget);
			player->setKeyFrameFile(keyFrameFileName);
		}
		else {
			cerr << "Warning: Size was " << args.size() << endl;
		}
	}
}
bool NerdMultiCoreEvaluationApplication::setupApplication()
{
	bool ok = true;
	
	CommandLineArgument *evalNameArg = new CommandLineArgument("name", "name", "<evalName>",
							 "The name of this evaluation process.", 1, 0, true, true);

	if(evalNameArg->getEntries().size() > 0) {
		QStringList params = evalNameArg->getEntryParameters(0);
		mEvaluationName = params.at(0);
	}
	
	mRunner = new MultiCoreEvaluationRunner();
	
	Core::log("EvaluationName: " + mEvaluationName, true);

	return ok;
}