12 #ifndef CXTHREADEDTIMEDALGORITHM_H_
13 #define CXTHREADEDTIMEDALGORITHM_H_
15 #include "cxResourceExport.h"
17 #include <QFutureWatcher>
18 #include <QtConcurrent/QtConcurrentRun>
43 connect(&mWatcher, SIGNAL(finished()),
this, SLOT(finishedSlot()));
44 connect(&mWatcher, SIGNAL(finished()),
this, SLOT(postProcessingSlot()));
45 connect(&mWatcher, SIGNAL(finished()),
this, SIGNAL(finished()));
52 this->preProcessingSlot();
55 virtual bool isFinished()
const {
return mWatcher.isFinished(); }
56 virtual bool isRunning()
const {
return mWatcher.isRunning(); }
60 virtual void preProcessingSlot() {}
61 virtual void postProcessingSlot() = 0;
64 virtual T calculate() = 0;
72 mWatcher.setFuture(mFutureResult);
76 T result = mWatcher.future().result();
86 QFuture<T> mFutureResult;
87 QFutureWatcher<T> mWatcher;
110 virtual void postProcessingSlot();
113 virtual QString calculate();