-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiTask.h
More file actions
executable file
·52 lines (42 loc) · 1.12 KB
/
iTask.h
File metadata and controls
executable file
·52 lines (42 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef ITASK_H
#define ITASK_H
#include <atomic>
#include <QObject>
enum TaskState
{
Complete,
Active,
Wait
};
enum TaskType
{
NumericRandom
};
class ITask : public QObject
{
Q_OBJECT
public:
explicit ITask(QObject *parent = nullptr) : QObject(parent), taskId(++countTasks) {}
virtual ~ITask() = default;
std::atomic<bool> flagDelete = false;
virtual void take(int workerId) = 0;
virtual void executeStep() = 0;
virtual void deleteTask() = 0;
virtual bool isCompleted() const = 0;
virtual int getProgress() const = 0;
virtual int getId() const { return taskId; }
virtual std::string getWorkerId() { return workerId == 0 ? "Ошибка" : std::to_string(workerId); }
virtual std::string getStatus() const = 0;
virtual std::string getType() const = 0;
signals:
void progressUpdated(int taskId);
void taskFinished(int taskId);
void taskDelete(int taskId);
void statusChanged();
protected:
virtual void closeTask() = 0;
static std::atomic<int> countTasks;
int taskId;
int workerId = 0;
};
#endif // ITASK_H