#pragma once

#include "CompilationSupervisor.h"     
#include "RunTask.h"   

class RunSupervisor : public Supervisor<RunTask> {
public:
	RunSupervisor(CompilationSupervisor* compilationSupervisor) {
		this->init("runTasks.json");

		//проверить отмененные задачи.  
		for (int i = 0; i < getLength(); ++i) {
			RunTask* task = this->get(i);
			CompilationTask* parent = compilationSupervisor->getTaskById(task->getTestCompilationTaskId());
			task->setState((parent->getState() == Done) ? Waiting : Canceled);
			task->setParent(parent);
#if DEB
			printf("id=%ld; parent_id = %ld; state=%s\n", task->getId(), task->getParent()->getId(), task->printState().getCharArray());
#endif
		}
	}

	String getStatePrefix() override {
		return String("Running");
	}
};
