aboutsummaryrefslogtreecommitdiff
path: root/qt/adapter.h
blob: 856cdad8b74c4826ed835d35c272fb77d90c4c13 (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
#ifndef ADAPTER_H
#define ADAPTER_H

#include "../cpp/nissy.h"

#include <map>
#include <string>
#include <QObject>
#include <QtQmlIntegration>

struct SolveOptions {
	nissy::cube cube;
	nissy::solver *solver;
	unsigned minmoves;
	unsigned maxmoves;
	unsigned maxsolutions;
	int optimal;
};

class NissyAdapter : public QObject {
	Q_OBJECT
	QML_SINGLETON
	QML_ELEMENT
	
public:
	NissyAdapter();

	Q_INVOKABLE bool isValidScramble(QString);
	Q_INVOKABLE void requestSolve(
		QString scramble,
		QString solver,
		int minmoves,
		int maxmoves,
		int maxsolutions,
		int optimal
	);

signals:
	void solutionsReady(QString, QString);
	void solverError(QString);
	void appendLog(QString);

private:
	std::vector<nissy::solver> solvers;
	std::function<void(const char*)> writeLog;

	void initSolver(const std::string&);
	void startSolve(SolveOptions);
	bool loadSolverData(nissy::solver&);
};

#endif

Generated with cgit - Back to sebastiano.tronto.net