##// END OF EJS Templates
Add a name for all thread
perrinel -
r429:06fe7b5c8cc3
parent child
Show More
@@ -1,142 +1,146
1 1 #include "SqpApplication.h"
2 2
3 3 #include <Data/IDataProvider.h>
4 4 #include <DataSource/DataSourceController.h>
5 5 #include <Network/NetworkController.h>
6 6 #include <QThread>
7 7 #include <Time/TimeController.h>
8 8 #include <Variable/Variable.h>
9 9 #include <Variable/VariableController.h>
10 10 #include <Visualization/VisualizationController.h>
11 11
12 12 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
13 13
14 14 class SqpApplication::SqpApplicationPrivate {
15 15 public:
16 16 SqpApplicationPrivate()
17 17 : m_DataSourceController{std::make_unique<DataSourceController>()},
18 18 m_NetworkController{std::make_unique<NetworkController>()},
19 19 m_TimeController{std::make_unique<TimeController>()},
20 20 m_VariableController{std::make_unique<VariableController>()},
21 21 m_VisualizationController{std::make_unique<VisualizationController>()}
22 22 {
23 23 // /////////////////////////////// //
24 24 // Connections between controllers //
25 25 // /////////////////////////////// //
26 26
27 27 // VariableController <-> DataSourceController
28 28 connect(m_DataSourceController.get(),
29 29 SIGNAL(variableCreationRequested(const QString &, const QVariantHash &,
30 30 std::shared_ptr<IDataProvider>)),
31 31 m_VariableController.get(),
32 32 SLOT(createVariable(const QString &, const QVariantHash &,
33 33 std::shared_ptr<IDataProvider>)));
34 34
35 35 // VariableController <-> VisualizationController
36 36 connect(m_VariableController.get(),
37 37 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)),
38 38 m_VisualizationController.get(),
39 39 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection);
40 40
41 41
42 42 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
43 m_DataSourceControllerThread.setObjectName("DataSourceControllerThread");
43 44 m_NetworkController->moveToThread(&m_NetworkControllerThread);
45 m_NetworkControllerThread.setObjectName("NetworkControllerThread");
44 46 m_VariableController->moveToThread(&m_VariableControllerThread);
47 m_VariableControllerThread.setObjectName("VariableControllerThread");
45 48 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
49 m_VisualizationControllerThread.setObjectName("VsualizationControllerThread");
46 50
47 51
48 52 // Additionnal init
49 53 m_VariableController->setTimeController(m_TimeController.get());
50 54 }
51 55
52 56 virtual ~SqpApplicationPrivate()
53 57 {
54 58 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
55 59 m_DataSourceControllerThread.quit();
56 60 m_DataSourceControllerThread.wait();
57 61
58 62 m_NetworkControllerThread.quit();
59 63 m_NetworkControllerThread.wait();
60 64
61 65 m_VariableControllerThread.quit();
62 66 m_VariableControllerThread.wait();
63 67
64 68 m_VisualizationControllerThread.quit();
65 69 m_VisualizationControllerThread.wait();
66 70 }
67 71
68 72 std::unique_ptr<DataSourceController> m_DataSourceController;
69 73 std::unique_ptr<VariableController> m_VariableController;
70 74 std::unique_ptr<TimeController> m_TimeController;
71 75 std::unique_ptr<NetworkController> m_NetworkController;
72 76 std::unique_ptr<VisualizationController> m_VisualizationController;
73 77 QThread m_DataSourceControllerThread;
74 78 QThread m_NetworkControllerThread;
75 79 QThread m_VariableControllerThread;
76 80 QThread m_VisualizationControllerThread;
77 81 };
78 82
79 83
80 84 SqpApplication::SqpApplication(int &argc, char **argv)
81 85 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
82 86 {
83 87 qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread();
84 88
85 89 connect(&impl->m_DataSourceControllerThread, &QThread::started,
86 90 impl->m_DataSourceController.get(), &DataSourceController::initialize);
87 91 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
88 92 impl->m_DataSourceController.get(), &DataSourceController::finalize);
89 93
90 94 connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(),
91 95 &NetworkController::initialize);
92 96 connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(),
93 97 &NetworkController::finalize);
94 98
95 99 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
96 100 &VariableController::initialize);
97 101 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
98 102 &VariableController::finalize);
99 103
100 104 connect(&impl->m_VisualizationControllerThread, &QThread::started,
101 105 impl->m_VisualizationController.get(), &VisualizationController::initialize);
102 106 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
103 107 impl->m_VisualizationController.get(), &VisualizationController::finalize);
104 108
105 109 impl->m_DataSourceControllerThread.start();
106 110 impl->m_NetworkControllerThread.start();
107 111 impl->m_VariableControllerThread.start();
108 112 impl->m_VisualizationControllerThread.start();
109 113 }
110 114
111 115 SqpApplication::~SqpApplication()
112 116 {
113 117 }
114 118
115 119 void SqpApplication::initialize()
116 120 {
117 121 }
118 122
119 123 DataSourceController &SqpApplication::dataSourceController() noexcept
120 124 {
121 125 return *impl->m_DataSourceController;
122 126 }
123 127
124 128 NetworkController &SqpApplication::networkController() noexcept
125 129 {
126 130 return *impl->m_NetworkController;
127 131 }
128 132
129 133 TimeController &SqpApplication::timeController() noexcept
130 134 {
131 135 return *impl->m_TimeController;
132 136 }
133 137
134 138 VariableController &SqpApplication::variableController() noexcept
135 139 {
136 140 return *impl->m_VariableController;
137 141 }
138 142
139 143 VisualizationController &SqpApplication::visualizationController() noexcept
140 144 {
141 145 return *impl->m_VisualizationController;
142 146 }
General Comments 0
You need to be logged in to leave comments. Login now