32 lines
635 B
C++
32 lines
635 B
C++
#ifndef MACHINECONTROLLER_H
|
|
#define MACHINECONTROLLER_H
|
|
|
|
#include <QObject>
|
|
#include <atomic>
|
|
#include <thread>
|
|
#include <memory>
|
|
|
|
class Machine;
|
|
|
|
class MachineController : public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
explicit MachineController(std::shared_ptr<Machine> machine = nullptr, QObject *parent = nullptr);
|
|
~MachineController() override;
|
|
|
|
void start();
|
|
void stop();
|
|
void step();
|
|
|
|
signals:
|
|
void tick();
|
|
void error(const QString &msg);
|
|
|
|
private:
|
|
void runLoop();
|
|
std::atomic<bool> m_running{false};
|
|
std::thread m_thread;
|
|
std::shared_ptr<Machine> m_machine;
|
|
};
|
|
|
|
#endif // MACHINECONTROLLER_H
|