NorMIT-nav  2023.01.05-dev+develop.0da12
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  bool 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  void turnOffReporting();
61 
62 signals:
63  void stateChanged();
64 
65 private:
66  QString getExecutableInBundlesAbsolutePath(QString exeInBundle);
67  bool internalLaunch(QString executable, QStringList arguments);
68 
69  QPointer<QProcess> mProcess;
70  ProcessReporterPtr mReporter;
71  QString mName;
72  QString mLastExecutablePath; //the path to the last executable that was launched
73 };
74 }
75 
76 #endif /* CXPROCESSWRAPPER_H_ */
cx::ProcessWrapper
Definition: cxProcessWrapper.h:43
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::ProcessReporterPtr
boost::shared_ptr< class ProcessReporter > ProcessReporterPtr
Definition: cxProcessReporter.h:24
cx::ProcessWrapperPtr
boost::shared_ptr< class ProcessWrapper > ProcessWrapperPtr
Definition: cxMainWindow.h:41
cxProcessReporter.h