CCIMXDesktop
 
Loading...
Searching...
No Matches
timerhandleserver.h
1#ifndef TIMERHANDLESERVER_H
2#define TIMERHANDLESERVER_H
3#include "TimeServerType.h"
4#include <QObject>
5#include <QTimer>
6class TimerHandleServer : public QObject {
7 Q_OBJECT
8public:
9 explicit TimerHandleServer(
10 const QString& name,
11 const ServerRunner& runner,
12 const int timer_interval,
13 QObject* parent = nullptr
14 );
15 explicit TimerHandleServer(QString&& name,
16 ServerRunner&& runner,
17 const int timer_interval,
18 QObject* parent = nullptr);
19
20 Q_DISABLE_COPY(TimerHandleServer);
22 // self deleted will be set if given true
29 void setAsRunOnce(bool ifSelfDeleted = true);
34 void resetServer();
35 const TimerServerProperty serverProperty() const noexcept;
40 void setState(bool should_run);
41
47 void adjust_timer_interval(const int new_interval, bool request_immediate = true);
48
49 void quit_self();
50
55 void restart_timer();
56
57 inline const ServerID id() const noexcept{
58 return timer_server_id;
59 }
60
61 inline const QString server_name() const noexcept {
62 return name;
63 }
64
65signals:
66 void server_status_changed(bool st);
67 void timer_alert();
68 void server_shutdown();
69 void server_finished();
70 void server_ready_destroyed();
71
72private:
73 const ServerID timer_server_id;
74 QString name;
75 ServerRunner runner;
76 QTimer runny_timer;
77 bool isSelfDeleted{false};
78
79private:
80 void run_raw_hook();
81 void run_cleanup();
82};
83
84#endif // TIMERHANDLESERVER_H
Definition timerhandleserver.h:6
void setAsRunOnce(bool ifSelfDeleted=true)
setAsRunOnce set the timer handle sever running once only
Definition timerhandleserver.cpp:44
void adjust_timer_interval(const int new_interval, bool request_immediate=true)
adjust_timer_interval
Definition timerhandleserver.cpp:87
void resetServer()
resetServer reset the server to the plain type
Definition timerhandleserver.cpp:56
void setState(bool should_run)
setState
Definition timerhandleserver.cpp:75
void restart_timer()
restart_timer will reset the count of timer to the cnt 0, which can be using in time resets
Definition timerhandleserver.cpp:105
Definition TimeServerType.h:13