Fraxinus  18.10
An IGT application
cxProcessWrapper.h
Go to the documentation of this file.
1  /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXPROCESSWRAPPER_H_
13 #define CXPROCESSWRAPPER_H_
14 
15 #include "cxResourceExport.h"
16 
17 #include <QObject>
18 #include "boost/shared_ptr.hpp"
19 #include <QStringList>
20 #include <QString>
21 #include <QProcess>
22 #include <QPointer>
23 #include "cxProcessReporter.h"
24 
25 namespace cx
26 {
27 
34 typedef boost::shared_ptr<class ProcessWrapper> ProcessWrapperPtr;
35 
43 class cxResource_EXPORT ProcessWrapper : public QObject
44 {
45  Q_OBJECT
46 public:
47  explicit ProcessWrapper(QString name = "executable", QObject* parent = NULL);
48  virtual ~ProcessWrapper();
49 
50  QProcess *getProcess();
51 
52  void launchWithRelativePath(QString executable, QStringList arguments = QStringList());
53  void launch(QString executable, QStringList argument = QStringList());
54 
55  bool isRunning();
56 
57  qint64 write(const char * data);
58  bool waitForStarted(int msecs = 30000);
59  bool waitForFinished(int msecs = 30000);
60 
61 signals:
62  void stateChanged();
63 
64 private:
65  QString getExecutableInBundlesAbsolutePath(QString exeInBundle);
66  void internalLaunch(QString executable, QStringList arguments);
67 
68  QPointer<QProcess> mProcess;
69  ProcessReporterPtr mReporter;
70  QString mName;
71  QString mLastExecutablePath; //the path to the last executable that was launched
72 };
73 }
74 
75 #endif /* CXPROCESSWRAPPER_H_ */
boost::shared_ptr< class ProcessWrapper > ProcessWrapperPtr
Definition: cxMainWindow.h:41
boost::shared_ptr< class ProcessReporter > ProcessReporterPtr
Namespace for all CustusX production code.