TreeFrogFramework  1.18
tscheduler.h
Go to the documentation of this file.
1 #ifndef TSCHEDULER_H
2 #define TSCHEDULER_H
3 
4 #include <TGlobal>
5 #include <TDatabaseContextThread>
6 #include <QTimer>
7 
8 
9 class T_CORE_EXPORT TScheduler : public TDatabaseContextThread
10 {
11  Q_OBJECT
12 public:
13  TScheduler(QObject *parent = nullptr);
14  virtual ~TScheduler();
15 
16  void start(int msec);
17  void restart();
18  void stop();
19  int interval() const;
20  bool isSingleShot() const;
21  void setSingleShot(bool singleShot);
22 
23 protected:
24  virtual void job() = 0;
25  void rollbackTransaction();
26  void publish(const QString &topic, const QString &text);
27  void publish(const QString &topic, const QByteArray &binary);
28 
29 private slots:
30  void start(Priority priority = InheritPriority);
31 
32 signals:
33  void startTimer(int msec);
34  void startTimer();
35  void stopTimer();
36 
37 private:
38  void run() override;
39 
40  QTimer *timer {nullptr};
41  bool rollback {false};
42 
45 };
46 
47 #endif // TSCHEDULER_H
#define T_CORE_EXPORT
Definition: tglobal.h:81
#define T_DISABLE_COPY(Class)
Definition: tglobal.h:137
#define T_DISABLE_MOVE(Class)
Definition: tglobal.h:141
The TScheduler class provides functionality for job scheduler.
Definition: tscheduler.h:9