##// END OF EJS Templates
Makes the connection between Variable controller and Visualization controller...
Alexandre Leroux -
r170:a3d07f8af710
parent child
Show More
@@ -1,27 +1,32
1 #ifndef SCIQLOP_VARIABLE_H
1 #ifndef SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
2 #define SCIQLOP_VARIABLE_H
3
3
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5
5
6 #include <QObject>
7
6 class IDataSeries;
8 class IDataSeries;
7 class QString;
9 class QString;
8
10
9 /**
11 /**
10 * @brief The Variable class represents a variable in SciQlop.
12 * @brief The Variable class represents a variable in SciQlop.
11 */
13 */
12 class Variable {
14 class Variable {
13 public:
15 public:
14 explicit Variable(const QString &name, const QString &unit, const QString &mission);
16 explicit Variable(const QString &name, const QString &unit, const QString &mission);
15
17
16 QString name() const noexcept;
18 QString name() const noexcept;
17 QString mission() const noexcept;
19 QString mission() const noexcept;
18 QString unit() const noexcept;
20 QString unit() const noexcept;
19
21
20 void addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept;
22 void addDataSeries(std::unique_ptr<IDataSeries> dataSeries) noexcept;
21
23
22 private:
24 private:
23 class VariablePrivate;
25 class VariablePrivate;
24 spimpl::unique_impl_ptr<VariablePrivate> impl;
26 spimpl::unique_impl_ptr<VariablePrivate> impl;
25 };
27 };
26
28
29 // Required for using shared_ptr in signals/slots
30 Q_DECLARE_METATYPE(std::shared_ptr<Variable>)
31
27 #endif // SCIQLOP_VARIABLE_H
32 #endif // SCIQLOP_VARIABLE_H
@@ -1,39 +1,43
1 #ifndef SCIQLOP_VISUALIZATIONCONTROLLER_H
1 #ifndef SCIQLOP_VISUALIZATIONCONTROLLER_H
2 #define SCIQLOP_VISUALIZATIONCONTROLLER_H
2 #define SCIQLOP_VISUALIZATIONCONTROLLER_H
3
3
4 #include <QLoggingCategory>
4 #include <QLoggingCategory>
5 #include <QObject>
5 #include <QObject>
6 #include <QUuid>
6 #include <QUuid>
7
7
8 #include <Common/spimpl.h>
8 #include <Common/spimpl.h>
9
9
10 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationController)
10 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationController)
11
11
12 class DataSourceItem;
12 class DataSourceItem;
13 class Variable;
13
14
14 /**
15 /**
15 * @brief The VisualizationController class aims to make the link between SciQlop and its plugins.
16 * @brief The VisualizationController class aims to make the link between SciQlop and its plugins.
16 * This is the intermediate class that SciQlop has to use in the way to connect a data source.
17 * This is the intermediate class that SciQlop has to use in the way to connect a data source.
17 * Please first use register method to initialize a plugin specified by its metadata name (JSON
18 * Please first use register method to initialize a plugin specified by its metadata name (JSON
18 * plugin source) then others specifics method will be able to access it. You can load a data source
19 * plugin source) then others specifics method will be able to access it. You can load a data source
19 * driver plugin then create a data source.
20 * driver plugin then create a data source.
20 */
21 */
21 class VisualizationController : public QObject {
22 class VisualizationController : public QObject {
22 Q_OBJECT
23 Q_OBJECT
23 public:
24 public:
24 explicit VisualizationController(QObject *parent = 0);
25 explicit VisualizationController(QObject *parent = 0);
25 virtual ~VisualizationController();
26 virtual ~VisualizationController();
26
27
27 public slots:
28 public slots:
29 /// Slot called when a variable has been created in SciQlop
30 void onVariableCreated(std::shared_ptr<Variable> variable) noexcept;
31
28 /// Manage init/end of the controller
32 /// Manage init/end of the controller
29 void initialize();
33 void initialize();
30 void finalize();
34 void finalize();
31
35
32 private:
36 private:
33 void waitForFinish();
37 void waitForFinish();
34
38
35 class VisualizationControllerPrivate;
39 class VisualizationControllerPrivate;
36 spimpl::unique_impl_ptr<VisualizationControllerPrivate> impl;
40 spimpl::unique_impl_ptr<VisualizationControllerPrivate> impl;
37 };
41 };
38
42
39 #endif // SCIQLOP_VISUALIZATIONCONTROLLER_H
43 #endif // SCIQLOP_VISUALIZATIONCONTROLLER_H
@@ -1,46 +1,54
1 #include <Visualization/VisualizationController.h>
1 #include <Visualization/VisualizationController.h>
2
2
3 #include <Variable/Variable.h>
4
3 #include <QMutex>
5 #include <QMutex>
4 #include <QThread>
6 #include <QThread>
5
7
6 #include <QDir>
8 #include <QDir>
7 #include <QStandardPaths>
9 #include <QStandardPaths>
8
10
9 Q_LOGGING_CATEGORY(LOG_VisualizationController, "VisualizationController")
11 Q_LOGGING_CATEGORY(LOG_VisualizationController, "VisualizationController")
10
12
11 class VisualizationController::VisualizationControllerPrivate {
13 class VisualizationController::VisualizationControllerPrivate {
12 public:
14 public:
13 QMutex m_WorkingMutex;
15 QMutex m_WorkingMutex;
14 };
16 };
15
17
16 VisualizationController::VisualizationController(QObject *parent)
18 VisualizationController::VisualizationController(QObject *parent)
17 : impl{spimpl::make_unique_impl<VisualizationControllerPrivate>()}
19 : impl{spimpl::make_unique_impl<VisualizationControllerPrivate>()}
18 {
20 {
19 qCDebug(LOG_VisualizationController()) << tr("VisualizationController construction")
21 qCDebug(LOG_VisualizationController()) << tr("VisualizationController construction")
20 << QThread::currentThread();
22 << QThread::currentThread();
21 }
23 }
22
24
23 VisualizationController::~VisualizationController()
25 VisualizationController::~VisualizationController()
24 {
26 {
25 qCDebug(LOG_VisualizationController()) << tr("VisualizationController destruction")
27 qCDebug(LOG_VisualizationController()) << tr("VisualizationController destruction")
26 << QThread::currentThread();
28 << QThread::currentThread();
27 this->waitForFinish();
29 this->waitForFinish();
28 }
30 }
29
31
32 void VisualizationController::onVariableCreated(std::shared_ptr<Variable> variable) noexcept
33 {
34 /// @todo ALX : make new graph for the variable
35 qCDebug(LOG_VisualizationController()) << "new variable to display";
36 }
37
30 void VisualizationController::initialize()
38 void VisualizationController::initialize()
31 {
39 {
32 qCDebug(LOG_VisualizationController()) << tr("VisualizationController init")
40 qCDebug(LOG_VisualizationController()) << tr("VisualizationController init")
33 << QThread::currentThread();
41 << QThread::currentThread();
34 impl->m_WorkingMutex.lock();
42 impl->m_WorkingMutex.lock();
35 qCDebug(LOG_VisualizationController()) << tr("VisualizationController init END");
43 qCDebug(LOG_VisualizationController()) << tr("VisualizationController init END");
36 }
44 }
37
45
38 void VisualizationController::finalize()
46 void VisualizationController::finalize()
39 {
47 {
40 impl->m_WorkingMutex.unlock();
48 impl->m_WorkingMutex.unlock();
41 }
49 }
42
50
43 void VisualizationController::waitForFinish()
51 void VisualizationController::waitForFinish()
44 {
52 {
45 QMutexLocker locker{&impl->m_WorkingMutex};
53 QMutexLocker locker{&impl->m_WorkingMutex};
46 }
54 }
@@ -1,103 +1,109
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 <QThread>
5 #include <QThread>
6 #include <Variable/Variable.h>
6 #include <Variable/VariableController.h>
7 #include <Variable/VariableController.h>
7 #include <Visualization/VisualizationController.h>
8 #include <Visualization/VisualizationController.h>
8
9
9 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
10 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
10
11
11 class SqpApplication::SqpApplicationPrivate {
12 class SqpApplication::SqpApplicationPrivate {
12 public:
13 public:
13 SqpApplicationPrivate()
14 SqpApplicationPrivate()
14 : m_DataSourceController{std::make_unique<DataSourceController>()},
15 : m_DataSourceController{std::make_unique<DataSourceController>()},
15 m_VariableController{std::make_unique<VariableController>()},
16 m_VariableController{std::make_unique<VariableController>()},
16 m_VisualizationController{std::make_unique<VisualizationController>()}
17 m_VisualizationController{std::make_unique<VisualizationController>()}
17 {
18 {
18 // /////////////////////////////// //
19 // /////////////////////////////// //
19 // Connections between controllers //
20 // Connections between controllers //
20 // /////////////////////////////// //
21 // /////////////////////////////// //
21
22
22 // VariableController <-> DataSourceController
23 // VariableController <-> DataSourceController
23 qRegisterMetaType<std::shared_ptr<IDataProvider> >();
24 qRegisterMetaType<std::shared_ptr<IDataProvider> >();
24 connect(m_DataSourceController.get(),
25 connect(m_DataSourceController.get(),
25 SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)),
26 SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)),
26 m_VariableController.get(),
27 m_VariableController.get(),
27 SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>)));
28 SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>)));
28
29
30 // VariableController <-> VisualizationController
31 qRegisterMetaType<std::shared_ptr<Variable> >();
32 connect(m_VariableController.get(), SIGNAL(variableCreated(std::shared_ptr<Variable>)),
33 m_VisualizationController.get(),
34 SLOT(onVariableCreated(std::shared_ptr<Variable>)));
35
29 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
36 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
30 m_VariableController->moveToThread(&m_VariableControllerThread);
37 m_VariableController->moveToThread(&m_VariableControllerThread);
31 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
38 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
32 }
39 }
33
40
34 virtual ~SqpApplicationPrivate()
41 virtual ~SqpApplicationPrivate()
35 {
42 {
36 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
43 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
37 m_DataSourceControllerThread.quit();
44 m_DataSourceControllerThread.quit();
38 m_DataSourceControllerThread.wait();
45 m_DataSourceControllerThread.wait();
39
46
40 m_VariableControllerThread.quit();
47 m_VariableControllerThread.quit();
41 m_VariableControllerThread.wait();
48 m_VariableControllerThread.wait();
42
49
43 m_VisualizationControllerThread.quit();
50 m_VisualizationControllerThread.quit();
44 m_VisualizationControllerThread.wait();
51 m_VisualizationControllerThread.wait();
45 }
52 }
46
53
47 std::unique_ptr<DataSourceController> m_DataSourceController;
54 std::unique_ptr<DataSourceController> m_DataSourceController;
48 std::unique_ptr<VariableController> m_VariableController;
55 std::unique_ptr<VariableController> m_VariableController;
49 std::unique_ptr<VisualizationController> m_VisualizationController;
56 std::unique_ptr<VisualizationController> m_VisualizationController;
50 QThread m_DataSourceControllerThread;
57 QThread m_DataSourceControllerThread;
51 QThread m_VariableControllerThread;
58 QThread m_VariableControllerThread;
52 QThread m_VisualizationControllerThread;
59 QThread m_VisualizationControllerThread;
53 };
60 };
54
61
55
62
56 SqpApplication::SqpApplication(int &argc, char **argv)
63 SqpApplication::SqpApplication(int &argc, char **argv)
57 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
64 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
58 {
65 {
59 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
66 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
60
67
61 connect(&impl->m_DataSourceControllerThread, &QThread::started,
68 connect(&impl->m_DataSourceControllerThread, &QThread::started,
62 impl->m_DataSourceController.get(), &DataSourceController::initialize);
69 impl->m_DataSourceController.get(), &DataSourceController::initialize);
63 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
70 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
64 impl->m_DataSourceController.get(), &DataSourceController::finalize);
71 impl->m_DataSourceController.get(), &DataSourceController::finalize);
65
72
66 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
73 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
67 &VariableController::initialize);
74 &VariableController::initialize);
68 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
75 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
69 &VariableController::finalize);
76 &VariableController::finalize);
70
77
71 connect(&impl->m_VisualizationControllerThread, &QThread::started,
78 connect(&impl->m_VisualizationControllerThread, &QThread::started,
72 impl->m_VisualizationController.get(), &VisualizationController::initialize);
79 impl->m_VisualizationController.get(), &VisualizationController::initialize);
73 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
80 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
74 impl->m_VisualizationController.get(), &VisualizationController::finalize);
81 impl->m_VisualizationController.get(), &VisualizationController::finalize);
75
82
76
77 impl->m_DataSourceControllerThread.start();
83 impl->m_DataSourceControllerThread.start();
78 impl->m_VariableControllerThread.start();
84 impl->m_VariableControllerThread.start();
79 impl->m_VisualizationControllerThread.start();
85 impl->m_VisualizationControllerThread.start();
80 }
86 }
81
87
82 SqpApplication::~SqpApplication()
88 SqpApplication::~SqpApplication()
83 {
89 {
84 }
90 }
85
91
86 void SqpApplication::initialize()
92 void SqpApplication::initialize()
87 {
93 {
88 }
94 }
89
95
90 DataSourceController &SqpApplication::dataSourceController() noexcept
96 DataSourceController &SqpApplication::dataSourceController() noexcept
91 {
97 {
92 return *impl->m_DataSourceController;
98 return *impl->m_DataSourceController;
93 }
99 }
94
100
95 VariableController &SqpApplication::variableController() noexcept
101 VariableController &SqpApplication::variableController() noexcept
96 {
102 {
97 return *impl->m_VariableController;
103 return *impl->m_VariableController;
98 }
104 }
99
105
100 VisualizationController &SqpApplication::visualizationController() noexcept
106 VisualizationController &SqpApplication::visualizationController() noexcept
101 {
107 {
102 return *impl->m_VisualizationController;
108 return *impl->m_VisualizationController;
103 }
109 }
General Comments 0
You need to be logged in to leave comments. Login now