int ProgramManager::StopProgram( int programId )
{
	Process* process = this->runningPrograms[programId];
	if ( process == NULL )
	{
		EventLogger::Instance()->WriteVerbose( "Program with id %d is not started!", programId );
		return ERROR_PRNOTSTARTED_ID;
	}

	Program* program = process->GetProgram();
	if ( program == NULL )
	{
		EventLogger::Instance()->WriteVerbose( "Program with id %d is not started!", programId );
		return ERROR_PRNOTSTARTED_ID;
	}

	process->Stop();

	// to do !!!
	MappingManager::Instance()->FinalizeProgram( program );

	// delete process & program;
	// delete this->runningPrograms[program->Id()];
	this->runningPrograms[program->Id()] = NULL;
	this->runningPrograms.erase( program->Id() );

	return 0;
}
Program* ProgramManager::GetRunningProgram( int programId )
{
	Process* process = this->runningPrograms[programId];

	if(process == NULL)
		return NULL;

	return process->GetProgram();
}
void ProgramManager::HandleError( void* sender, ErrorItem* error)
{
	Process* process = ( Process* )sender;
	if( process == NULL )
		return;

	Program* program = process->GetProgram();
	if ( program == NULL )
	{
		EventLogger::Instance()->WriteVerbose( "Program with id %d is still not started but an Error in the process with the same id is found!", program->Id() );
		return;
	}

	process->Stop();

	// to do !!!
	MappingManager::Instance()->FinalizeProgram( program );
	// delete process & program;
	// delete this->runningPrograms[program->Id()];
	this->runningPrograms[program->Id()] = NULL;
	this->runningPrograms.erase( program->Id() );
}