SpikeStream Application Library
0.2
|
00001 #ifndef ANALYSISRUNNER_H 00002 #define ANALYSISRUNNER_H 00003 00004 //SpikeStream includes 00005 #include "AbstractAnalysisTimeStepThread.h" 00006 #include "DBInfo.h" 00007 00008 //Qt includes 00009 #include <QHash> 00010 #include <QString> 00011 #include <QThread> 00012 #include <QMutex> 00013 00014 namespace spikestream { 00015 00017 class AnalysisRunner : public QThread { 00018 Q_OBJECT 00019 00020 public: 00021 AnalysisRunner(const DBInfo& netDBInfo, const DBInfo& archDBInfo, const DBInfo& anaDBInfo); 00022 ~AnalysisRunner(); 00023 QString getErrorMessage() { return errorMessage; } 00024 bool isError() { return error; } 00025 void prepareAnalysisTask(const AnalysisInfo& anaInfo, int firstTimeStep, int lastTimeStep); 00026 void reset(); 00027 void run(); 00028 void setError(const QString& message); 00029 void setTimeStepThreadCreationFunction(AbstractAnalysisTimeStepThread* (*createAnalysisTimeStepThread)(const DBInfo& netDBInfo, const DBInfo& archDBInfo, const DBInfo& anaDBInfo)); 00030 void stop(); 00031 00032 signals: 00033 void newResultsFound(); 00034 void progress(const QString& msg, unsigned int timeStep, unsigned int stepsCompleted, unsigned int totalSteps); 00035 void timeStepComplete(unsigned int timeStep); 00036 00037 private slots: 00038 void threadFinished(); 00039 void updateResults(); 00040 void updateProgress(const QString& msg, unsigned int timeStep, unsigned int stepsCompleted, unsigned int totalSteps); 00041 00042 private: 00043 //======================== VARAIBLES ========================= 00045 AnalysisInfo analysisInfo; 00046 00048 DBInfo networkDBInfo; 00049 00051 DBInfo archiveDBInfo; 00052 00054 DBInfo analysisDBInfo; 00055 00057 bool error; 00058 00060 QString errorMessage; 00061 00063 int firstTimeStep; 00064 00066 int lastTimeStep; 00067 00069 int nextTimeStep; 00070 00072 QHash<int, AbstractAnalysisTimeStepThread*> subThreadMap; 00073 00076 QMutex mutex; 00077 00079 bool stopThread; 00080 00082 AbstractAnalysisTimeStepThread* (*createAnalysisTimeStepThread)(const DBInfo& netDBInfo, const DBInfo& archDBInfo, const DBInfo& anaDBInfo); 00083 00084 00085 //========================= METHODS =========================== 00086 void clearError(); 00087 int getNextTimeStep(); 00088 void startAnalysisTimeStepThread(int timeStep); 00089 bool subThreadsRunning(); 00090 }; 00091 00092 } 00093 00094 #endif//ANALYSISRUNNER_H 00095