yhkylin-backup-tools/backup-daemon/workerfactory.h

71 lines
1.6 KiB
C++
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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 progress(int currentRate);
// 工作结果信号
void workResult(bool result);
// 任务取消
void cancel();
public slots:
// 环境检测
void checkEnv();
// 任务处理
void doWork();
protected:
// 环境检测,个性化部分派生类去实现
virtual bool checkEnvEx();
// 任务处理,个性化部分派生类去实现
virtual void doWorkEx();
// 任务取消,个性化部分派生类去实现
virtual void cancelEx();
public:
void setParam(const BackupWrapper& backupWrapper) { m_backupWrapper = backupWrapper; }
public:
// 同一时间只能运行一个备份/还原等操作
BackupWrapper m_backupWrapper;
// 是否取消操作
bool m_bCancel;
};
/**
* @brief 备份还原相关任务工厂类
*/
class WorkerFactory
{
public:
/**
* @brief 根据操作类型和位置创建相应的处理类
* @param type 操作类型,如:系统备份, 系统还原
* @param position 本地备份还是U盘备份: 0-本地备份1-移动设备备份
* @return Worker派生类对象指针需调用者释放此对象
*/
static Worker * createWorker(int type, int position);
};
#endif // WORKERFACTORY_H