1 | /* |
2 | * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com) |
3 | * |
4 | * This program is free software: you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation, either version 3 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
16 | */ |
17 | #ifndef OJPROBLEMCASESRUNNER_H |
18 | #define OJPROBLEMCASESRUNNER_H |
19 | |
20 | #include "runner.h" |
21 | #include <QVector> |
22 | #include "../problems/ojproblemset.h" |
23 | |
24 | class OJProblemCasesRunner : public Runner |
25 | { |
26 | Q_OBJECT |
27 | public: |
28 | explicit OJProblemCasesRunner(const QString& filename, const QString& arguments, const QString& workDir, |
29 | const QVector<POJProblemCase>& problemCases, QObject *parent = nullptr); |
30 | explicit OJProblemCasesRunner(const QString& filename, const QString& arguments, const QString& workDir, |
31 | POJProblemCase problemCase, QObject *parent = nullptr); |
32 | //max size of output buffer |
33 | int bufferSize() const; |
34 | void setBufferSize(int newBufferSize); |
35 | |
36 | //max time (in milliseconds) waiting to flush output buffer |
37 | int outputRefreshTime() const; |
38 | void setOutputRefreshTime(int newOutputRefreshTime); |
39 | |
40 | int waitForFinishTime() const; |
41 | void setWaitForFinishTime(int newWaitForFinishTime); |
42 | |
43 | int execTimeout() const; |
44 | void setExecTimeout(int newExecTimeout); |
45 | |
46 | signals: |
47 | void caseStarted(const QString &caseId, int current, int total); |
48 | void caseFinished(const QString &caseId, int current, int total); |
49 | void newOutputGetted(const QString &caseId, const QString &newOutputLine); |
50 | void resetOutput(const QString &caseId, const QString &newOutputLine); |
51 | private: |
52 | void runCase(int index, POJProblemCase problemCase); |
53 | private: |
54 | QVector<POJProblemCase> mProblemCases; |
55 | |
56 | // QThread interface |
57 | protected: |
58 | void run() override; |
59 | private: |
60 | int mBufferSize; |
61 | int mOutputRefreshTime; |
62 | int mExecTimeout; |
63 | }; |
64 | |
65 | #endif // OJPROBLEMCASESRUNNER_H |
66 | |