itom
Loading...
Searching...
No Matches
processOrganizer.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2021, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************** */
22
23#pragma once
24
25#include "../../common/sharedStructures.h"
26#include "../global.h"
27
28#include <qhash.h>
29#include <qobject.h>
30#include <qpair.h>
31#include <qprocess.h>
32#include <qsignalmapper.h>
33#include <qstring.h>
34
35namespace ito {
36
37class ProcessOrganizer : public QObject
38{
39 Q_OBJECT
40public:
43
44 inline QMultiHash<QString, QPair<QProcess*, bool>> getProcesses()
45 {
46 return m_processes;
47 }
48
49 QProcess* getFirstExistingProcess(const QString& name);
50 QProcess* getProcess(
51 const QString& name,
52 bool tryToUseExistingProcess,
53 bool& existingProcess,
54 bool closeOnFinalize = false);
55
56 QByteArray getStandardOutputBuffer(const QString& processKey) const
57 {
58 return m_processStdOut[processKey];
59 }
60
61 void clearStandardOutputBuffer(const QString& processKey)
62 {
63 if (m_processStdOut.contains(processKey))
64 {
65 m_processStdOut[processKey].clear();
66 }
67 }
68
69 bool bringWindowsOnTop(const QString& windowName);
70
71 static QString getAbsQtToolPath(const QString& binaryName, bool* found = NULL);
72
73protected:
74 RetVal collectGarbage(bool forceToCloseAll = false);
75
76private:
77 // keyName (assistant, designer...) -> (Process-Pointer, boolean deciding
78 // whether application should be closed on shutdown of itom or not)
79 QMultiHash<QString, QPair<QProcess*, bool>> m_processes;
80 QMap<QString, QByteArray> m_processStdOut;
81
82
83public slots:
84 void processFinished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/);
85 void processError(QProcess::ProcessError /*error*/);
87};
88
89} // end namespace ito
Definition processOrganizer.h:38
void processFinished(int, QProcess::ExitStatus)
shortdesc
Definition processOrganizer.cpp:328
QProcess * getFirstExistingProcess(const QString &name)
shortdesc
Definition processOrganizer.cpp:263
RetVal collectGarbage(bool forceToCloseAll=false)
shortdesc
Definition processOrganizer.cpp:234
QProcess * getProcess(const QString &name, bool tryToUseExistingProcess, bool &existingProcess, bool closeOnFinalize=false)
shortdesc
Definition processOrganizer.cpp:284
void readyReadStandardOutput()
shortdesc
Definition processOrganizer.cpp:351
static QString getAbsQtToolPath(const QString &binaryName, bool *found=NULL)
shortdesc
Definition processOrganizer.cpp:127
bool bringWindowsOnTop(const QString &windowName)
shortdesc
Definition processOrganizer.cpp:385
void processError(QProcess::ProcessError)
shortdesc
Definition processOrganizer.cpp:340
Class for managing status values (like errors or warning)
Definition retVal.h:54
Definition apiFunctionsGraph.cpp:40