itom  4.1.0
processOrganizer.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet 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 #ifndef PROCESSORGANIZER_H
24 #define PROCESSORGANIZER_H
25 
26 #include "../../common/sharedStructures.h"
27 #include "../global.h"
28 
29 #include <qobject.h>
30 #include <qprocess.h>
31 #include <qhash.h>
32 #include <qsignalmapper.h>
33 #include <qstring.h>
34 #include <qpair.h>
35 
36 namespace ito
37 {
38 
39 class ProcessOrganizer : public QObject
40 {
41  Q_OBJECT
42 public:
45 
46  inline QMultiHash< QString, QPair<QProcess*, bool> > getProcesses() { return m_processes; }
47  QProcess* getFirstExistingProcess(const QString &name);
48  QProcess* getProcess(const QString &name, bool tryToUseExistingProcess, bool &existingProcess, bool closeOnFinalize = false);
49 
50  QByteArray getStandardOutputBuffer( const QString &processKey ) const { return m_processStdOut[processKey]; }
51  void clearStandardOutputBuffer( const QString &processKey ) { if(m_processStdOut.contains(processKey)) { m_processStdOut[processKey].clear(); } }
52 
53  bool bringWindowsOnTop(const QString &windowName);
54 
55  static QString getAbsQtToolPath(const QString &binaryName, bool *found = NULL);
56 
57 protected:
58 
59  RetVal collectGarbage(bool forceToCloseAll = false);
60 
61 private:
62  QMultiHash< QString, QPair<QProcess*, bool> > m_processes; //keyName (assistant, designer...) -> (Process-Pointer, boolean deciding whether application should be closed on shutdown of itom or not)
63  QMap< QString, QByteArray > m_processStdOut;
64 
65 
66 public slots:
67  void processFinished ( int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/ );
68  void processError (QProcess::ProcessError /*error*/ );
70 };
71 
72 } //end namespace ito
73 
74 #endif
Class for managing status values (like errors or warning)
Definition: retVal.h:54
Definition: processOrganizer.h:39
QProcess * getProcess(const QString &name, bool tryToUseExistingProcess, bool &existingProcess, bool closeOnFinalize=false)
shortdesc
Definition: processOrganizer.cpp:266
void readyReadStandardOutput()
shortdesc
Definition: processOrganizer.cpp:323
RetVal collectGarbage(bool forceToCloseAll=false)
shortdesc
Definition: processOrganizer.cpp:217
Definition: apiFunctionsGraph.cpp:39
QProcess * getFirstExistingProcess(const QString &name)
shortdesc
Definition: processOrganizer.cpp:246
static QString getAbsQtToolPath(const QString &binaryName, bool *found=NULL)
shortdesc
Definition: processOrganizer.cpp:113
void processError(QProcess::ProcessError)
shortdesc
Definition: processOrganizer.cpp:312
bool bringWindowsOnTop(const QString &windowName)
shortdesc
Definition: processOrganizer.cpp:357
void processFinished(int, QProcess::ExitStatus)
shortdesc
Definition: processOrganizer.cpp:300