h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

adapter.h (981B)


      1 #ifndef ADAPTER_H
      2 #define ADAPTER_H
      3 
      4 #include "../cpp/nissy.h"
      5 
      6 #include <map>
      7 #include <string>
      8 #include <QObject>
      9 #include <QtQmlIntegration>
     10 
     11 struct SolveOptions {
     12 	nissy::cube cube;
     13 	nissy::solver *solver;
     14 	unsigned minmoves;
     15 	unsigned maxmoves;
     16 	unsigned maxsolutions;
     17 	unsigned optimal;
     18 };
     19 
     20 class NissyAdapter : public QObject {
     21 	Q_OBJECT
     22 	QML_SINGLETON
     23 	QML_ELEMENT
     24 	
     25 public:
     26 	static constexpr int maxSolutionsHardLimit = 9999;
     27 
     28 	NissyAdapter();
     29 
     30 	Q_INVOKABLE bool isValidScramble(QString);
     31 	Q_INVOKABLE void requestSolve(
     32 		QString scramble,
     33 		QString solver,
     34 		int minmoves,
     35 		int maxmoves,
     36 		int maxsolutions,
     37 		int optimal
     38 	);
     39 
     40 signals:
     41 	void solutionsReady(QString, QString);
     42 	void solverError(QString);
     43 	void appendLog(QString);
     44 
     45 private:
     46 	std::vector<nissy::solver> solvers;
     47 	std::function<void(std::string)> writeLog;
     48 
     49 	void initSolver(const std::string&);
     50 	void startSolve(SolveOptions);
     51 	bool loadSolverData(nissy::solver&);
     52 	void logLine(std::string);
     53 };
     54 
     55 #endif