From 45edf6844d32b92b3792a76e79153222fb9fa155 2017-05-29 12:25:31 From: mperrinel Date: 2017-05-29 12:25:31 Subject: [PATCH] Initialisation de l'application multithread avec le spimpl. Ajout du DataSourceController dans un thread dédié. --- diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt new file mode 100644 index 0000000..959e34c --- /dev/null +++ b/app/CMakeLists.txt @@ -0,0 +1,147 @@ + +## sciqlop - CMakeLists.txt +SET(EXECUTABLE_NAME "sciqlop") +SET(SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/) +SET(INCLUDE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/include) +SET(UI_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/src) +SET(RES_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/resources) + +# +# Find Qt modules +# +SCIQLOP_FIND_QT(Core Widgets) + +# +# Find dependent libraries +# ======================== +find_package(sciqlop-gui) + +message("Librairies inclues dans APP: ${SCIQLOP-GUI_LIBRARIES}") +SET(LIBRARIES ${SCIQLOP-GUI_LIBRARIES}) +SET(EXTERN_SHARED_LIBRARIES) + +INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR}) + +# Add sqpcore to the list of libraries to use +list(APPEND LIBRARIES ${SQPCORE_LIBRARY_NAME}) + +# Include core directory +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../core/include") + +# Add dependent shared libraries +list(APPEND SHARED_LIBRARIES ${SQPCORE_SHARED_LIBRARIES}) + +# Retrieve the location of the dynamic library to copy it to the output path +#get_property(sqpcoreLocation TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY LOCATION) +list(APPEND SHARED_LIBRARIES_FROM_TARGETS ${sqpcoreLocation}) + +# +# Compile the application +# +FILE (GLOB_RECURSE APPLICATION_SOURCES + ${SOURCES_DIR}/*.c + ${SOURCES_DIR}/*.cpp + ${SOURCES_DIR}/*.h) + +# Headers files (.h) +FILE (GLOB_RECURSE PROJECT_HEADERS ${INCLUDE_FOLDER}/*.h) + +# Ui files +FILE (GLOB_RECURSE PROJECT_FORMS ${UI_FOLDER}/*.ui) + +# Resources files +FILE (GLOB_RECURSE PROJECT_RESOURCES ${RES_FOLDER}/*.qrc) + +# Retrieve resources files +FILE (GLOB_RECURSE APPLICATION_RESOURCES ${RES_FOLDER}/*.qrc) + +QT5_ADD_RESOURCES(RCC_HDRS ${APPLICATION_RESOURCES} ) + +QT5_WRAP_UI(UIS_HDRS + ${PROJECT_FORMS} +) + + +ADD_EXECUTABLE(${EXECUTABLE_NAME} ${APPLICATION_SOURCES} ${RCC_HDRS} ${UIS_HDRS}) +set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD 14) +set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) +target_link_libraries(${EXECUTABLE_NAME} + ${LIBRARIES}) + +# Link with Qt5 modules +qt5_use_modules(${EXECUTABLE_NAME} Core Widgets) + + +# Add the files to the list of files to be analyzed +LIST(APPEND CHECKSTYLE_INPUT_FILES ${APPLICATION_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) +# Vera++ exclusion files +#LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/path/to/exclusionFiles.tcl) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) + +# +# Compile the tests +# +IF(BUILD_TESTS) + INCLUDE_DIRECTORIES(${SOURCES_DIR}) + 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 ${LIBRARIES}) + + FOREACH( testFile ${TESTS_SOURCES} ) + GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) + GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) + + # Add to the list of sources files all the sources in the same + # directory that aren't another test + FILE (GLOB currentTestSources + ${testDirectory}/*.c + ${testDirectory}/*.cpp + ${testDirectory}/*.h) + LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) + LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) + + ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) + TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} ) + qt5_use_modules(${testName} Test) + + ADD_TEST( NAME ${testName} COMMAND ${testName} ) + + SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName}) + ENDFOREACH( testFile ) + + LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) + LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) + LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) + SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) +ENDIF(BUILD_TESTS) + +# +# Set the files that must be formatted by clang-format. +# +LIST (APPEND FORMATTING_INPUT_FILES ${APPLICATION_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) + +# +# Set the directories that doxygen must browse to generate the +# documentation. +# +# Source directories: +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) +# Source directories to exclude from the documentation generation +#LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) + +# +# Set the directories with the sources to analyze and propagate the +# modification to the parent scope +# +# Source directories to analyze: +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) +# Source directories to exclude from the analysis +#LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) diff --git a/app/resources/qlopapp.qrc b/app/resources/qlopapp.qrc new file mode 100644 index 0000000..fa7e3c3 --- /dev/null +++ b/app/resources/qlopapp.qrc @@ -0,0 +1,5 @@ + + + sciqlopLOGO.svg + + diff --git a/app/resources/sciqlopLOGO.svg b/app/resources/sciqlopLOGO.svg new file mode 100644 index 0000000..2231dd0 --- /dev/null +++ b/app/resources/sciqlopLOGO.svg @@ -0,0 +1,664 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main.cpp b/app/src/main.cpp new file mode 100644 index 0000000..5187192 --- /dev/null +++ b/app/src/main.cpp @@ -0,0 +1,39 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the QLop Software +-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ +#include "mainwindow.h" +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + SqpApplication a(argc, argv); + SqpApplication::setOrganizationName("LPP"); + SqpApplication::setOrganizationDomain("lpp.fr"); + SqpApplication::setApplicationName("SciQLop"); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/app/src/mainwindow.cpp b/app/src/mainwindow.cpp new file mode 100644 index 0000000..123396f --- /dev/null +++ b/app/src/mainwindow.cpp @@ -0,0 +1,104 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the QLop Software +-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include +#include +#include +#include +#include +#include +//#include +//#include +//#include +//#include +//#include +//#include "qlopcore.h" +//#include "qlopcodecmanager.h" +//#include "cdfcodec.h" +//#include "amdatxtcodec.h" +//#include + + +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) +{ + ui->setupUi(this); + /* QLopGUI::registerMenuBar(menuBar()); + this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); + this->m_progressWidget = new QWidget(); + this->m_progressLayout = new QVBoxLayout(this->m_progressWidget); + this->m_progressWidget->setLayout(this->m_progressLayout); + this->m_progressWidget->setWindowModality(Qt::WindowModal); + m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); + for(int i=0;im_progress.append(new QProgressBar(this->m_progressWidget)); + this->m_progress.last()->setMinimum(0); + this->m_progress.last()->setMaximum(100); + this->m_progressLayout->addWidget(this->m_progress.last()); + this->m_progressWidget->hide(); + this->m_progressThreadIds[i] = -1; + } + this->m_progressWidget->setWindowTitle("Loading File"); + const QListServicesToLoad=QList() + << QLopCore::self() + << QLopPlotManager::self() + << QLopCodecManager::self() + << FileDownloader::self() + << QLopDataBase::self() + << SpaceData::self(); + + CDFCodec::registerToManager(); + AMDATXTCodec::registerToManager(); + + + for(int i=0;iserviceName(); + ServicesToLoad.at(i)->initialize(); //must be called before getGUI + QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI(); + if(wdgt) + { + wdgt->setAllowedAreas(Qt::AllDockWidgetAreas); + this->addDockWidget(Qt::TopDockWidgetArea,wdgt); + } + PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i)); + }*/ +} + +MainWindow::~MainWindow() +{ + delete ui; +} + + +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/app/src/mainwindow.h b/app/src/mainwindow.h new file mode 100644 index 0000000..a349a21 --- /dev/null +++ b/app/src/mainwindow.h @@ -0,0 +1,60 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the QLop Software +-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------------*/ +/*-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@member.fsf.org +----------------------------------------------------------------------------*/ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +//#include "../Core/qlopservice.h" +//#include "../Core/qlopgui.h" + + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow { + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); +public slots: + +protected: + void changeEvent(QEvent *e); + +private: + Ui::MainWindow *ui; + QList m_progress; + int *m_progressThreadIds; + QWidget *m_progressWidget; + QVBoxLayout *m_progressLayout; + // QList m_qlopServices; +}; + +#endif // MAINWINDOW_H diff --git a/app/src/mainwindow.ui b/app/src/mainwindow.ui new file mode 100644 index 0000000..581352a --- /dev/null +++ b/app/src/mainwindow.ui @@ -0,0 +1,56 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + QLop + + + true + + + + true + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + 0 + 0 + 800 + 45 + + + + + + + Index Viewer + + + + + + + diff --git a/cmake/sciqlop_params.cmake b/cmake/sciqlop_params.cmake index 917bf6f..880f268 100644 --- a/cmake/sciqlop_params.cmake +++ b/cmake/sciqlop_params.cmake @@ -4,18 +4,18 @@ # Debug or release # # As the "NMake Makefiles" forces by default the CMAKE_BUILD_TYPE variable to Debug, SCIQLOP_BUILD_TYPE variable is used to be sure that the debug mode is a user choice -SET(SCIQLOP_BUILD_TYPE "Release" CACHE STRING "Choose to compile in Debug or Release mode") +#SET(SCIQLOP_BUILD_TYPE "Release" CACHE STRING "Choose to compile in Debug or Release mode") -IF(SCIQLOP_BUILD_TYPE MATCHES "Debug") - MESSAGE (STATUS "Build in Debug") - SET (CMAKE_BUILD_TYPE "Debug") - SET (DEBUG_SUFFIX "d") -ELSE() - MESSAGE (STATUS "Build in Release") - SET (CMAKE_BUILD_TYPE "Release") - SET (SCIQLOP_BUILD_TYPE "Release") - SET (DEBUG_SUFFIX "") -ENDIF() +#IF(SCIQLOP_BUILD_TYPE MATCHES "Debug") +# MESSAGE (STATUS "Build in Debug") +# SET (CMAKE_BUILD_TYPE "Debug") +# SET (DEBUG_SUFFIX "d") +#ELSE() +# MESSAGE (STATUS "Build in Release") +# SET (CMAKE_BUILD_TYPE "Release") +# SET (SCIQLOP_BUILD_TYPE "Release") +# SET (DEBUG_SUFFIX "") +#ENDIF() # # Need to compile tests? diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt new file mode 100644 index 0000000..6313ed2 --- /dev/null +++ b/core/CMakeLists.txt @@ -0,0 +1,128 @@ + +## core - CMakeLists.txt +STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) +SET(SQPCORE_LIBRARY_NAME "${LIBRARY_PREFFIX}_core${DEBUG_SUFFIX}") +SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/") +SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/") + +# Include core directory +include_directories("${INCLUDES_DIR}") + +# Set a variable to display a warning in the version files. +SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.") +# Generate the version file from the cmake version variables. The version +# variables are defined in the cmake/sciqlop_version.cmake file. +CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.h.in" + "${INCLUDES_DIR}/Version.h") +CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.cpp.in" + "${SOURCES_DIR}/Version.cpp") + +# +# Find Qt modules +# +SCIQLOP_FIND_QT(Core) + +# +# Compile the library library +# +FILE (GLOB_RECURSE MODULE_SOURCES + ${INCLUDES_DIR}/*.h + ${SOURCES_DIR}/*.c + ${SOURCES_DIR}/*.cpp + ${SOURCES_DIR}/*.h) + +ADD_LIBRARY(${SQPCORE_LIBRARY_NAME} ${MODULE_SOURCES}) +set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD 14) +set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) +TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME}) +qt5_use_modules(${SQPCORE_LIBRARY_NAME} Core) + +# 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 +IF(BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES(${SQPCORE_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT") +ELSE() + TARGET_COMPILE_DEFINITIONS(${SQPCORE_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES") +ENDIF() + +# Set the variable to parent scope so that the other projects can copy the +# 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}) + +# 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) +# Vera++ exclusion files +#LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/path/to/exclusionFiles.tcl) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) + +# +# Compile the tests +# +IF(BUILD_TESTS) + INCLUDE_DIRECTORIES(${SOURCES_DIR}) + 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}) + + FOREACH( testFile ${TESTS_SOURCES} ) + GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) + GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) + + # Add to the list of sources files all the sources in the same + # directory that aren't another test + FILE (GLOB currentTestSources + ${testDirectory}/*.c + ${testDirectory}/*.cpp + ${testDirectory}/*.h) + LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) + LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) + + ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) + 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}) + ENDFOREACH( testFile ) + + LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) + LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) + LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) + SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) +ENDIF(BUILD_TESTS) + +# +# Set the files that must be formatted by clang-format. +# +LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) + +# +# Set the directories that doxygen must browse to generate the +# documentation. +# +# Source directories: +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) +# Source directories to exclude from the documentation generation +#LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) + +# +# Set the directories with the sources to analyze and propagate the +# modification to the parent scope +# +# Source directories to analyze: +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) +# Source directories to exclude from the analysis +#LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) diff --git a/core/cmake/Findsciqlop-core.cmake b/core/cmake/Findsciqlop-core.cmake new file mode 100755 index 0000000..f1b3a79 --- /dev/null +++ b/core/cmake/Findsciqlop-core.cmake @@ -0,0 +1,21 @@ +# - Try to find sciqlop-core +# Once done this will define +# SCIQLOP-CORE_FOUND - System has sciqlop-core +# SCIQLOP-CORE_INCLUDE_DIR - The sciqlop-core include directories +# SCIQLOP-CORE_LIBRARIES - The libraries needed to use sciqlop-core + +if(SCIQLOP-CORE_FOUND) + return() +endif(SCIQLOP-CORE_FOUND) + +set(SCIQLOP-CORE_INCLUDE_DIR ${sciqlop-core_DIR}/../include) + +set (OS_LIB_EXTENSION "so") + +if(WIN32) + set (OS_LIB_EXTENSION "dll") +endif(WIN32) +# TODO: Add Mac Support +set(SCIQLOP-CORE_LIBRARIES ${LIBRARY_OUTPUT_PATH}/libsciqlop_core${DEBUG_SUFFIX}.${OS_LIB_EXTENSION}) + +set(SCIQLOP-CORE_FOUND TRUE) diff --git a/core/include/Common/spimpl.h b/core/include/Common/spimpl.h new file mode 100644 index 0000000..d58c7e4 --- /dev/null +++ b/core/include/Common/spimpl.h @@ -0,0 +1,461 @@ +/* + ==================================================================== + A Smart Pointer to IMPLementation (i.e. Smart PIMPL or just SPIMPL). + ==================================================================== + + Version: 1.1 + + Latest version: + https://github.com/oliora/samples/blob/master/spimpl.h + Rationale and description: + http://oliora.github.io/2015/12/29/pimpl-and-rule-of-zero.html + + Copyright (c) 2015 Andrey Upadyshev (oliora@gmail.com) + + Distributed under the Boost Software License, Version 1.0. + See http://www.boost.org/LICENSE_1_0.txt + + Changes history + --------------- + v1.1: + - auto_ptr support is disabled by default for C++17 compatibility + v1.0: + - Released + */ + +#ifndef SPIMPL_H_ +#define SPIMPL_H_ + +#include +#include +#include + + +#if defined _MSC_VER && _MSC_VER < 1900 // MS Visual Studio before VS2015 +#define SPIMPL_NO_CPP11_NOEXCEPT +#define SPIMPL_NO_CPP11_CONSTEXPR +#define SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC +#endif + +#if !defined SPIMPL_NO_CPP11_NOEXCEPT +#define SPIMPL_NOEXCEPT noexcept +#else +#define SPIMPL_NOEXCEPT +#endif + +#if !defined SPIMPL_NO_CPP11_CONSTEXPR +#define SPIMPL_CONSTEXPR constexpr +#else +#define SPIMPL_CONSTEXPR +#endif + +// define SPIMPL_HAS_AUTO_PTR to enable constructor and assignment operator that accept +// std::auto_ptr +// TODO: auto detect std::auto_ptr support + + +namespace spimpl { +namespace details { +template +T *default_copy(T *src) +{ + static_assert(sizeof(T) > 0, "default_copy cannot copy incomplete type"); + static_assert(!std::is_void::value, "default_copy cannot copy incomplete type"); + return new T(*src); +} + +template +void default_delete(T *p) SPIMPL_NOEXCEPT +{ + static_assert(sizeof(T) > 0, "default_delete cannot delete incomplete type"); + static_assert(!std::is_void::value, "default_delete cannot delete incomplete type"); + delete p; +} + +template +struct default_deleter { + using type = void (*)(T *); +}; + +template +using default_deleter_t = typename default_deleter::type; + +template +struct default_copier { + using type = T *(*)(T *); +}; + +template +using default_copier_t = typename default_copier::type; + +template +struct is_default_manageable + : public std::integral_constant >::value + && std::is_same >::value> { +}; +} + + +template , + class Copier = details::default_copier_t > +class impl_ptr { +private: + static_assert(!std::is_array::value, + "impl_ptr specialization for arrays is not implemented"); + struct dummy_t_ { + int dummy__; + }; + +public: + using pointer = T *; + using element_type = T; + using copier_type = typename std::decay::type; + using deleter_type = typename std::decay::type; + using unique_ptr_type = std::unique_ptr; + using is_default_manageable = details::is_default_manageable; + + SPIMPL_CONSTEXPR impl_ptr() SPIMPL_NOEXCEPT : ptr_(nullptr, deleter_type{}), + copier_(copier_type{}) + { + } + + SPIMPL_CONSTEXPR impl_ptr(std::nullptr_t) SPIMPL_NOEXCEPT : impl_ptr() {} + + template + impl_ptr(pointer p, D &&d, C &&c, + typename std::enable_if::value + && std::is_convertible::value, + dummy_t_>::type + = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(p), std::forward(d)), + copier_(std::forward(c)) + { + } + + template + impl_ptr(U *u, typename std::enable_if::value + && is_default_manageable::value, + dummy_t_>::type + = dummy_t_()) SPIMPL_NOEXCEPT + : impl_ptr(u, &details::default_delete, &details::default_copy) + { + } + + impl_ptr(const impl_ptr &r) : impl_ptr(r.clone()) {} + +#ifndef SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC + impl_ptr(impl_ptr &&r) SPIMPL_NOEXCEPT = default; +#else + impl_ptr(impl_ptr &&r) SPIMPL_NOEXCEPT : ptr_(std::move(r.ptr_)), copier_(std::move(r.copier_)) + { + } +#endif + +#ifdef SPIMPL_HAS_AUTO_PTR + template + impl_ptr(std::auto_ptr &&u, typename std::enable_if::value + && is_default_manageable::value, + dummy_t_>::type + = dummy_t_()) SPIMPL_NOEXCEPT + : ptr_(u.release(), &details::default_delete), + copier_(&details::default_copy) + { + } +#endif + + template + impl_ptr(std::unique_ptr &&u, + typename std::enable_if::value + && is_default_manageable::value, + dummy_t_>::type + = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(u.release(), &details::default_delete), + copier_(&details::default_copy) + { + } + + template + impl_ptr(std::unique_ptr &&u, C &&c, + typename std::enable_if::value + && std::is_convertible::value + && std::is_convertible::value, + dummy_t_>::type + = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(u)), + copier_(std::forward(c)) + { + } + + template + impl_ptr(impl_ptr &&u, + typename std::enable_if::value + && std::is_convertible::value + && std::is_convertible::value, + dummy_t_>::type + = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(u.ptr_)), + copier_(std::move(u.copier_)) + { + } + + impl_ptr &operator=(const impl_ptr &r) + { + if (this == &r) + return *this; + + return operator=(r.clone()); + } + +#ifndef SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC + impl_ptr &operator=(impl_ptr &&r) SPIMPL_NOEXCEPT = default; +#else + impl_ptr &operator=(impl_ptr &&r) SPIMPL_NOEXCEPT + { + ptr_ = std::move(r.ptr_); + copier_ = std::move(r.copier_); + return *this; + } +#endif + + template + typename std::enable_if::value + && std::is_convertible::value + && std::is_convertible::value, + impl_ptr &>::type + operator=(impl_ptr &&u) SPIMPL_NOEXCEPT + { + ptr_ = std::move(u.ptr_); + copier_ = std::move(u.copier_); + return *this; + } + + template + typename std::enable_if::value + && std::is_convertible::value + && std::is_convertible::value, + impl_ptr &>::type + operator=(const impl_ptr &u) + { + return operator=(u.clone()); + } + +// + +#ifdef SPIMPL_HAS_AUTO_PTR + template + typename std::enable_if::value + && is_default_manageable::value, + impl_ptr &>::type + operator=(std::auto_ptr &&u) SPIMPL_NOEXCEPT + { + return operator=(impl_ptr(std::move(u))); + } +#endif + + template + typename std::enable_if::value + && is_default_manageable::value, + impl_ptr &>::type + operator=(std::unique_ptr &&u) SPIMPL_NOEXCEPT + { + return operator=(impl_ptr(std::move(u))); + } + + impl_ptr clone() const + { + return impl_ptr(ptr_ ? copier_(ptr_.get()) : nullptr, ptr_.get_deleter(), copier_); + } + + typename std::remove_reference::type &operator*() const { return *ptr_; } + pointer operator->() const SPIMPL_NOEXCEPT { return get(); } + pointer get() const SPIMPL_NOEXCEPT { return ptr_.get(); } + + void swap(impl_ptr &u) SPIMPL_NOEXCEPT + { + using std::swap; + ptr_.swap(u.ptr_); + swap(copier_, u.copier_); + } + + pointer release() SPIMPL_NOEXCEPT { return ptr_.release(); } + + unique_ptr_type release_unique() SPIMPL_NOEXCEPT { return std::move(ptr_); } + + explicit operator bool() const SPIMPL_NOEXCEPT { return static_cast(ptr_); } + + typename std::remove_reference::type &get_deleter() SPIMPL_NOEXCEPT + { + return ptr_.get_deleter(); + } + const typename std::remove_reference::type &get_deleter() const SPIMPL_NOEXCEPT + { + return ptr_.get_deleter(); + } + + typename std::remove_reference::type &get_copier() SPIMPL_NOEXCEPT + { + return copier_; + } + const typename std::remove_reference::type &get_copier() const SPIMPL_NOEXCEPT + { + return copier_; + } + +private: + unique_ptr_type ptr_; + copier_type copier_; +}; + + +template +inline void swap(impl_ptr &l, impl_ptr &r) SPIMPL_NOEXCEPT +{ + l.swap(r); +} + + +template +inline bool operator==(const impl_ptr &l, const impl_ptr &r) +{ + return l.get() == r.get(); +} + +template +inline bool operator!=(const impl_ptr &l, const impl_ptr &r) +{ + return !(l == r); +} + +template +inline bool operator<(const impl_ptr &l, const impl_ptr &r) +{ + using P1 = typename impl_ptr::pointer; + using P2 = typename impl_ptr::pointer; + using CT = typename std::common_type::type; + return std::less()(l.get(), r.get()); +} + +template +inline bool operator>(const impl_ptr &l, const impl_ptr &r) +{ + return r < l; +} + +template +inline bool operator<=(const impl_ptr &l, const impl_ptr &r) +{ + return !(r < l); +} + +template +inline bool operator>=(const impl_ptr &l, const impl_ptr &r) +{ + return !(l < r); +} + +template +inline bool operator==(const impl_ptr &p, std::nullptr_t) SPIMPL_NOEXCEPT +{ + return !p; +} + +template +inline bool operator==(std::nullptr_t, const impl_ptr &p) SPIMPL_NOEXCEPT +{ + return !p; +} + +template +inline bool operator!=(const impl_ptr &p, std::nullptr_t) SPIMPL_NOEXCEPT +{ + return static_cast(p); +} + +template +inline bool operator!=(std::nullptr_t, const impl_ptr &p) SPIMPL_NOEXCEPT +{ + return static_cast(p); +} + +template +inline bool operator<(const impl_ptr &l, std::nullptr_t) +{ + using P = typename impl_ptr::pointer; + return std::less

