blob: 6e88521a7dc5630e7dca889f9ac66379579b2ce3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#ifndef MACONDO_BACKEND_H
#define MACONDO_BACKEND_H
#include <QProcess>
namespace Quackle {
class Game;
class Move;
}
class QTimer;
class MacondoBackend: public QObject {
Q_OBJECT
public:
struct InitOptions {
inline InitOptions(std::string execPath) {
this->execPath = execPath;
}
std::string execPath;
};
MacondoBackend(Quackle::Game *game, const InitOptions &);
struct SimulateOptions {
inline SimulateOptions() {}
};
void simulate(const SimulateOptions &);
~MacondoBackend();
std::string getSimResults();
signals:
void gotSimMoves(const std::vector<Quackle::Move> &moves);
protected slots:
void processStarted();
void processFinished(int, QProcess::ExitStatus);
void timer();
private:
enum class Command {
None,
Simulate,
Solve,
};
void loadGCG();
void killProcess();
void removeTempGCG();
std::string m_execPath;
std::string m_tempGCG;
QProcess *m_process = nullptr;
QTimer *m_updateTimer = nullptr;
bool m_runningSimulation = false;
Quackle::Game *m_game;
QByteArray m_processOutput;
Command m_command = Command::None;
};
#endif
|