SqpApplication.cpp
127 lines
| 5.0 KiB
| text/x-c
|
CppLexer
r21 | #include "SqpApplication.h" | |||
Alexandre Leroux
|
r169 | #include <Data/IDataProvider.h> | ||
r21 | #include <DataSource/DataSourceController.h> | |||
#include <QThread> | ||||
r193 | #include <Time/TimeController.h> | |||
Alexandre Leroux
|
r170 | #include <Variable/Variable.h> | ||
Alexandre Leroux
|
r111 | #include <Variable/VariableController.h> | ||
r53 | #include <Visualization/VisualizationController.h> | |||
r21 | ||||
Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") | ||||
class SqpApplication::SqpApplicationPrivate { | ||||
public: | ||||
r55 | SqpApplicationPrivate() | |||
: m_DataSourceController{std::make_unique<DataSourceController>()}, | ||||
r193 | m_TimeController{std::make_unique<TimeController>()}, | |||
Alexandre Leroux
|
r111 | m_VariableController{std::make_unique<VariableController>()}, | ||
r55 | m_VisualizationController{std::make_unique<VisualizationController>()} | |||
Alexandre Leroux
|
r32 | { | ||
r338 | QThread::currentThread()->setObjectName("MainThread"); | |||
m_DataSourceController->moveToThread(&m_DataSourceControllerThread); | ||||
m_DataSourceControllerThread.setObjectName("DataSourceControllerThread"); | ||||
m_VariableController->moveToThread(&m_VariableControllerThread); | ||||
m_VariableControllerThread.setObjectName("VariableControllerThread"); | ||||
m_VisualizationController->moveToThread(&m_VisualizationControllerThread); | ||||
m_VisualizationControllerThread.setObjectName("VisualizationControllerThread"); | ||||
Alexandre Leroux
|
r169 | // /////////////////////////////// // | ||
// Connections between controllers // | ||||
// /////////////////////////////// // | ||||
// VariableController <-> DataSourceController | ||||
connect(m_DataSourceController.get(), | ||||
SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)), | ||||
m_VariableController.get(), | ||||
SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>))); | ||||
Alexandre Leroux
|
r170 | // VariableController <-> VisualizationController | ||
connect(m_VariableController.get(), SIGNAL(variableCreated(std::shared_ptr<Variable>)), | ||||
m_VisualizationController.get(), | ||||
Alexandre Leroux
|
r174 | SIGNAL(variableCreated(std::shared_ptr<Variable>))); | ||
Alexandre Leroux
|
r336 | connect(m_VariableController.get(), | ||
SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), | ||||
m_VisualizationController.get(), | ||||
SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection); | ||||
Alexandre Leroux
|
r170 | |||
r193 | ||||
// Additionnal init | ||||
m_VariableController->setTimeController(m_TimeController.get()); | ||||
Alexandre Leroux
|
r32 | } | ||
r24 | virtual ~SqpApplicationPrivate() | |||
r22 | { | |||
Alexandre Leroux
|
r32 | qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction"); | ||
r22 | m_DataSourceControllerThread.quit(); | |||
m_DataSourceControllerThread.wait(); | ||||
r53 | ||||
Alexandre Leroux
|
r111 | m_VariableControllerThread.quit(); | ||
m_VariableControllerThread.wait(); | ||||
r55 | m_VisualizationControllerThread.quit(); | |||
m_VisualizationControllerThread.wait(); | ||||
r22 | } | |||
r21 | ||||
std::unique_ptr<DataSourceController> m_DataSourceController; | ||||
Alexandre Leroux
|
r111 | std::unique_ptr<VariableController> m_VariableController; | ||
r193 | std::unique_ptr<TimeController> m_TimeController; | |||
r53 | std::unique_ptr<VisualizationController> m_VisualizationController; | |||
r21 | QThread m_DataSourceControllerThread; | |||
Alexandre Leroux
|
r111 | QThread m_VariableControllerThread; | ||
r55 | QThread m_VisualizationControllerThread; | |||
r21 | }; | |||
SqpApplication::SqpApplication(int &argc, char **argv) | ||||
Alexandre Leroux
|
r32 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} | ||
r21 | { | |||
Alexandre Leroux
|
r32 | qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction"); | ||
r21 | ||||
connect(&impl->m_DataSourceControllerThread, &QThread::started, | ||||
impl->m_DataSourceController.get(), &DataSourceController::initialize); | ||||
connect(&impl->m_DataSourceControllerThread, &QThread::finished, | ||||
impl->m_DataSourceController.get(), &DataSourceController::finalize); | ||||
Alexandre Leroux
|
r111 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), | ||
&VariableController::initialize); | ||||
connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), | ||||
&VariableController::finalize); | ||||
r55 | connect(&impl->m_VisualizationControllerThread, &QThread::started, | |||
impl->m_VisualizationController.get(), &VisualizationController::initialize); | ||||
connect(&impl->m_VisualizationControllerThread, &QThread::finished, | ||||
impl->m_VisualizationController.get(), &VisualizationController::finalize); | ||||
r53 | ||||
r21 | impl->m_DataSourceControllerThread.start(); | |||
Alexandre Leroux
|
r111 | impl->m_VariableControllerThread.start(); | ||
r55 | impl->m_VisualizationControllerThread.start(); | |||
r21 | } | |||
SqpApplication::~SqpApplication() | ||||
{ | ||||
} | ||||
void SqpApplication::initialize() | ||||
{ | ||||
} | ||||
Alexandre Leroux
|
r33 | |||
Alexandre Leroux
|
r116 | DataSourceController &SqpApplication::dataSourceController() noexcept | ||
Alexandre Leroux
|
r33 | { | ||
return *impl->m_DataSourceController; | ||||
} | ||||
r53 | ||||
r193 | TimeController &SqpApplication::timeController() noexcept | |||
{ | ||||
return *impl->m_TimeController; | ||||
} | ||||
Alexandre Leroux
|
r116 | VariableController &SqpApplication::variableController() noexcept | ||
Alexandre Leroux
|
r111 | { | ||
return *impl->m_VariableController; | ||||
} | ||||
Alexandre Leroux
|
r116 | VisualizationController &SqpApplication::visualizationController() noexcept | ||
r53 | { | |||
return *impl->m_VisualizationController; | ||||
} | ||||