From 8a6d4b06f2291c363f3dea17837ed20893852453 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Wed, 9 Sep 2015 19:00:56 +0200 Subject: Cleanup repo with some directories --- src/ProcessManager.hpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/ProcessManager.hpp (limited to 'src/ProcessManager.hpp') diff --git a/src/ProcessManager.hpp b/src/ProcessManager.hpp new file mode 100644 index 0000000..7782cb3 --- /dev/null +++ b/src/ProcessManager.hpp @@ -0,0 +1,75 @@ +#ifndef PROCESSMANAGER_HPP +#define PROCESSMANAGER_HPP + +#define DELETE_SAVE(x) if(x != 0) \ +{\ + delete x;\ + x = 0;\ +} + +#include +#include +#include + +class ProcessManager : public QObject +{ + Q_OBJECT +public: + explicit ProcessManager(const QString& prefix, const QString& id = "", bool useStdErr = false, QObject *parent = 0); + ~ProcessManager(); + + bool isOk(); + bool isRunning(); + bool start(const QString& program, QStringList args); + + QByteArray readAll(); + QByteArray readLine(); + qint64 write(const QByteArray& data); + bool isWritable(); + bool setWorkingDirectory(const QString& path); + + void kill(); + void exit(); + + void closeProgFifos(); + + QString ID(); + +signals: + void readyRead(); + void stdErrReadyRead(); + void finished(int); + +public slots: + +private slots: + void ctrlOutReadyRead(); + void _stdOutReadyRead(); + void _stdErrReadyRead(); + +private: + QString prefix; + QString id; + + QFile ctrlIn; + QFile ctrlOut; + QFile stdIn; + QFile stdOut; + QFile stdErr; + + QSocketNotifier* ctrlOutNotifier = 0; + QSocketNotifier* stdOutNotifier = 0; + QSocketNotifier* stdErrNotifier = 0; + + bool useStdErr = false; + + bool ok = false; + bool running = false; + + int pid = 0; + int exitCode = 0; + + bool connectToIO(); +}; + +#endif // PROCESSMANAGER_HPP -- cgit v1.2.3-54-g00ecf