00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #ifndef QVWORKER_H
00026 #define QVWORKER_H
00027
00028 #include <QApplication>
00029 #include <QStringList>
00030 #include <QMap>
00031 #include <QSet>
00032 #include <QThread>
00033 #include <QTimer>
00034
00035 #include <qvcore/qvimage.h>
00036 #include <qvcore/qvcamera.h>
00037 #include <qvutils/cpustat.h>
00038 #include <qvcore/qvpropertyholder.h>
00039
00041 class QVWorker: public QThread, public QVPropertyHolder
00042 {
00043 Q_OBJECT
00044
00045 public:
00046 typedef enum
00047 {
00048 Running,
00049 RunningOneStep,
00050 Paused,
00051 Finished
00052 } TWorkerStatus;
00053
00054 CpuStat cpuStat;
00055
00056 QVWorker(QString name = QString());
00057
00058 ~QVWorker();
00059
00063 virtual void worker() = 0;
00064
00065 bool isFinished() const { return status == Finished; }
00066 int getIteration() const { return numIterations; }
00067 TWorkerStatus getStatus() const { return status; }
00068 const QString getErrorStatusString() const { return errorStatus; }
00069
00070
00071
00072
00073 public slots:
00074 void iterate();
00075 void pause() { qDebug() << "QVWorker::pause()"; status = Paused; emit statusUpdate(status); }
00076 void unPause() { qDebug() << "QVWorker::unPause()"; status = Running; emit statusUpdate(status); }
00077 void step() { qDebug() << "QVWorker::step()"; status = RunningOneStep; emit statusUpdate(status); }
00078 void finish() { qDebug() << "QVWorker::finish()"; status = Finished; emit statusUpdate(status); }
00079
00080
00081
00082 signals:
00083
00084
00085
00086 void startIteration();
00087 void endIteration();
00088
00089 void statusUpdate(QVWorker::TWorkerStatus);
00090
00091
00092
00093
00094
00095
00096 protected:
00097 int numIterations;
00098 TWorkerStatus status;
00099 bool inited;
00100 QMap<QString, bool> initedParam;
00101 QString errorStatus;
00102 QSet<QVCamera *> cameras;
00103
00104 void run();
00105
00106 void setErrorStatusString(const QString string) { errorStatus = string; }
00107
00108 void timeFlag(const QString flag)
00109 {
00110 qDebug() << "QVWorker::timeFlag("<< flag <<")";
00111 cpuStat.setFlag(flag);
00112 }
00113
00114
00115
00116
00117
00118
00119
00120 };
00122 #endif