67 lines
1.4 KiB
C++
67 lines
1.4 KiB
C++
#ifndef WORKERFACTORY_H
|
||
#define WORKERFACTORY_H
|
||
|
||
#include <QObject>
|
||
#include "../common/mydefine.h"
|
||
#include "../common/reflect.h"
|
||
|
||
/**
|
||
* @brief 备份还原相关任务处理类基类
|
||
*/
|
||
class Worker : public QObject
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
explicit Worker();
|
||
virtual ~Worker();
|
||
|
||
signals:
|
||
// 检测结果信号
|
||
void checkResult(int result);
|
||
// 工作结果信号
|
||
void workResult(bool result);
|
||
|
||
public slots:
|
||
// 环境检测
|
||
void checkEnv();
|
||
|
||
// 任务处理
|
||
void doWork();
|
||
|
||
// 任务取消
|
||
void cancel();
|
||
|
||
protected:
|
||
// 环境检测,个性化部分派生类去实现
|
||
virtual void checkEnvEx();
|
||
|
||
// 任务处理,个性化部分派生类去实现
|
||
virtual void doWorkEx();
|
||
|
||
// 任务取消,个性化部分派生类去实现
|
||
virtual void cancelEx();
|
||
|
||
public:
|
||
void setParam(const BackupWrapper& backupWrapper) { m_backupWrapper = backupWrapper; }
|
||
|
||
protected:
|
||
BackupWrapper m_backupWrapper;
|
||
};
|
||
|
||
/**
|
||
* @brief 备份还原相关任务工厂类
|
||
*/
|
||
class WorkerFactory
|
||
{
|
||
public:
|
||
/**
|
||
* @brief 根据操作类型和位置创建相应的处理类
|
||
* @param type 操作类型,如:系统备份, 系统还原
|
||
* @param position 本地备份还是U盘备份: 0-本地备份;1-移动设备备份
|
||
* @return Worker派生类对象指针,需调用者释放此对象
|
||
*/
|
||
static Worker * createWorker(int type, int position);
|
||
};
|
||
|
||
#endif // WORKERFACTORY_H
|