-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib-main.h
58 lines (44 loc) · 1.19 KB
/
lib-main.h
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
53
54
55
56
57
58
#ifndef LIB_MAIN_H
#define LIB_MAIN_H
#include <QCoreApplication>
#include <QTimer>
#include <functional>
#include <memory>
#include <queue>
#include "lib-common-defs.h"
#include "lib-events.h"
namespace TrkSim {
///////////////////////////////////////////////////////////////////////////////
using HistoryFunc = std::function<void()>;
class LibMain : public QObject {
Q_OBJECT
public:
XnEvents events;
unsigned int api_version = 0x0001;
bool connected = false;
QTimer m_hist_timer;
std::queue<HistoryFunc> hist;
TrkStatus trkStatus = TrkStatus::On;
LibMain();
void log(const QString &msg, LogLevel loglevel) const;
static QString trkStatusToString(TrkStatus);
private slots:
void m_hist_timer_tick();
};
///////////////////////////////////////////////////////////////////////////////
// Dirty magic for Qt's event loop
// This class should be created first
struct AppThread {
AppThread() {
if (QCoreApplication::instance() == nullptr) {
int argc = 0;
QCoreApplication* app = new QCoreApplication(argc, nullptr);
QMetaObject::invokeMethod(qApp, "quit", Qt::QueuedConnection);
app->exec();
}
}
};
extern AppThread main_thread;
extern LibMain lib;
} // namespace TrkSim
#endif