SqpApplication.cpp
72 lines
| 2.5 KiB
| text/x-c
|
CppLexer
r21 | #include "SqpApplication.h" | |||
#include <DataSource/DataSourceController.h> | ||||
#include <QThread> | ||||
r53 | #include <Visualization/VisualizationController.h> | |||
r21 | ||||
Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") | ||||
class SqpApplication::SqpApplicationPrivate { | ||||
public: | ||||
r55 | SqpApplicationPrivate() | |||
: m_DataSourceController{std::make_unique<DataSourceController>()}, | ||||
m_VisualizationController{std::make_unique<VisualizationController>()} | ||||
Alexandre Leroux
|
r32 | { | ||
m_DataSourceController->moveToThread(&m_DataSourceControllerThread); | ||||
r55 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); | |||
Alexandre Leroux
|
r32 | } | ||
r24 | virtual ~SqpApplicationPrivate() | |||
r22 | { | |||
Alexandre Leroux
|
r32 | qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction"); | ||
r22 | m_DataSourceControllerThread.quit(); | |||
m_DataSourceControllerThread.wait(); | ||||
r53 | ||||
r55 | m_VisualizationControllerThread.quit(); | |||
m_VisualizationControllerThread.wait(); | ||||
r22 | } | |||
r21 | ||||
std::unique_ptr<DataSourceController> m_DataSourceController; | ||||
r53 | std::unique_ptr<VisualizationController> m_VisualizationController; | |||
r21 | QThread m_DataSourceControllerThread; | |||
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); | ||||
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(); | |||
r55 | impl->m_VisualizationControllerThread.start(); | |||
r21 | } | |||
SqpApplication::~SqpApplication() | ||||
{ | ||||
} | ||||
void SqpApplication::initialize() | ||||
{ | ||||
} | ||||
Alexandre Leroux
|
r33 | |||
DataSourceController &SqpApplication::dataSourceController() const noexcept | ||||
{ | ||||
return *impl->m_DataSourceController; | ||||
} | ||||
r53 | ||||
VisualizationController &SqpApplication::visualizationController() const noexcept | ||||
{ | ||||
return *impl->m_VisualizationController; | ||||
} | ||||