Heart 1.4.918.d927d9c
Heart is base back end library for your c++ Qt projects.
Loading...
Searching...
No Matches
abstracttask.h
Go to the documentation of this file.
1//#
2//# Copyright (C) 2021-2025 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;
28
29
33class HEARTSHARED_EXPORT AbstractTask
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();
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...
virtual bool isValid() const
isValid This method check task configuration and return true if task is valid else false.
void setMode(ScheduleMode newMode)
setMode This method sets new mode of this task.
virtual bool execute(AbstractNode *node) const =0
execute This method will be invoked when task be executed.
ScheduleMode mode() const
mode This method retunr current mode of this task.
void setTime(quint64 newTime)
setTime This method sets new value for the AbstractTask::time property.
AbstractTask()=default
int taskId() const
taskId This method return id of this task.
quint64 time() const
time This is universal property. This property has its own meaning for each AbstractTask::mode....
virtual ~AbstractTask()=default
TimeValMsec
The TimeVal enum contains all time values for a tasks scheduling.
@ Msec
Milessecundes.
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.