Changeset View
Changeset View
Standalone View
Standalone View
src/part/loadagraphthread.h
Show All 19 Lines | |||||
20 | #ifndef LOADAGRAPHTHREAD_H | 20 | #ifndef LOADAGRAPHTHREAD_H | ||
21 | #define LOADAGRAPHTHREAD_H | 21 | #define LOADAGRAPHTHREAD_H | ||
22 | 22 | | |||
23 | #include <QSemaphore> | 23 | #include <QSemaphore> | ||
24 | #include <QThread> | 24 | #include <QThread> | ||
25 | 25 | | |||
26 | #include <graphviz/gvc.h> | 26 | #include <graphviz/gvc.h> | ||
27 | 27 | | |||
28 | | ||||
29 | class LoadAGraphThread : public QThread | 28 | class LoadAGraphThread : public QThread | ||
30 | { | 29 | { | ||
31 | Q_OBJECT | 30 | Q_OBJECT | ||
32 | public: | 31 | public: | ||
33 | LoadAGraphThread() : sem(1) {} | 32 | LoadAGraphThread() | ||
33 | : sem(1) | ||||
34 | { | ||||
35 | } | ||||
34 | void loadFile(const QString& dotFileName); | 36 | void loadFile(const QString &dotFileName); | ||
35 | inline graph_t* g() {return m_g;} | 37 | inline graph_t *g() | ||
36 | inline const QString& dotFileName() {return m_dotFileName;} | 38 | { | ||
37 | void processed_finished() { sem.release(); } | 39 | return m_g; | ||
40 | } | ||||
41 | inline const QString &dotFileName() | ||||
42 | { | ||||
43 | return m_dotFileName; | ||||
44 | } | ||||
45 | void processed_finished() | ||||
46 | { | ||||
47 | sem.release(); | ||||
48 | } | ||||
38 | 49 | | |||
39 | // helper method only for DotGraphView::loadLibrarySync() | 50 | // helper method only for DotGraphView::loadLibrarySync() | ||
40 | // see notes next to the call there | 51 | // see notes next to the call there | ||
41 | void setDotFileName(const QString& dotFileName) { m_dotFileName = dotFileName; } | 52 | void setDotFileName(const QString &dotFileName) | ||
53 | { | ||||
54 | m_dotFileName = dotFileName; | ||||
55 | } | ||||
42 | 56 | | |||
43 | protected: | 57 | protected: | ||
44 | void run() override; | 58 | void run() override; | ||
45 | 59 | | |||
46 | private: | 60 | private: | ||
47 | QSemaphore sem; | 61 | QSemaphore sem; | ||
48 | QString m_dotFileName; | 62 | QString m_dotFileName; | ||
49 | graph_t *m_g; | 63 | graph_t *m_g; | ||
50 | }; | 64 | }; | ||
51 | 65 | | |||
52 | #endif // LOADAGRAPHTHREAD_H | 66 | #endif // LOADAGRAPHTHREAD_H |