()(l.get(), nullptr); +} + +template +inline bool operator<(std::nullptr_t, const impl_ptr &p) +{ + using P = typename impl_ptr::pointer; + return std::less

()(nullptr, p.get()); +} + +template +inline bool operator>(const impl_ptr &p, std::nullptr_t) +{ + return nullptr < p; +} + +template +inline bool operator>(std::nullptr_t, const impl_ptr &p) +{ + return p < nullptr; +} + +template +inline bool operator<=(const impl_ptr &p, std::nullptr_t) +{ + return !(nullptr < p); +} + +template +inline bool operator<=(std::nullptr_t, const impl_ptr &p) +{ + return !(p < nullptr); +} + +template +inline bool operator>=(const impl_ptr &p, std::nullptr_t) +{ + return !(p < nullptr); +} + +template +inline bool operator>=(std::nullptr_t, const impl_ptr &p) +{ + return !(nullptr < p); +} + + +template +inline impl_ptr make_impl(Args &&... args) +{ + return impl_ptr(new T(std::forward(args)...), &details::default_delete, + &details::default_copy); +} + + +// Helpers to manage unique impl, stored in std::unique_ptr + +template +using unique_impl_ptr = std::unique_ptr; + +template +inline unique_impl_ptr make_unique_impl(Args &&... args) +{ + static_assert(!std::is_array::value, "unique_impl_ptr does not support arrays"); + return unique_impl_ptr(new T(std::forward(args)...), &details::default_delete); +} +} + +namespace std { +template +struct hash > { + using argument_type = spimpl::impl_ptr; + using result_type = size_t; + + result_type operator()(const argument_type &p) const SPIMPL_NOEXCEPT + { + return hash()(p.get()); + } +}; +} + +#endif // SPIMPL_H_ diff --git a/core/include/DataSource/DataSourceController.h b/core/include/DataSource/DataSourceController.h new file mode 100644 index 0000000..94e9d7f --- /dev/null +++ b/core/include/DataSource/DataSourceController.h @@ -0,0 +1,39 @@ +#ifndef SCIQLOP_DATASOURCECONTROLLER_H +#define SCIQLOP_DATASOURCECONTROLLER_H + +#include "DataSourceController.h" + +#include +#include + +#include + +Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController) + +/** + * @brief The DataSourceController class aims to make the link between SciQlop + * and its plugins. This is the intermediate class that SciQlop have to use + * in the way to connect a data source. Please first use load method to intialize + * a plugin specified by its metadata name (JSON plugin source) then others specifics + * method will ba able to access it. + * You can load a data source driver plugin then create a data source. + */ +class DataSourceController : public QObject { + Q_OBJECT +public: + explicit DataSourceController(QObject *parent = 0); + virtual ~DataSourceController(); + +public slots: + /// Manage init/end of the controller + void initialize(); + void finalize(); + +private: + void waitForFinish(); + + class DataSourceControllerPrivate; + spimpl::unique_impl_ptr impl; +}; + +#endif // SCIQLOP_DATASOURCECONTROLLER_H diff --git a/core/resources/Version.cpp.in b/core/resources/Version.cpp.in new file mode 100644 index 0000000..2a27649 --- /dev/null +++ b/core/resources/Version.cpp.in @@ -0,0 +1,78 @@ +#include "Version.h" + +/*************************************************** + * @SCIQLOP_CMAKE_GENERATION_WARNING@ * + ***************************************************/ + +#include +#include + +namespace sciqlop { + +const char *Version::VERSION_SUFFIX = "@SCIQLOP_VERSION_SUFFIX@"; + +/** + * From the C99 standard: + * __DATE__: The date of translation of the preprocessing translation unit: + * a character string literal of the form "Mmm dd yyyy", where the names of + * the months are the same as those generated by the asctime function, and + * the first character of dd is a space character if the value is less than + * 10. If the date of translation is not available, an + * implementation-defined valid date shall be supplied. + */ +const char *Version::BUILD_DATE = __DATE__; +/** + * From the C99 standard: + * __TIME__: The time of translation of the preprocessing translation unit: + * a character string literal of the form "hh:mm:ss" as in the time + * generated by the asctime function. If the time of translation is not + * available, an implementation-defined valid time shall be supplied. + */ +const char *Version::BUILD_TIME = __TIME__; + +QDateTime Version::buildDateTime() +{ + static QDateTime buildDateTime; + if (!buildDateTime.isValid()) { + // Convert BUILD_DATE to a QDate + // The __DATE__ macro return the month name with the asctime() function, + // which doesn't support localization, the month names returned are + // always the same. On the contrary, the "MMM" format on + // QDate::fromString() is localized, so this method can't be used to + // retrieve the month and we must manually do it instead. + QString buildDateStr = QString(BUILD_DATE); + QString buildMonthStr = buildDateStr.left(3); + QString buildDayAndYearStr = buildDateStr.mid(4).trimmed(); + + QDate buildDate = QDate::fromString(buildDayAndYearStr, "d yyyy"); + QStringList monthList = QStringList() << "Jan" + << "Feb" + << "Mar" + << "Apr" + << "May" + << "Jun" + << "Jul" + << "Aug" + << "Sep" + << "Oct" + << "Nov" + << "Dec"; + for (int i = 0; i < monthList.size(); ++i) { + if (buildMonthStr == monthList.at(i)) { + buildDate.setDate(buildDate.year(), i + 1, buildDate.day()); + break; + } + } + + // Convert BUILD_TIME to a QTime + QTime buildTime = QTime::fromString(BUILD_TIME, "hh:mm:ss"); + + // Set the buildDateTime + buildDateTime.setDate(buildDate); + buildDateTime.setTime(buildTime); + } + + return buildDateTime; +} + +} // namespace sciqlop diff --git a/core/resources/Version.h.in b/core/resources/Version.h.in new file mode 100644 index 0000000..cf7a260 --- /dev/null +++ b/core/resources/Version.h.in @@ -0,0 +1,98 @@ +// TODO copyright +/** + * @file Version.h + */ +#ifndef SCIQLOP_VERSION_H +#define SCIQLOP_VERSION_H + +/*************************************************** + * @SCIQLOP_CMAKE_GENERATION_WARNING@ * + ***************************************************/ + +//#include "SciqlopExport.h" +#include + +class QDateTime; + +namespace sciqlop { + +/** + * Holds the version of Sciqlop. + * + * @attention Don't update this class directly, it is generated from the + * `resources/Version.h.in` and `resources/Version.cpp.in` files, along with + * the cmake variables defined in the `cmake/sciqlop_version.cmake` file. + * + * To change the Sciqlop version number, update the `cmake/sciqlop_version.cmake` + * file, and to change this class other than to change the version number, + * update the `resources/Version.h.in` and `resources/Version.cpp.in` files. + * @ingroup Utils + */ +class /*SCIQLOP_API*/ Version { +public: + /** + * Retrieve the version of Sciqlop. + * + * The version is of the form MAJOR.MINOR.PATCH. If a suffix has been + * provided to the version, it is appended after the PATCH. + * + * The version can be modified by updating the cmake/sciqlop_version.cmake + * file. + * + * @return The version of Sciqlop as a QString. + */ + static QString version() + { + static const QString v("@SCIQLOP_VERSION@"); + return v; + } + + /** + * @return The datetime of the build. + */ + static QDateTime buildDateTime(); + + /** + * Major version. + */ + static const int VERSION_MAJOR = @SCIQLOP_VERSION_MAJOR@; + /** + * Minor version. + */ + static const int VERSION_MINOR = @SCIQLOP_VERSION_MINOR@; + /** + * Patch version. + */ + static const int VERSION_PATCH = @SCIQLOP_VERSION_PATCH@; + /** + * Suffix version. + */ + static const char *VERSION_SUFFIX; + + /** + * Compile date computed with the __DATE__ macro. + * + * From the C99 standard: + * __DATE__: The date of translation of the preprocessing translation unit: + * a character string literal of the form "Mmm dd yyyy", where the names of + * the months are the same as those generated by the asctime function, and + * the first character of dd is a space character if the value is less than + * 10. If the date of translation is not available, an + * implementation-defined valid date shall be supplied. + */ + static const char *BUILD_DATE; + /** + * Compile time computed with the __TIME__ macro. + * + * From the C99 standard: + * __TIME__: The time of translation of the preprocessing translation unit: + * a character string literal of the form "hh:mm:ss" as in the time + * generated by the asctime function. If the time of translation is not + * available, an implementation-defined valid time shall be supplied. + */ + static const char *BUILD_TIME; +}; + +} // namespace sciqlop + +#endif // SCIQLOP_VERSION_H diff --git a/core/src/DataSource/DataSourceController.cpp b/core/src/DataSource/DataSourceController.cpp new file mode 100644 index 0000000..2a330b8 --- /dev/null +++ b/core/src/DataSource/DataSourceController.cpp @@ -0,0 +1,47 @@ +#include "DataSource/DataSourceController.h" + +#include +#include + +Q_LOGGING_CATEGORY(LOG_DataSourceController, "dataSourceController") + +class DataSourceController::DataSourceControllerPrivate { +public: + DataSourceControllerPrivate() {} + + + QMutex m_WorkingMutex; +}; + +DataSourceController::DataSourceController(QObject *parent) + : impl{spimpl::make_unique_impl()} +{ + qCInfo(LOG_DataSourceController()) << tr("Construction du DataSourceController"); +} + +DataSourceController::~DataSourceController() +{ + // delete impl; + this->waitForFinish(); +} + +void DataSourceController::initialize() +{ + qCInfo(LOG_DataSourceController()) << tr("initialize du DataSourceController"); + impl->m_WorkingMutex.lock(); + qCInfo(LOG_DataSourceController()) << tr("initialize du DataSourceController END"); +} + +void DataSourceController::finalize() +{ + qCInfo(LOG_DataSourceController()) << tr("finalize du DataSourceController"); + impl->m_WorkingMutex.unlock(); + qCInfo(LOG_DataSourceController()) << tr("finalize du DataSourceController END"); +} + +void DataSourceController::waitForFinish() +{ + qCInfo(LOG_DataSourceController()) << tr("waitForFinish du DataSourceController"); + QMutexLocker locker(&impl->m_WorkingMutex); + qCInfo(LOG_DataSourceController()) << tr("waitForFinish du DataSourceController END"); +} diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt new file mode 100644 index 0000000..117e771 --- /dev/null +++ b/gui/CMakeLists.txt @@ -0,0 +1,159 @@ + +## gui - CMakeLists.txt +STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) +SET(SQPGUI_LIBRARY_NAME "${LIBRARY_PREFFIX}_gui${DEBUG_SUFFIX}") +SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") +SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include") +SET(UI_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/ui") +SET(RES_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/resources") + +# Include gui directory +include_directories("${INCLUDES_DIR}") +include_directories("${CMAKE_CURRENT_BINARY_DIR}") + +# Set a variable to display a warning in the version files. +SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.") + +# +# Find Qt modules +# +SCIQLOP_FIND_QT(Core Widgets) + +# +# Find dependent libraries +# ======================== +find_package(sciqlop-core) + +message("Librairies inclues dans APP: ${SCIQLOP-CORE_LIBRARIES}") +SET(LIBRARIES ${SCIQLOP-CORE_LIBRARIES}) + +INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR}) + +# Add sqpcore to the list of libraries to use +list(APPEND LIBRARIES ${SQPCORE_LIBRARY_NAME}) + +# Add dependent shared libraries +list(APPEND SHARED_LIBRARIES ${SQPCORE_SHARED_LIBRARIES}) + + +# Ui files +FILE (GLOB_RECURSE PROJECT_FORMS ${UI_FOLDER}/*.ui) + +# Resources files +FILE (GLOB_RECURSE PROJECT_RESOURCES ${RES_FOLDER}/*.qrc) + +# +# Compile the library library +# +FILE (GLOB_RECURSE MODULE_SOURCES + ${INCLUDES_DIR}/*.h + ${SOURCES_DIR}/*.c + ${SOURCES_DIR}/*.cpp + ${SOURCES_DIR}/*.h + ${PROJECT_FORMS}) + +QT5_ADD_RESOURCES(RCC_HDRS + ${PROJECT_RESOURCES} +) + +QT5_WRAP_UI(UIS_HDRS + ${PROJECT_FORMS} +) + + +ADD_LIBRARY(${SQPGUI_LIBRARY_NAME} ${MODULE_SOURCES} ${UIS_HDRS} ${RCC_HDRS}) +set_property(TARGET ${SQPGUI_LIBRARY_NAME} PROPERTY CXX_STANDARD 14) +set_property(TARGET ${SQPGUI_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) + +TARGET_LINK_LIBRARIES(${SQPGUI_LIBRARY_NAME} ${LIBRARIES}) +qt5_use_modules(${SQPGUI_LIBRARY_NAME} Core Widgets) + +# 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 +IF(BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES(${SQPGUI_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT") +ELSE() + TARGET_COMPILE_DEFINITIONS(${SQPGUI_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES") +ENDIF() + +# Set the variable to parent scope so that the other projects can copy the +# dependent shared libraries +SCIQLOP_SET_TO_PARENT_SCOPE(SQPGUI_LIBRARY_NAME) + +# Copy extern shared libraries to the lib folder +SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPGUI_LIBRARY_NAME}) + +# 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) +# Vera++ exclusion files +#LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/path/to/exclusionFiles.tcl) +SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) + +# +# Compile the tests +# +IF(BUILD_TESTS) + INCLUDE_DIRECTORIES(${SOURCES_DIR}) + 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 ${SQPGUI_LIBRARY_NAME}) + + FOREACH( testFile ${TESTS_SOURCES} ) + GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) + GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) + + # Add to the list of sources files all the sources in the same + # directory that aren't another test + FILE (GLOB currentTestSources + ${testDirectory}/*.c + ${testDirectory}/*.cpp + ${testDirectory}/*.h) + LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) + LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) + + ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) + 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}) + ENDFOREACH( testFile ) + + LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) + LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) + LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) + SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) +ENDIF(BUILD_TESTS) + +# +# Set the files that must be formatted by clang-format. +# +LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES}) +SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) + +# +# Set the directories that doxygen must browse to generate the +# documentation. +# +# Source directories: +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") +LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) +# Source directories to exclude from the documentation generation +#LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") +SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) + +# +# Set the directories with the sources to analyze and propagate the +# modification to the parent scope +# +# Source directories to analyze: +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") +LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) +# Source directories to exclude from the analysis +#LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") +SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) diff --git a/gui/cmake/Findsciqlop-gui.cmake b/gui/cmake/Findsciqlop-gui.cmake new file mode 100755 index 0000000..890f96f --- /dev/null +++ b/gui/cmake/Findsciqlop-gui.cmake @@ -0,0 +1,21 @@ +# - Try to find sciqlop-gui +# Once done this will define +# SCIQLOP-GUI_FOUND - System has sciqlop-gui +# SCIQLOP-GUI_INCLUDE_DIR - The sciqlop-gui include directories +# SCIQLOP-GUI_LIBRARIES - The libraries needed to use sciqlop-gui + +if(SCIQLOP-GUI_FOUND) + return() +endif(SCIQLOP-GUI_FOUND) + +set(SCIQLOP-GUI_INCLUDE_DIR ${sciqlop-gui_DIR}/../include) + +set (OS_LIB_EXTENSION "so") + +if(WIN32) + set (OS_LIB_EXTENSION "dll") +endif(WIN32) +# TODO: Add Mac Support +set(SCIQLOP-GUI_LIBRARIES ${LIBRARY_OUTPUT_PATH}/libsciqlop_gui${DEBUG_SUFFIX}.${OS_LIB_EXTENSION}) + +set(SCIQLOP-GUI_FOUND TRUE) diff --git a/gui/include/SqpApplication.h b/gui/include/SqpApplication.h new file mode 100644 index 0000000..7114ca5 --- /dev/null +++ b/gui/include/SqpApplication.h @@ -0,0 +1,33 @@ +#ifndef SCIQLOP_SQPAPPLICATION_H +#define SCIQLOP_SQPAPPLICATION_H + +#include "SqpApplication.h" + +#include +#include + +#include + +Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication) + +/** + * @brief The SqpApplication class aims to make the link between SciQlop + * and its plugins. This is the intermediate class that SciQlop have to use + * in the way to connect a data source. Please first use load method to intialize + * a plugin specified by its metadata name (JSON plugin source) then others specifics + * method will ba able to access it. + * You can load a data source driver plugin then create a data source. + */ +class SqpApplication : public QApplication { + Q_OBJECT +public: + explicit SqpApplication(int &argc, char **argv); + virtual ~SqpApplication(); + void initialize(); + +private: + class SqpApplicationPrivate; + spimpl::unique_impl_ptr impl; +}; + +#endif // SCIQLOP_SQPAPPLICATION_H diff --git a/gui/src/SqpApplication.cpp b/gui/src/SqpApplication.cpp new file mode 100644 index 0000000..3bfa138 --- /dev/null +++ b/gui/src/SqpApplication.cpp @@ -0,0 +1,40 @@ +#include "SqpApplication.h" + +#include +#include + +Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") + +class SqpApplication::SqpApplicationPrivate { +public: + SqpApplicationPrivate() {} + + std::unique_ptr m_DataSourceController; + QThread m_DataSourceControllerThread; +}; + + +SqpApplication::SqpApplication(int &argc, char **argv) + : QApplication(argc, argv), impl{spimpl::make_unique_impl()} +{ + qCInfo(LOG_SqpApplication()) << tr("Construction du SqpApplication"); + + impl->m_DataSourceController = std::make_unique(); + impl->m_DataSourceController->moveToThread(&impl->m_DataSourceControllerThread); + + connect(&impl->m_DataSourceControllerThread, &QThread::started, + impl->m_DataSourceController.get(), &DataSourceController::initialize); + connect(&impl->m_DataSourceControllerThread, &QThread::finished, + impl->m_DataSourceController.get(), &DataSourceController::finalize); + + impl->m_DataSourceControllerThread.start(); +} + +SqpApplication::~SqpApplication() +{ + impl->m_DataSourceControllerThread.quit(); +} + +void SqpApplication::initialize() +{ +}