#pragma once

#include <QObject>
#include <QVariant>
#include <QThread>
#include <QVector>

#include "snake_geometry.h"
#include "snake.h"

using namespace snake;
using namespace snake_geometry;
using namespace std;


typedef QList<QVariant> QVariantList;

typedef struct Result{
    QVariantList            waypoints;
    QVector<unsigned long>  arrivalPathIdx;
    QVector<unsigned long>  returnPathIdx;
    bool                    success;
    QString                 errorMessage;
}WorkerResult_t;

class SnakeWorker : public QThread{
    Q_OBJECT

public:
    SnakeWorker(QObject *parent = nullptr);
    ~SnakeWorker() override;

    void setScenario            (const Scenario  &scenario);
    void setProgress            (const QVector<int> &progress);
    void setLineDistance        (double lineDistance);
    void setMinTransectLength   (double minTransectLength);

    const WorkerResult_t &getResult() const;

protected:
    void run() override;

private:
    Scenario        _scenario;
    vector<int8_t>  _progress;
    double          _lineDistance;
    double          _minTransectLength;
    WorkerResult_t  _result;
};

