YourDefrag  SVN
cmd/src/YDWorkThread.h
Go to the documentation of this file.
00001 
00009 #ifndef YDWORKTHREAD_H
00010 #define YDWORKTHREAD_H
00011 
00012 #include <QString>
00013 #include <QThread>
00014 #include <QWaitCondition>
00015 #include <QList>
00016 #include <QStringList>
00017 #include <QTextStream>
00018 
00019 #include "YDConfigFile.h"
00020 
00021 #include <windows.h>
00022 #include <stdio.h>
00023 #include "JkDefragLib.h"
00024 
00025 #define YD_MODE_MIN             0
00026 #define YD_MODE_MAX             10
00027 #define YD_MODE_DEFAULT         2
00028 #define YD_MODE_INVALID         -1
00029 
00030 #define YD_SPEED_MIN            1
00031 #define YD_SPEED_MAX            100
00032 #define YD_SPEED_DEFAULT        100
00033 #define YD_SPEED_INVALID        -1
00034 
00035 #define YD_FREESPACE_MIN        1
00036 #define YD_FREESPACE_MAX        100
00037 #define YD_FREESPACE_DEFAULT    1
00038 #define YD_FREESPACE_INVALID    -1
00039 
00040 #define YD_STARTFLAG_DEFAULT    true
00041 
00042 class YDWorkThread: public QThread {
00043 
00044         Q_OBJECT
00045 
00046 public:
00047         YDWorkThread(QString name, QObject *parent = NULL);
00048         ~YDWorkThread();
00049 
00050         QString diskState() const { return m_diskState; }
00051         QString diskName() const { return m_configFile.m_diskName; }
00052 
00053         void setExcludes(QStringList _list) { m_configFile.m_excludes = _list; }
00054         QStringList excludes() const { return m_configFile.m_excludes; }
00055         static QStringList defaultExcludes();
00056 
00057         void setSpaceHogs(QStringList _list) { m_configFile.m_spaceHogs = _list; }
00058         QStringList spaceHogs() const { return m_configFile.m_spaceHogs; }
00059         static QStringList defaultSpaceHogs();
00060 
00061         void setVerbose(int verbose) { m_verbose = verbose; }
00062         int verbose() const { return m_verbose; }
00063 
00064         void setMode(int mode) { m_configFile.m_mode = mode; }
00065         int mode() const { return m_configFile.m_mode; }
00066 
00067         void setSpeed(int speed) { m_configFile.m_speed = speed; }
00068         int speed() const { return m_configFile.m_speed; }
00069 
00070         void setFreeSpace(int freeSpace) { m_configFile.m_freeSpace = freeSpace; }
00071         int freeSpace() const { return m_configFile.m_freeSpace; }
00072 
00073         void setStartFlag(int startFlag) { m_configFile.m_startFlag = startFlag; }
00074         int startFlag() const { return m_configFile.m_startFlag; }
00075 
00076         void setLogStream(QTextStream *logStream) { m_logStream = logStream; }
00077         QTextStream *logStream() const { return m_logStream; }
00078 
00079         bool loadConfig(QString fileName = QString::null) { return m_configFile.load(fileName); }
00080         bool saveConfig(QString fileName = QString::null, bool hidden = true) { return m_configFile.save(fileName, hidden); }
00081 
00082 public slots:
00083         void stop();
00084 
00085 signals:
00086         void finished(QThread *thread);
00087 
00088 protected:
00089         QString m_diskState;
00090         YDConfigFile m_configFile;
00091         int m_running;
00092         int m_redrawScreen;
00093         int m_verbose;
00094         QTextStream *m_logStream;
00095         
00096         void run();
00097 
00098 private:
00099         virtual void showStatus(struct DefragDataStruct *data);
00100         virtual void showMove(struct ItemStruct *item, ULONG64 clusters, ULONG64 fromLcn, ULONG64 toLcn, ULONG64 fromVcn);
00101         virtual void showAnalyze(struct DefragDataStruct *data, struct ItemStruct *item);
00102         virtual void showDebug(int level, struct ItemStruct *item, WCHAR *message, va_list varArgs);
00103         virtual void drawCluster(struct DefragDataStruct *data, ULONG64 clusterStart, ULONG64 clusterEnd, int color);
00104         virtual void clearScreen(WCHAR *format, va_list varArgs);
00105 
00106         friend void __cdecl YDShowStatus(struct DefragDataStruct *data);
00107         friend void __cdecl YDShowMove(struct ItemStruct *item, ULONG64 clusters, ULONG64 fromLcn, ULONG64 toLcn, ULONG64 fromVcn);
00108         friend void __cdecl YDShowAnalyze(struct DefragDataStruct *data, struct ItemStruct *item);
00109         friend void __cdecl YDShowDebug(int level, struct ItemStruct *item, WCHAR *message, ...);
00110         friend void __cdecl YDDrawCluster(struct DefragDataStruct *data, ULONG64 clusterStart, ULONG64 clusterEnd, int color);
00111         friend void __cdecl YDClearScreen(WCHAR *format, ...);
00112 };
00113 
00114 typedef QList<YDWorkThread*> YDWorkThreadList;
00115 
00116 #endif/*YDWORKTHREAD_H*/
00117         
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines