1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 18:53:52 +00:00
openmw/apps/opencs/model/doc/runner.hpp

83 lines
1.9 KiB
C++
Raw Normal View History

2014-09-02 08:21:17 +00:00
#ifndef CSM_DOC_RUNNER_H
#define CSM_DOC_RUNNER_H
#include <string>
2022-09-22 18:26:05 +00:00
#include <vector>
2014-09-02 08:21:17 +00:00
#include <QObject>
#include <QProcess>
2014-09-05 11:49:34 +00:00
#include <QTextDocument>
2014-09-02 08:21:17 +00:00
#include <components/esm3/debugprofile.hpp>
#include <filesystem>
class QTemporaryFile;
2014-09-02 08:21:17 +00:00
namespace CSMDoc
{
class OperationHolder;
2022-09-22 18:26:05 +00:00
2014-09-02 08:21:17 +00:00
class Runner : public QObject
{
2022-09-22 18:26:05 +00:00
Q_OBJECT
2014-09-02 08:21:17 +00:00
2022-09-22 18:26:05 +00:00
QProcess mProcess;
bool mRunning;
ESM::DebugProfile mProfile;
std::vector<std::filesystem::path> mContentFiles;
std::string mStartupInstruction;
QTemporaryFile* mStartup;
QTextDocument mLog;
std::filesystem::path mProjectPath;
2014-09-02 08:21:17 +00:00
2022-09-22 18:26:05 +00:00
public:
Runner(std::filesystem::path projectPath);
2014-09-02 08:21:17 +00:00
2022-09-22 18:26:05 +00:00
~Runner();
2014-09-02 08:21:17 +00:00
2022-09-22 18:26:05 +00:00
/// \param delayed Flag as running but do not start the OpenMW process yet (the
/// process must be started by another call of start with delayed==false)
void start(bool delayed = false);
2022-09-22 18:26:05 +00:00
void stop();
2014-09-02 08:21:17 +00:00
2022-09-22 18:26:05 +00:00
/// \note Running state is entered when the start function is called. This
/// is not necessarily identical to the moment the child process is started.
bool isRunning() const;
2014-09-02 08:21:17 +00:00
2022-09-22 18:26:05 +00:00
void configure(const ESM::DebugProfile& profile, const std::vector<std::filesystem::path>& contentFiles,
const std::string& startupInstruction);
2022-09-22 18:26:05 +00:00
QTextDocument* getLog();
2022-09-22 18:26:05 +00:00
signals:
2014-09-05 11:49:34 +00:00
2022-09-22 18:26:05 +00:00
void runStateChanged();
2014-09-02 08:21:17 +00:00
2022-09-22 18:26:05 +00:00
private slots:
2014-09-02 08:21:17 +00:00
2022-09-22 18:26:05 +00:00
void finished(int exitCode, QProcess::ExitStatus exitStatus);
2014-09-02 08:21:17 +00:00
2022-09-22 18:26:05 +00:00
void readyReadStandardOutput();
2014-09-02 08:21:17 +00:00
};
/// \brief Watch for end of save operation and restart or stop runner
class SaveWatcher : public QObject
{
2022-09-22 18:26:05 +00:00
Q_OBJECT
2022-09-22 18:26:05 +00:00
Runner* mRunner;
2022-09-22 18:26:05 +00:00
public:
/// *this attaches itself to runner
SaveWatcher(Runner* runner, OperationHolder* operation);
2022-09-22 18:26:05 +00:00
private slots:
2022-09-22 18:26:05 +00:00
void saveDone(int type, bool failed);
};
2014-09-02 08:21:17 +00:00
}
#endif