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 EXECUTABLERUNNER_H
18#define EXECUTABLERUNNER_H
19
20#include "runner.h"
21#include <QProcess>
22#include <QSemaphore>
23
24class ExecutableRunner : public Runner
25{
26 Q_OBJECT
27public:
28 ExecutableRunner(const QString& filename, const QString& arguments, const QString& workDir,
29 QObject* parent = nullptr);
30
31 const QString &redirectInputFilename() const;
32 void setRedirectInputFilename(const QString &newDataFile);
33
34 bool redirectInput() const;
35 void setRedirectInput(bool isRedirect);
36
37 bool startConsole() const;
38 void setStartConsole(bool newStartConsole);
39
40 const QString &shareMemoryId() const;
41
42 void setShareMemoryId(const QString &newShareMemoryId);
43
44 const QStringList &binDirs() const;
45 void addBinDirs(const QStringList &binDirs);
46 void addBinDir(const QString &binDir);
47
48private:
49 QString mRedirectInputFilename;
50 QString mShareMemoryId;
51 bool mRedirectInput;
52 bool mStartConsole;
53 std::shared_ptr<QProcess> mProcess;
54 QSemaphore mQuitSemaphore;
55 QStringList mBinDirs;
56
57 // QThread interface
58protected:
59 void run() override;
60
61 // Runner interface
62protected:
63 void doStop() override;
64};
65
66#endif // EXECUTABLERUNNER_H
67