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

67 lines
1.4 KiB
C++
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 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