Fraxinus  22.04-rc5
An IGT application
cxTimedAlgorithm.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 CXTIMEDALGORITHM_H_
13 #define CXTIMEDALGORITHM_H_
14 
15 #include "cxResourceExport.h"
16 
17 //#include <QtWidgets>
18 
19 
20 #include <QObject>
21 #include <QDateTime>
22 #include <QTimer>
23 #include <boost/function.hpp>
24 #include <vector>
25 #include <iostream>
26 #include "boost/shared_ptr.hpp"
27 
28 namespace cx
29 {
30 
31 
32 
40 class cxResource_EXPORT TimedBaseAlgorithm : public QObject
41 {
42  Q_OBJECT
43 
44 public:
45  TimedBaseAlgorithm(QString product, int secondsBetweenAnnounce);
46  virtual ~TimedBaseAlgorithm();
47 
48  virtual QString getProduct() const { return mProduct; }
55  virtual void execute() = 0;
59  virtual bool isFinished() const = 0;
64  virtual bool isRunning() const = 0;
65 
66 signals:
67  void aboutToStart();
68  void started(int maxSteps);
69  void finished();
70  void productChanged();
71 // void progress();
72 
73 protected:
74  void startTiming();
75  void stopTiming();
77 
78  QString getSecondsPassedAsString() const;
79 
80 protected slots:
81  virtual void finishedSlot() {}
82  virtual void postProcessingSlot() {}
83 
84 private slots:
85  void timeoutSlot();
86 
87 private:
88  QTime getTimePassed();
89 
90  QTimer* mTimer;
91  QDateTime mStartTime;
92  QString mProduct;
93 };
94 typedef boost::shared_ptr<TimedBaseAlgorithm> TimedAlgorithmPtr;
95 
96 }//namespace
97 
98 #endif /* CXTIMEDALGORITHM_H_ */
Base class for algorithms that wants to time their execution.
virtual void finishedSlot()
boost::shared_ptr< class TimedBaseAlgorithm > TimedAlgorithmPtr
virtual QString getProduct() const
virtual void postProcessingSlot()
Namespace for all CustusX production code.