diff --git a/core/include/Catalogue/CatalogueController.h b/core/include/Catalogue/CatalogueController.h new file mode 100644 index 0000000..8878f81 --- /dev/null +++ b/core/include/Catalogue/CatalogueController.h @@ -0,0 +1,51 @@ +#ifndef SCIQLOP_CATALOGUECONTROLLER_H +#define SCIQLOP_CATALOGUECONTROLLER_H + +#include "CoreGlobal.h" + +#include + +#include +#include +#include + +#include + +Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueController) + +class DataSourceItem; +class Variable; + +/** + * @brief The CatalogueController class aims to make the link between SciQlop and its plugins. + * This is the intermediate class that SciQlop has to use in the way to connect a data source. + * Please first use register method to initialize a plugin specified by its metadata name (JSON + * plugin source) then others specifics method will be able to access it. You can load a data source + * driver plugin then create a data source. + */ +class SCIQLOP_CORE_EXPORT CatalogueController : public QObject { + Q_OBJECT +public: + explicit CatalogueController(QObject *parent = 0); + virtual ~CatalogueController(); + +signals: + /// Signal emitted when a variable is about to be deleted from SciQlop + void variableAboutToBeDeleted(std::shared_ptr variable); + + /// Signal emitted when a data acquisition is requested on a range for a variable + void rangeChanged(std::shared_ptr variable, const SqpRange &range); + +public slots: + /// Manage init/end of the controller + void initialize(); + void finalize(); + +private: + void waitForFinish(); + + class CatalogueControllerPrivate; + spimpl::unique_impl_ptr impl; +}; + +#endif // SCIQLOP_CATALOGUECONTROLLER_H diff --git a/core/src/Catalogue/CatalogueController.cpp b/core/src/Catalogue/CatalogueController.cpp new file mode 100644 index 0000000..4932adf --- /dev/null +++ b/core/src/Catalogue/CatalogueController.cpp @@ -0,0 +1,52 @@ +#include + +#include + +#include + +#include +#include + +#include +#include + +Q_LOGGING_CATEGORY(LOG_CatalogueController, "CatalogueController") + +class CatalogueController::CatalogueControllerPrivate { +public: + QMutex m_WorkingMutex; + CatalogueDao m_CatalogueDao; +}; + +CatalogueController::CatalogueController(QObject *parent) + : impl{spimpl::make_unique_impl()} +{ + qCDebug(LOG_CatalogueController()) << tr("CatalogueController construction") + << QThread::currentThread(); +} + +CatalogueController::~CatalogueController() +{ + qCDebug(LOG_CatalogueController()) << tr("CatalogueController destruction") + << QThread::currentThread(); + this->waitForFinish(); +} + +void CatalogueController::initialize() +{ + qCDebug(LOG_CatalogueController()) << tr("CatalogueController init") + << QThread::currentThread(); + impl->m_WorkingMutex.lock(); + impl->m_CatalogueDao.initialize(); + qCDebug(LOG_CatalogueController()) << tr("CatalogueController init END"); +} + +void CatalogueController::finalize() +{ + impl->m_WorkingMutex.unlock(); +} + +void CatalogueController::waitForFinish() +{ + QMutexLocker locker{&impl->m_WorkingMutex}; +} diff --git a/gui/src/SqpApplication.cpp b/gui/src/SqpApplication.cpp index 4cc6a83..4e676ed 100644 --- a/gui/src/SqpApplication.cpp +++ b/gui/src/SqpApplication.cpp @@ -1,5 +1,6 @@ #include "SqpApplication.h" +#include #include #include #include @@ -22,6 +23,7 @@ public: m_NetworkController{std::make_unique()}, m_VisualizationController{std::make_unique()}, m_DragDropHelper{std::make_unique()}, + m_CatalogueController{std::make_unique()}, m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None), m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor) { @@ -60,6 +62,8 @@ public: m_VariableControllerThread.setObjectName("VariableControllerThread"); m_VisualizationController->moveToThread(&m_VisualizationControllerThread); m_VisualizationControllerThread.setObjectName("VsualizationControllerThread"); + m_CatalogueController->moveToThread(&m_CatalogueControllerThread); + m_CatalogueControllerThread.setObjectName("CatalogueControllerThread"); // Additionnal init @@ -79,6 +83,9 @@ public: m_VisualizationControllerThread.quit(); m_VisualizationControllerThread.wait(); + + m_CatalogueControllerThread.quit(); + m_CatalogueControllerThread.wait(); } std::unique_ptr m_DataSourceController; @@ -86,10 +93,12 @@ public: std::unique_ptr m_TimeController; std::unique_ptr m_NetworkController; std::unique_ptr m_VisualizationController; + std::unique_ptr m_CatalogueController; QThread m_DataSourceControllerThread; QThread m_NetworkControllerThread; QThread m_VariableControllerThread; QThread m_VisualizationControllerThread; + QThread m_CatalogueControllerThread; std::unique_ptr m_DragDropHelper; @@ -123,10 +132,16 @@ SqpApplication::SqpApplication(int &argc, char **argv) connect(&impl->m_VisualizationControllerThread, &QThread::finished, impl->m_VisualizationController.get(), &VisualizationController::finalize); + connect(&impl->m_CatalogueControllerThread, &QThread::started, + impl->m_CatalogueController.get(), &CatalogueController::initialize); + connect(&impl->m_CatalogueControllerThread, &QThread::finished, + impl->m_CatalogueController.get(), &CatalogueController::finalize); + impl->m_DataSourceControllerThread.start(); impl->m_NetworkControllerThread.start(); impl->m_VariableControllerThread.start(); impl->m_VisualizationControllerThread.start(); + impl->m_CatalogueControllerThread.start(); } SqpApplication::~SqpApplication()