itom 1.4.0
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2013, Institut für Technische Optik (ITO), 00005 Universität Stuttgart, Germany 00006 00007 This file is part of itom. 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 itom is distributed in the hope that it will be useful, but 00015 WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00017 General Public Licence for more details. 00018 00019 You should have received a copy of the GNU Library General Public License 00020 along with itom. If not, see <http://www.gnu.org/licenses/>. 00021 *********************************************************************** */ 00022 00023 #ifndef PROCESSORGANIZER_H 00024 #define PROCESSORGANIZER_H 00025 00026 #include "../../common/sharedStructures.h" 00027 #include "../global.h" 00028 00029 #include <qobject.h> 00030 #include <qprocess.h> 00031 #include <qhash.h> 00032 #include <qsignalmapper.h> 00033 #include <qstring.h> 00034 #include <qpair.h> 00035 00036 namespace ito 00037 { 00038 00039 class ProcessOrganizer : public QObject 00040 { 00041 Q_OBJECT 00042 public: 00043 ProcessOrganizer(); 00044 ~ProcessOrganizer(); 00045 00046 inline QMultiHash< QString, QPair<QProcess*, bool> > getProcesses() { return m_processes; } 00047 QProcess* getFirstExistingProcess(const QString &name); 00048 QProcess* getProcess(const QString &name, bool tryToUseExistingProcess, bool &existingProcess, bool closeOnFinalize = false); 00049 00050 QByteArray getStandardOutputBuffer( const QString &processKey ) const { return m_processStdOut[processKey]; } 00051 void clearStandardOutputBuffer( const QString &processKey ) { if(m_processStdOut.contains(processKey)) { m_processStdOut[processKey].clear(); } } 00052 00053 bool bringWindowsOnTop(const QString &windowName); 00054 00055 static QString getAbsQtToolPath(const QString &binaryName); 00056 00057 protected: 00058 00059 RetVal collectGarbage(bool forceToCloseAll = false); 00060 00061 private: 00062 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) 00063 QMap< QString, QByteArray > m_processStdOut; 00064 00065 00066 public slots: 00067 void processFinished ( int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/ ); 00068 void processError (QProcess::ProcessError /*error*/ ); 00069 void readyReadStandardOutput(); 00070 }; 00071 00072 } //end namespace ito 00073 00074 #endif