54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
#ifndef WORKER_H
|
|
#define WORKER_H
|
|
|
|
#pragma once
|
|
#include <QObject>
|
|
#include <QProcess>
|
|
#include <QStringList>
|
|
#include <QDebug>
|
|
#include "IProcessMonitor.h"
|
|
|
|
class IPCControllerFactory;
|
|
class IPCController;
|
|
class Worker : public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
Worker(const QString& program, const QStringList& arguments, IProccessMonitor * monitor, QObject* parent = nullptr);
|
|
|
|
~Worker() override {
|
|
qDebug() << "Worker destroyed";
|
|
}
|
|
|
|
void start();
|
|
|
|
void stop();
|
|
|
|
bool isRunning() const {
|
|
return process->state() != QProcess::NotRunning;
|
|
}
|
|
IProccessMonitor *getMonitor() const {return monitor; }
|
|
|
|
signals:
|
|
void finished();
|
|
|
|
private slots:
|
|
void onProcessFinished(int, QProcess::ExitStatus);
|
|
void readyReadStandardOutput();
|
|
|
|
void readyReadStandardError();
|
|
private:
|
|
IProccessMonitor *monitor = 0;
|
|
QProcess* process;
|
|
QString program;
|
|
QStringList arguments;
|
|
IPCControllerFactory * factory = 0;
|
|
QString masterMemory = "MasterMemory";
|
|
QString slaveMemory = "SlaveMemory";
|
|
IPCController* slaveCtrl = 0;
|
|
bool isLogStandartOutput = false;
|
|
QString msg;
|
|
bool isStarted=false;
|
|
};
|
|
|
|
#endif // WORKER_H
|