From 73015bd6234fbd1f3513fddc917032c9fbf36c2c 2017-05-29 13:10:25 From: perrinel Date: 2017-05-29 13:10:25 Subject: [PATCH] Merge pull request #131 from SCIQLOP-Initialisation feature/InitDataSourceController Feature/InitDataSourceController --- diff --git a/sqpapp/CMakeLists.txt b/app/CMakeLists.txt similarity index 94% rename from sqpapp/CMakeLists.txt rename to app/CMakeLists.txt index f0c8b80..959e34c 100644 --- a/sqpapp/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -14,15 +14,19 @@ SCIQLOP_FIND_QT(Core Widgets) # # Find dependent libraries # ======================== -SET(LIBRARIES) -SET(EXTERN_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 sqpcore directory -include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../sqpcore/src") +# Include core directory +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../core/include") # Add dependent shared libraries list(APPEND SHARED_LIBRARIES ${SQPCORE_SHARED_LIBRARIES}) @@ -61,7 +65,6 @@ QT5_WRAP_UI(UIS_HDRS 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}) @@ -83,7 +86,7 @@ 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} ${EXTERN_LIBRARIES}) + SET( TEST_LIBRARIES ${LIBRARIES}) FOREACH( testFile ${TESTS_SOURCES} ) GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) @@ -104,7 +107,7 @@ IF(BUILD_TESTS) ADD_TEST( NAME ${testName} COMMAND ${testName} ) - SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) + SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName}) ENDFOREACH( testFile ) LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) diff --git a/sqpapp/resources/qlopapp.qrc b/app/resources/qlopapp.qrc similarity index 100% rename from sqpapp/resources/qlopapp.qrc rename to app/resources/qlopapp.qrc diff --git a/sqpapp/resources/sciqlopLOGO.svg b/app/resources/sciqlopLOGO.svg similarity index 100% rename from sqpapp/resources/sciqlopLOGO.svg rename to app/resources/sciqlopLOGO.svg diff --git a/sqpapp/src/main.cpp b/app/src/main.cpp similarity index 84% rename from sqpapp/src/main.cpp rename to app/src/main.cpp index 5b8c8ca..5187192 100644 --- a/sqpapp/src/main.cpp +++ b/app/src/main.cpp @@ -20,18 +20,18 @@ -- Mail : alexis.jeandet@member.fsf.org ----------------------------------------------------------------------------*/ #include "mainwindow.h" -#include #include #include -//#include +#include +#include #include int main(int argc, char *argv[]) { - QApplication a(argc, argv); - QApplication::setOrganizationName("LPP"); - QApplication::setOrganizationDomain("lpp.fr"); - QApplication::setApplicationName("SciQLop"); + SqpApplication a(argc, argv); + SqpApplication::setOrganizationName("LPP"); + SqpApplication::setOrganizationDomain("lpp.fr"); + SqpApplication::setApplicationName("SciQLop"); MainWindow w; w.show(); diff --git a/sqpapp/src/mainwindow.cpp b/app/src/mainwindow.cpp similarity index 98% rename from sqpapp/src/mainwindow.cpp rename to app/src/mainwindow.cpp index bf9315d..123396f 100644 --- a/sqpapp/src/mainwindow.cpp +++ b/app/src/mainwindow.cpp @@ -26,7 +26,7 @@ #include #include #include -//#include +#include //#include //#include //#include diff --git a/sqpapp/src/mainwindow.h b/app/src/mainwindow.h similarity index 100% rename from sqpapp/src/mainwindow.h rename to app/src/mainwindow.h diff --git a/sqpapp/src/mainwindow.ui b/app/src/mainwindow.ui similarity index 100% rename from sqpapp/src/mainwindow.ui rename to app/src/mainwindow.ui diff --git a/cmake/sciqlop_applications.cmake b/cmake/sciqlop_applications.cmake index 94dc1cb..b4fb446 100644 --- a/cmake/sciqlop_applications.cmake +++ b/cmake/sciqlop_applications.cmake @@ -10,9 +10,15 @@ SET (LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE}) # # Compile the diffents modules # -ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/sqpcore") -#ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/sqpgui") -ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/sqpapp") +set(sciqlop-core_DIR "${CMAKE_SOURCE_DIR}/core/cmake") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-core_DIR}") +ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/core") + +set(sciqlop-gui_DIR "${CMAKE_SOURCE_DIR}/gui/cmake") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-gui_DIR}") +ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/gui") + +ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/app") # # Code formatting 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/sqpcore/CMakeLists.txt b/core/CMakeLists.txt similarity index 93% rename from sqpcore/CMakeLists.txt rename to core/CMakeLists.txt index 1f3e6de..6313ed2 100644 --- a/sqpcore/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,15 +1,19 @@ -## sqpcore - CMakeLists.txt +## core - CMakeLists.txt STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) -SET(SQPCORE_LIBRARY_NAME "${LIBRARY_PREFFIX}_sqpcore${DEBUG_SUFFIX}") +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" - "${SOURCES_DIR}/Version.h") + "${INCLUDES_DIR}/Version.h") CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.cpp.in" "${SOURCES_DIR}/Version.cpp") @@ -22,14 +26,15 @@ SCIQLOP_FIND_QT(Core) # Compile the library library # FILE (GLOB_RECURSE MODULE_SOURCES - ${SOURCES_DIR}/*.c - ${SOURCES_DIR}/*.cpp + ${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} ${EXTERN_LIBRARIES}) +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 @@ -62,7 +67,7 @@ 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} ${EXTERN_LIBRARIES}) + SET( TEST_LIBRARIES ${SQPCORE_LIBRARY_NAME}) FOREACH( testFile ${TESTS_SOURCES} ) GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) 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/sqpcore/resources/Version.cpp.in b/core/resources/Version.cpp.in similarity index 100% rename from sqpcore/resources/Version.cpp.in rename to core/resources/Version.cpp.in diff --git a/sqpcore/resources/Version.h.in b/core/resources/Version.h.in similarity index 100% rename from sqpcore/resources/Version.h.in rename to core/resources/Version.h.in diff --git a/core/src/DataSource/DataSourceController.cpp b/core/src/DataSource/DataSourceController.cpp new file mode 100644 index 0000000..ed71deb --- /dev/null +++ b/core/src/DataSource/DataSourceController.cpp @@ -0,0 +1,45 @@ +#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()} +{ + qCDebug(LOG_DataSourceController()) << tr("Construction du DataSourceController") + << QThread::currentThread(); +} + +DataSourceController::~DataSourceController() +{ + qCDebug(LOG_DataSourceController()) << tr("Desctruction du DataSourceController") + << QThread::currentThread(); + this->waitForFinish(); +} + +void DataSourceController::initialize() +{ + qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController") + << QThread::currentThread(); + impl->m_WorkingMutex.lock(); + qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController END"); +} + +void DataSourceController::finalize() +{ + impl->m_WorkingMutex.unlock(); +} + +void DataSourceController::waitForFinish() +{ + QMutexLocker locker(&impl->m_WorkingMutex); +} diff --git a/sqpgui/CMakeLists.txt b/gui/CMakeLists.txt similarity index 76% rename from sqpgui/CMakeLists.txt rename to gui/CMakeLists.txt index 6dd5351..117e771 100644 --- a/sqpgui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -1,30 +1,40 @@ -## sqpgui - CMakeLists.txt +## gui - CMakeLists.txt STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX) -SET(SQPGUI_LIBRARY_NAME "${LIBRARY_PREFFIX}_sqpgui${DEBUG_SUFFIX}") +SET(SQPGUI_LIBRARY_NAME "${LIBRARY_PREFFIX}_gui${DEBUG_SUFFIX}") SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") -SET(INCLUDE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/include) -SET(UI_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/ui) -SET(RES_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/resources) +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) # -# Compile the library library -# -FILE (GLOB_RECURSE MODULE_SOURCES - ${SOURCES_DIR}/*.c - ${SOURCES_DIR}/*.cpp - ${SOURCES_DIR}/*.h) +# 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}) -# Headers files (.h) -FILE (GLOB_RECURSE PROJECT_HEADERS ${INCLUDE_FOLDER}/*.h) # Ui files FILE (GLOB_RECURSE PROJECT_FORMS ${UI_FOLDER}/*.ui) @@ -32,6 +42,16 @@ 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} ) @@ -40,15 +60,14 @@ QT5_WRAP_UI(UIS_HDRS ${PROJECT_FORMS} ) -include_directories("${CMAKE_CURRENT_BINARY_DIR}") -message(CURRENT INCLUDE : ${CMAKE_CURRENT_BINARY_DIR}) -ADD_LIBRARY(${SQPGUI_LIBRARY_NAME} ${MODULE_SOURCES} ${UIS_HDRS}) +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} ${EXTERN_LIBRARIES}) + +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 @@ -63,8 +82,8 @@ ENDIF() SCIQLOP_SET_TO_PARENT_SCOPE(SQPGUI_LIBRARY_NAME) # Copy extern shared libraries to the lib folder -SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPGUI_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES}) - +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) @@ -76,49 +95,49 @@ 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} ${EXTERN_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} ) + 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 ) + ENDFOREACH( testFile ) - LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) - LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) - LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) + 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 +# +# 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") @@ -127,11 +146,11 @@ SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) #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 +# +# Set the directories with the sources to analyze and propagate the # modification to the parent scope -# -# Source directories to analyze: +# +# 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) 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..6900d5f --- /dev/null +++ b/gui/src/SqpApplication.cpp @@ -0,0 +1,46 @@ +#include "SqpApplication.h" + +#include +#include + +Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") + +class SqpApplication::SqpApplicationPrivate { +public: + SqpApplicationPrivate() {} + ~SqpApplicationPrivate() + { + qCInfo(LOG_SqpApplication()) << tr("Desctruction du SqpApplicationPrivate"); + ; + m_DataSourceControllerThread.quit(); + m_DataSourceControllerThread.wait(); + } + + 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() +{ +} + +void SqpApplication::initialize() +{ +}