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