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

71 lines
1.6 KiB
C
Raw Normal View History

2021-08-06 10:20:03 +08:00
#ifndef WORKERFACTORY_H
#define WORKERFACTORY_H
#include <QObject>
#include "../common/mydefine.h"
#include "../common/reflect.h"
/**
* @brief
*/
class Worker : public QObject
{
Q_OBJECT
public:
2021-08-17 10:07:35 +08:00
explicit Worker();
2021-08-06 10:20:03 +08:00
virtual ~Worker();
signals:
// 检测结果信号
void checkResult(int result);
// 进度百分比
void progress(int currentRate);
2021-08-06 10:20:03 +08:00
// 工作结果信号
void workResult(bool result);
2022-01-18 17:35:26 +08:00
// 任务取消
void cancel();
2021-08-06 10:20:03 +08:00
public slots:
// 环境检测
void checkEnv();
// 任务处理
void doWork();
protected:
// 环境检测,个性化部分派生类去实现
2021-08-24 18:08:18 +08:00
virtual bool checkEnvEx();
2021-08-06 10:20:03 +08:00
// 任务处理,个性化部分派生类去实现
virtual void doWorkEx();
// 任务取消,个性化部分派生类去实现
virtual void cancelEx();
public:
void setParam(const BackupWrapper& backupWrapper) { m_backupWrapper = backupWrapper; }
2021-11-15 13:36:00 +08:00
public:
// 同一时间只能运行一个备份/还原等操作
2021-08-06 10:20:03 +08:00
BackupWrapper m_backupWrapper;
2022-01-18 17:35:26 +08:00
// 是否取消操作
bool m_bCancel;
2021-08-06 10:20:03 +08:00
};
/**
* @brief
*/
class WorkerFactory
{
public:
/**
* @brief
* @param type ,
* @param position U盘备份: 0-1-
* @return Worker派生类对象指针
*/
static Worker * createWorker(int type, int position);
};
#endif // WORKERFACTORY_H