SqpApplication.cpp
151 lines
| 6.1 KiB
| text/x-c
|
CppLexer
r21 | #include "SqpApplication.h" | |||
Alexandre Leroux
|
r157 | #include <Data/IDataProvider.h> | ||
r21 | #include <DataSource/DataSourceController.h> | |||
r313 | #include <Network/NetworkController.h> | |||
r21 | #include <QThread> | |||
r179 | #include <Time/TimeController.h> | |||
Alexandre Leroux
|
r158 | #include <Variable/Variable.h> | ||
Alexandre Leroux
|
r106 | #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>()}, | ||||
r313 | m_NetworkController{std::make_unique<NetworkController>()}, | |||
r179 | m_TimeController{std::make_unique<TimeController>()}, | |||
Alexandre Leroux
|
r106 | m_VariableController{std::make_unique<VariableController>()}, | ||
r55 | m_VisualizationController{std::make_unique<VisualizationController>()} | |||
Alexandre Leroux
|
r32 | { | ||
Alexandre Leroux
|
r157 | // /////////////////////////////// // | ||
// Connections between controllers // | ||||
// /////////////////////////////// // | ||||
// VariableController <-> DataSourceController | ||||
connect(m_DataSourceController.get(), | ||||
Alexandre Leroux
|
r377 | SIGNAL(variableCreationRequested(const QString &, const QVariantHash &, | ||
std::shared_ptr<IDataProvider>)), | ||||
Alexandre Leroux
|
r157 | m_VariableController.get(), | ||
Alexandre Leroux
|
r377 | SLOT(createVariable(const QString &, const QVariantHash &, | ||
std::shared_ptr<IDataProvider>))); | ||||
Alexandre Leroux
|
r157 | |||
Alexandre Leroux
|
r158 | // VariableController <-> VisualizationController | ||
Alexandre Leroux
|
r310 | connect(m_VariableController.get(), | ||
SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), | ||||
m_VisualizationController.get(), | ||||
SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection); | ||||
Alexandre Leroux
|
r158 | |||
r403 | connect(m_VariableController.get(), | |||
SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpDateTime &)), | ||||
m_VisualizationController.get(), | ||||
SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpDateTime &))); | ||||
r179 | ||||
Alexandre Leroux
|
r32 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); | ||
r395 | m_DataSourceControllerThread.setObjectName("DataSourceControllerThread"); | |||
r313 | m_NetworkController->moveToThread(&m_NetworkControllerThread); | |||
r395 | m_NetworkControllerThread.setObjectName("NetworkControllerThread"); | |||
Alexandre Leroux
|
r106 | m_VariableController->moveToThread(&m_VariableControllerThread); | ||
r395 | m_VariableControllerThread.setObjectName("VariableControllerThread"); | |||
r55 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); | |||
r395 | m_VisualizationControllerThread.setObjectName("VsualizationControllerThread"); | |||
r179 | ||||
r345 | ||||
r179 | // 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 | ||||
r313 | m_NetworkControllerThread.quit(); | |||
m_NetworkControllerThread.wait(); | ||||
Alexandre Leroux
|
r106 | m_VariableControllerThread.quit(); | ||
m_VariableControllerThread.wait(); | ||||
r55 | m_VisualizationControllerThread.quit(); | |||
m_VisualizationControllerThread.wait(); | ||||
r22 | } | |||
r21 | ||||
std::unique_ptr<DataSourceController> m_DataSourceController; | ||||
Alexandre Leroux
|
r106 | std::unique_ptr<VariableController> m_VariableController; | ||
r179 | std::unique_ptr<TimeController> m_TimeController; | |||
r313 | std::unique_ptr<NetworkController> m_NetworkController; | |||
r53 | std::unique_ptr<VisualizationController> m_VisualizationController; | |||
r21 | QThread m_DataSourceControllerThread; | |||
r313 | QThread m_NetworkControllerThread; | |||
Alexandre Leroux
|
r106 | 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 | { | |||
r359 | qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread(); | |||
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); | ||||
r313 | connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(), | |||
&NetworkController::initialize); | ||||
connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(), | ||||
&NetworkController::finalize); | ||||
Alexandre Leroux
|
r106 | 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(); | |||
r313 | impl->m_NetworkControllerThread.start(); | |||
Alexandre Leroux
|
r106 | impl->m_VariableControllerThread.start(); | ||
r55 | impl->m_VisualizationControllerThread.start(); | |||
r21 | } | |||
SqpApplication::~SqpApplication() | ||||
{ | ||||
} | ||||
void SqpApplication::initialize() | ||||
{ | ||||
} | ||||
Alexandre Leroux
|
r33 | |||
Alexandre Leroux
|
r110 | DataSourceController &SqpApplication::dataSourceController() noexcept | ||
Alexandre Leroux
|
r33 | { | ||
return *impl->m_DataSourceController; | ||||
} | ||||
r53 | ||||
r313 | NetworkController &SqpApplication::networkController() noexcept | |||
{ | ||||
return *impl->m_NetworkController; | ||||
} | ||||
r179 | TimeController &SqpApplication::timeController() noexcept | |||
{ | ||||
return *impl->m_TimeController; | ||||
} | ||||
Alexandre Leroux
|
r110 | VariableController &SqpApplication::variableController() noexcept | ||
Alexandre Leroux
|
r106 | { | ||
return *impl->m_VariableController; | ||||
} | ||||
Alexandre Leroux
|
r110 | VisualizationController &SqpApplication::visualizationController() noexcept | ||
r53 | { | |||
return *impl->m_VisualizationController; | ||||
} | ||||