Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
abstracttask.h
Go to the documentation of this file.
1//#
2//# Copyright (C) 2021-2024 QuasarApp.
3//# Distributed under the lgplv3 software license, see the accompanying
4//# Everyone is permitted to copy and distribute verbatim copies
5//# of this license document, but changing it is not allowed.
6//#
7
8#ifndef ABSTRACTTASK_H
9#define ABSTRACTTASK_H
10
11#include <QSharedPointer>
12#include "heart_global.h"
13
14namespace QH {
15
16class AbstractNode;
20enum class ScheduleMode: int{
24 Repeat,
27};
28
29
34{
35public:
36
40 enum TimeValMsec: qint64 {
42 Msec = 1,
44 Sec = 1000 * Msec,
46 Min = 60 * Sec,
48 Hour = 60 * Min,
50 Day = 24 * Hour
51 };
52
53 AbstractTask() = default;
54 virtual ~AbstractTask() = default;
55
61 ScheduleMode mode() const;
62
68 void setMode(ScheduleMode newMode);
69
77 quint64 time() const;
78
84 void setTime(quint64 newTime);
85
91 virtual bool execute(AbstractNode *node) const = 0;
92
97 int taskId() const;
98
103 virtual bool isValid() const;
104
105private:
106 void idGen();
107 ScheduleMode _mode = ScheduleMode::SingleWork;
108 quint64 _time = 0;
109 int _taskId = 0;
110};
111
112}
113
114Q_DECLARE_METATYPE(QSharedPointer<QH::AbstractTask>)
115
116
117#endif // ABSTRACTTASK_H
The AbstractNode class - Abstract implementation of node. this implementation have a methods for send...
The AbstractTask class. All tasks executed on separate thread.
virtual bool execute(AbstractNode *node) const =0
execute This method will be invoked when task be executed.
AbstractTask()=default
virtual ~AbstractTask()=default
TimeValMsec
The TimeVal enum contains all time values for a tasks scheduling.
#define HEARTSHARED_EXPORT
Q_DECLARE_METATYPE(QH::HostAddress)
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13
ScheduleMode
The ScheduleMode enum contails list of the shedule modes.
@ TimePoint
In this mode AbstractTask will be executed int time msecunds by Unix time.
@ Repeat
In this mode AbstractTask will be executed task every time from the moment of adding this task.
@ SingleWork
In this mode AbstractTask will be executed after time msecunds from the moment of adding this task.