From 22f8b7e43ec3b4cdf76686d574e20934851ee0dc 2017-12-04 17:38:21 From: mperrinel Date: 2017-12-04 17:38:21 Subject: [PATCH] Merge branch 'feature/IntegrationCatalogueAPI' into develop --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ab325b8..52bef36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,13 @@ cmake_policy(VERSION 3.6) PROJECT(SCIQLOP) + +# +# build the CatalogueAPI dependencu +# +INCLUDE("extern/CatalogueAPI.cmake") + # # build the project # -INCLUDE("cmake/sciqlop.cmake") \ No newline at end of file +INCLUDE("cmake/sciqlop.cmake") diff --git a/cmake/FindCatalogueAPI.cmake b/cmake/FindCatalogueAPI.cmake new file mode 100644 index 0000000..e1ec0e8 --- /dev/null +++ b/cmake/FindCatalogueAPI.cmake @@ -0,0 +1,29 @@ +# - Try to find CatalogueAPI Module +# Once done this will define +# CATALOGUEAPI_FOUND - System has CatalogueAPI +# CATALOGUEAPI_INCLUDE_DIRS - The CatalogueAPI include directories +# CATALOGUEAPI_LIBRARIES - The libraries needed to use CatalogueAPI +# CATALOGUEAPI_SHARED_LIBRARIES - The shared libraries for CatalogueAPI + +set(CATALOGUEAPI_ROOT_DIR "${CATALOGUEAPI_EXTERN_FOLDER}" + CACHE PATHS + "Path to the installation of CatalogueAPI" + ${libRootDirForceValue}) + +find_path(CATALOGUEAPI_INCLUDE_DIR CatalogueDao.h + HINTS ${CATALOGUEAPI_ROOT_DIR} ${CATALOGUEAPI_EXTERN_FOLDER} + PATH_SUFFIXES src ) + +find_library(CATALOGUEAPI_LIBRARY NAMES CatalogueAPI + HINTS ${CATALOGUEAPI_ROOT_DIR} ${CATALOGUEAPI_EXTERN_FOLDER} + PATH_SUFFIXES lib) + +set(CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_LIBRARY} ) +set(CATALOGUEAPI_INCLUDE_DIRS ${CATALOGUEAPI_INCLUDE_DIR} ) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set CATALOGUEAPI_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(CatalogueAPI FOUND_VAR CATALOGUEAPI_FOUND + REQUIRED_VARS CATALOGUEAPI_LIBRARY CATALOGUEAPI_INCLUDE_DIR) +mark_as_advanced(CATALOGUEAPI_INCLUDE_DIR CATALOGUEAPI_LIBRARY ) diff --git a/cmake/sciqlop_package_qt.cmake b/cmake/sciqlop_package_qt.cmake index 5ca2a69..4f6139b 100644 --- a/cmake/sciqlop_package_qt.cmake +++ b/cmake/sciqlop_package_qt.cmake @@ -1,5 +1,5 @@ STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TO_LOWER) -SET(WINDEPLOYQT_ARGS --${CMAKE_BUILD_TYPE_TO_LOWER} --list mapping --no-system-d3d-compiler --compiler-runtime --dry-run) +SET(WINDEPLOYQT_ARGS --${CMAKE_BUILD_TYPE_TO_LOWER} --list mapping -network -sql --no-system-d3d-compiler --compiler-runtime --dry-run) #FOREACH(qtModule @_qt5_modules@) # STRING(TOLOWER ${qtModule} qtLowerModule) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 48ddf35..5e4a01b 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,4 +1,3 @@ - ## core - CMakeLists.txt STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) SET(SQPCORE_LIBRARY_NAME "${LIBRARY_PREFFIX}_core${DEBUG_SUFFIX}") @@ -45,12 +44,17 @@ set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME}) qt5_use_modules(${SQPCORE_LIBRARY_NAME} Core Network) +# Find CATALOGUE_API +include_directories("${CATALOGUEAPI_INCLUDE}") +TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME} ${CATALOGUEAPI_LIBRARIES}) INSTALL(TARGETS ${SQPCORE_LIBRARY_NAME} RUNTIME DESTINATION ${INSTALL_BINARY_DIR} LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} ARCHIVE DESTINATION ${INSTALL_LIBRARY_DIR} ) +add_dependencies(${SQPCORE_LIBRARY_NAME} CatalogueAPI) + # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order. # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets @@ -64,9 +68,19 @@ ENDIF() # dependent shared libraries SCIQLOP_SET_TO_PARENT_SCOPE(SQPCORE_LIBRARY_NAME) -# Copy extern shared libraries to the lib folder -SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPCORE_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES}) - +## Copy extern shared libraries to the lib folder +LIST (APPEND ${EXTERN_SHARED_LIBRARIES} ${CATALOGUEAPI_LIBRARIES}) + + +SET (COPY_LIBS_DESTINATION LIBRARY) +if(APPLE) + SET (COPY_LIBS_DESTINATION RUNTIME) +endif() + +add_custom_command(TARGET ${SQPCORE_LIBRARY_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CATALOGUEAPI_LIBRARIES} ${EXECUTABLE_OUTPUT_PATH} +) + # Add the files to the list of files to be analyzed LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES}) SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) @@ -82,6 +96,7 @@ IF(BUILD_TESTS) FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp) FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h) SET( TEST_LIBRARIES ${SQPCORE_LIBRARY_NAME}) + list(APPEND TEST_LIBRARIES ${CATALOGUEAPI_LIBRARIES}) SET(TARGETS_COV) FOREACH( testFile ${TESTS_SOURCES} ) @@ -100,12 +115,12 @@ IF(BUILD_TESTS) ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14) set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON) - TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} ) + TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES}) qt5_use_modules(${testName} Test) ADD_TEST( NAME ${testName} COMMAND ${testName} ) - SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) + SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${CATALOGUEAPI_LIBRARIES}) set(Coverage_NAME ${testName}) if(UNIX) SETUP_TARGET_FOR_COVERAGE(TARGET ${testName}_coverage OUTPUT ${testFile}-path NAME ${testFile} EXECUTABLE ${testName}) 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/meson.build b/core/meson.build index 864624b..cc49a89 100644 --- a/core/meson.build +++ b/core/meson.build @@ -1,5 +1,10 @@ +qxorm_dep = dependency('QxOrm', required : true, fallback:['QxOrm','qxorm_dep']) +catalogueapi_dep = dependency('CatalogueAPI', required : true, fallback:['CatalogueAPI','CatalogueAPI_dep']) + + core_moc_headers = [ + 'include/Catalogue/CatalogueController.h', 'include/Data/IDataProvider.h', 'include/DataSource/DataSourceController.h', 'include/DataSource/DataSourceItemAction.h', @@ -21,6 +26,7 @@ core_sources = [ 'src/Common/DateUtils.cpp', 'src/Common/StringUtils.cpp', 'src/Common/MimeTypesDef.cpp', + 'src/Catalogue/CatalogueController.cpp', 'src/Data/ScalarSeries.cpp', 'src/Data/SpectrogramSeries.cpp', 'src/Data/DataSeriesIterator.cpp', @@ -52,14 +58,15 @@ sciqlop_core_lib = library('sciqlopcore', core_moc_files, cpp_args : '-DCORE_LIB', include_directories : core_inc, - dependencies : [qt5core, qt5network], + dependencies : [qt5core, qt5network, catalogueapi_dep], install : true ) sciqlop_core = declare_dependency(link_with : sciqlop_core_lib, include_directories : core_inc, - dependencies : [qt5core, qt5network]) + dependencies : [qt5core, qt5network, catalogueapi_dep]) + subdir('tests') 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/extern/CatalogueAPI.cmake b/extern/CatalogueAPI.cmake new file mode 100644 index 0000000..7bacfa1 --- /dev/null +++ b/extern/CatalogueAPI.cmake @@ -0,0 +1,73 @@ +# - Clone and build CatalogueAPI Module +include(ExternalProject) + +find_package(Git REQUIRED) + +if(WIN32) + find_program(MesonExec meson PATHS C:/Appli/Meson) + if(NOT MesonExec) + Message("Error: Meson not found") + else() + message("Meson found: ${MesonExec}" ) + endif() + find_program(NinjaExec ninja PATHS C:/Appli/Meson) + if(NOT NinjaExec) + Message("Error: Ninja not found") + else() + message("Ninja found: ${NinjaExec}" ) + endif() +endif() +if(NOT MesonExec) + set (MesonExec meson) +endif() +if(NOT NinjaExec) + set (NinjaExec ninja) +endif() + +SET(CATALOGUEAPI_SOURCES_PATH ${CMAKE_SOURCE_DIR}/3rdparty/CatalogueAPI) +SET(CATALOGUEAPI_BUILD_PATH ${CATALOGUEAPI_SOURCES_PATH}/build) +SET(CATALOGUEAPI_QXORM_LIB_PATH ${CATALOGUEAPI_BUILD_PATH}/subprojects/QxOrm) +SET(CatalogueAPI_build_type plain) + +if(CMAKE_BUILD_TYPE STREQUAL "") + set(CMAKE_BUILD_TYPE Release) +endif() +string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) + +ExternalProject_Add( + CatalogueAPI + + GIT_REPOSITORY https://perrinel@hephaistos.lpp.polytechnique.fr/rhodecode/GIT_REPOSITORIES/LPP/Users/mperrinel/CatalogueAPI + GIT_TAG develop + + UPDATE_COMMAND ${GIT_EXECUTABLE} pull + PATCH_COMMAND "" + + SOURCE_DIR "${CATALOGUEAPI_SOURCES_PATH}" + CONFIGURE_COMMAND ${MesonExec} --prefix=${CATALOGUEAPI_SOURCES_PATH} --buildtype=${CMAKE_BUILD_TYPE_TOLOWER} "${CATALOGUEAPI_SOURCES_PATH}" "${CATALOGUEAPI_BUILD_PATH}" + + BUILD_COMMAND ${NinjaExec} -C "${CATALOGUEAPI_BUILD_PATH}" + INSTALL_COMMAND ${NinjaExec} -C "${CATALOGUEAPI_BUILD_PATH}" install + LOG_DOWNLOAD 1 + LOG_UPDATE 1 +) + +set(CATALOG_LIB_PATH lib) +if(WIN32) + set(CATALOG_LIB_PATH bin) +endif() + +ExternalProject_Add_Step( + CatalogueAPI CopyToBin + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CATALOGUEAPI_SOURCES_PATH}/lib64 ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CATALOGUEAPI_QXORM_LIB_PATH} ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH} + DEPENDEES install +) + + +set(CATALOGUEAPI_INCLUDE ${CATALOGUEAPI_SOURCES_PATH}/src) +set(CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}CatalogueAPI${CMAKE_SHARED_LIBRARY_SUFFIX}) +list(APPEND CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}QxOrm${CMAKE_SHARED_LIBRARY_SUFFIX}) + +mark_as_advanced(CATALOGUEAPI_INCLUDE) +mark_as_advanced(CATALOGUEAPI_LIBRARIES) 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() diff --git a/subprojects/CatalogueAPI.wrap b/subprojects/CatalogueAPI.wrap new file mode 100644 index 0000000..349a087 --- /dev/null +++ b/subprojects/CatalogueAPI.wrap @@ -0,0 +1,4 @@ +[wrap-git] +directory=CatalogueAPI +url=https://hephaistos.lpp.polytechnique.fr/rhodecode/GIT_REPOSITORIES/LPP/Users/mperrinel/CatalogueAPI.git +revision=head diff --git a/subprojects/QxOrm.wrap b/subprojects/QxOrm.wrap new file mode 100644 index 0000000..b382a86 --- /dev/null +++ b/subprojects/QxOrm.wrap @@ -0,0 +1,5 @@ +[wrap-git] +directory=QxOrm +url=https://github.com/jeandet/qxorm.git +revision=head +