VHISTlib  1.84.0.3018
/daten/ahuesgen/projects/vhist/code/vhistlib/include/unvhistlib/validationqueue.h
00001 /* $HEADERS
00002  $Id: validationqueue.h 2792 2013-05-06 11:25:27Z michael $
00003  */
00004 
00005 #ifndef VALIDATIONQUEUE_INCLUDED
00006 #define VALIDATIONQUEUE_INCLUDED
00007 
00008 #include "../shared/misc_defines.h"
00009 
00010 #include <QObject>
00011 #include <QString>
00012 #include <QQueue>
00013 #include <QFile>
00014 
00015 #include "validator.h"
00016 #include "../shared/stopwatch.h"
00017 #include "../shared/logsource.h"
00018 
00019 namespace vhist
00020 {
00021 
00022 class VhistParser;
00023 struct FileTag;
00024 struct SectionTag;
00025 
00026 enum ValidateeType
00027 {
00028     VALIDATEE_SECTION,
00029     VALIDATEE_FILE,
00030     VALIDATEE_SAVEDFILE
00031 };
00032 
00033 
00034 struct VHIST_EXTERN Validatee
00035 {
00036     ValidateeType type;
00037     int id;
00038     int start;
00039     int numBytes;
00040     int tagPos;
00041     QByteArray replacementTag;
00042     QString md5;
00043     QString cmd5;
00044     QString name; // file- or sectionname
00045 };
00046 
00047 
00048 struct VHIST_EXTERN SavedFile
00049 {
00050     QString filename;
00051     QString md5;
00052     int filesize;
00053 };
00054 
00055 
00067 class VHIST_EXTERN ValidationQueue : public LogSource
00068 {
00069     Q_OBJECT
00070     public: // construction, destruction, assignment
00071         ValidationQueue(VhistParser* parser = NULL, int chunksize = 100000);
00072         virtual ~ValidationQueue();
00073         void reset(VhistParser* parser);
00074         void repopulate(VhistParser* parser);
00075         void addValidatees(QList<int> files, QList<int> sections);
00076         void addValidatees(QList<SavedFile> files);
00077     
00078     public slots:
00079         void cancelValidation();
00080     
00081     public:
00082         bool process();
00083     
00084     signals:
00085         void fileProcessed(int id, bool valid);
00086         void savedFileProcessed(const QString filename, bool valid);
00087         void sectionProcessed(int id, bool valid);
00088         void percentFinishedChanged(int, const QString name);
00089     
00090     private:
00091         void reinit(VhistParser* parser);
00092         void nextEntry();
00093         Validatee validateeFromFile(const FileTag& tag);
00094         Validatee validateeFromSection(const SectionTag& tag);
00095         Validatee validateeFromSavedFile(const SavedFile& file);
00096     
00097     private: // member variables
00098         VhistParser* m_parser;
00099         Validator m_validator;
00100         StopWatch m_stopwatch;
00101         QQueue<Validatee> m_validatees;
00102         // the number of processed bytes of the current validatee
00103         int m_bytesHandled;
00104         // the total number of bytes to handle since the last restart
00105         qint64 m_totalBytes;
00106         // the total number of bytes handled since the last restart
00107         qint64 m_totalHandled;
00108         QFile m_currentFile;
00109         int m_chunksize;
00110 };
00111 
00112 }
00113 
00114 #endif // VALIDATIONQUEUE_INCLUDED
00115 

VHISTlib 1.84.0.3018 of Jun 28 2013, generated by doxygen.