fixed code style, removed unnecessary pragmas

This commit is contained in:
2023-12-03 13:09:16 +03:00
parent bd74d4684f
commit 6b7bde1471
12 changed files with 765 additions and 744 deletions

View File

@@ -1,7 +1,9 @@
#pragma once
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#pragma once
template <class T> template <class T>
class Array { class Array {
protected: protected:

View File

@@ -1,6 +1,8 @@
#pragma once
#include "Supervisor.h" #include "Supervisor.h"
#include "CompilationTask.h" #include "CompilationTask.h"
#pragma once
class CompilationSupervisor : public Supervisor<CompilationTask> { class CompilationSupervisor : public Supervisor<CompilationTask> {
public: public:
CompilationSupervisor() { CompilationSupervisor() {

View File

@@ -1,5 +1,8 @@
#include "Task.h"
#pragma once #pragma once
#include "Task.h"
#include "Text.h"
class CompilationTask : public Task { class CompilationTask : public Task {
String test_id; String test_id;
String makefile_text; String makefile_text;

View File

@@ -1,5 +1,6 @@
#include "Text.h"
#pragma once #pragma once
#include "Text.h"
class File { class File {
FILE* ptr; FILE* ptr;
public: public:
@@ -40,7 +41,8 @@ public:
line->addChar((char)c); line->addChar((char)c);
break; break;
} }
}else { }
else {
switch (c) { switch (c) {
case '\r': case '\r':
break; break;

View File

@@ -1,13 +1,10 @@
#pragma once
#include "String.h" #include "String.h"
#pragma once
String userWorkspace; String userWorkspace;
#pragma once
String packageWorkspace; String packageWorkspace;
#pragma once
int maxKernels; int maxKernels;
#pragma once
int busyKernels; int busyKernels;
#pragma once
int freeKernels; int freeKernels;
#pragma once
String dvm_drv; String dvm_drv;

View File

@@ -1,6 +1,8 @@
#pragma once
#include "CompilationSupervisor.h" #include "CompilationSupervisor.h"
#include "RunTask.h" #include "RunTask.h"
#pragma once
class RunSupervisor : public Supervisor<RunTask> { class RunSupervisor : public Supervisor<RunTask> {
public: public:
RunSupervisor(CompilationSupervisor* compilationSupervisor) { RunSupervisor(CompilationSupervisor* compilationSupervisor) {

View File

@@ -1,5 +1,7 @@
#include "CompilationTask.h"
#pragma once #pragma once
#include "CompilationTask.h"
class RunTask : public Task { class RunTask : public Task {
long testcompilationtask_id; long testcompilationtask_id;
String binary_name; String binary_name;

View File

@@ -1,8 +1,10 @@
#pragma once
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#pragma once
class String { class String {
friend String operator+(const String& a, const String& b); friend String operator+(const String& a, const String& b);
long length; long length;
@@ -144,7 +146,8 @@ public:
if (k < s.length) { if (k < s.length) {
if (body[i] == s.body[k]) { if (body[i] == s.body[k]) {
k++; k++;
}else { }
else {
//обрыв поиска. //обрыв поиска.
search_on = false; search_on = false;
k = 0; k = 0;
@@ -155,7 +158,8 @@ public:
//printf("starts with %ld", start); //printf("starts with %ld", start);
return true; return true;
} }
}else { }
else {
if (body[i] == s.body[0]) { if (body[i] == s.body[0]) {
k = 1; k = 1;
start = i; start = i;
@@ -204,7 +208,6 @@ int main(void) {
return ( fclose(f) ); return ( fclose(f) );
} }
*/ */
}; };
String operator+(const String& a, const String& b) { String operator+(const String& a, const String& b) {

View File

@@ -1,8 +1,9 @@
#pragma once
#include <unistd.h>
#include "File.h" #include "File.h"
#include "Task.h" #include "Task.h"
#include <unistd.h>
#pragma once
enum SupervisorState { enum SupervisorState {
WorkspacesCreation, //0 WorkspacesCreation, //0
Preparation, //1 Preparation, //1
@@ -10,7 +11,7 @@ enum SupervisorState {
Archivation, //3 Archivation, //3
End //4 End //4
}; };
#pragma once
template <class T> template <class T>
class Supervisor : public Array <T> { class Supervisor : public Array <T> {
protected: protected:
@@ -85,7 +86,8 @@ public:
if (task->getState() == WorkspaceReady) { if (task->getState() == WorkspaceReady) {
activeCount++; activeCount++;
task->Start(); task->Start();
}else if (task->getState()==Running){ }
else if (task->getState() == Running) {
activeCount++; activeCount++;
task->Check(); task->Check();
} }

View File

@@ -1,8 +1,9 @@
#pragma once
#include "File.h" #include "File.h"
#include "Utils.h" #include "Utils.h"
#include "Global.h" #include "Global.h"
#pragma once
enum TaskState { enum TaskState {
Inactive, //0 Inactive, //0
Waiting, //1 Waiting, //1
@@ -25,14 +26,13 @@ enum TaskState {
FailedToQueue, //18 FailedToQueue, //18
AbortingByUser //19 AbortingByUser //19
}; };
#pragma once
enum TestType { enum TestType {
Default, //0 Default, //0
Correctness, //1 Correctness, //1
Performance, //2 Performance, //2
}; };
#pragma once
class Task { class Task {
protected: protected:
long id; long id;
@@ -140,11 +140,13 @@ public:
virtual void Check() { virtual void Check() {
if (Utils::Exists(workspace + "/DONE")) { if (Utils::Exists(workspace + "/DONE")) {
analyseResults(); analyseResults();
}else { }
else {
if (Utils::Exists(workspace + "/TIMEOUT")) { if (Utils::Exists(workspace + "/TIMEOUT")) {
state = AbortedByTimeout; state = AbortedByTimeout;
//todo определить по интервалу времени на всякий случай. //todo определить по интервалу времени на всякий случай.
}else if (Utils::Exists(workspace+"/INTERRUPT")){ }
else if (Utils::Exists(workspace + "/INTERRUPT")) {
state = AbortedByUser; state = AbortedByUser;
} }
} }

View File

@@ -1,6 +1,8 @@
#pragma once
#include "String.h" #include "String.h"
#include "Array.h" #include "Array.h"
#pragma once
class Text : public Array<String> { class Text : public Array<String> {
public: public:
void Print() { void Print() {

View File

@@ -1,10 +1,12 @@
#pragma once
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include "String.h" #include "String.h"
#pragma once
class Utils { class Utils {
public: public:
static int max(int a, int b) { static int max(int a, int b) {