##// END OF EJS Templates
Merge pull request 132 from SCIQLOP-Initialisation feature/initializationTestLogVera...
perrinel -
r27:36eb6adb226c merge
parent child
Show More
@@ -0,0 +1,4
1 [Rules]
2 *.debug=false
3 SqpApplication.debug=true
4 DataSourceController.debug=true
@@ -0,0 +1,3
1 # On ignore toutes les règles vera++ pour le fichier spimpl
2 Common/spimpl\.h:\d+:.*
3
@@ -0,0 +1,4
1 # On ignore toutes les règles vera++ pour le fichier spimpl
2
3 .*IPSIS_S04_METHOD.*found: Q_DECLARE_LOGGING_CATEGORY.*
4 .*IPSIS_S04_VARIABLE.*found: impl.*
@@ -1,147 +1,146
1
1
2 ## sciqlop - CMakeLists.txt
2 ## sciqlop - CMakeLists.txt
3 SET(EXECUTABLE_NAME "sciqlop")
3 SET(EXECUTABLE_NAME "sciqlop")
4 SET(SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/)
4 SET(SOURCES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/)
5 SET(INCLUDE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/include)
5 SET(INCLUDE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/include)
6 SET(UI_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/src)
6 SET(UI_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/src)
7 SET(RES_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/resources)
7 SET(RES_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/resources)
8
8
9 #
9 #
10 # Find Qt modules
10 # Find Qt modules
11 #
11 #
12 SCIQLOP_FIND_QT(Core Widgets)
12 SCIQLOP_FIND_QT(Core Widgets)
13
13
14 #
14 #
15 # Find dependent libraries
15 # Find dependent libraries
16 # ========================
16 # ========================
17 find_package(sciqlop-gui)
17 find_package(sciqlop-gui)
18
18
19 message("Librairies inclues dans APP: ${SCIQLOP-GUI_LIBRARIES}")
20 SET(LIBRARIES ${SCIQLOP-GUI_LIBRARIES})
19 SET(LIBRARIES ${SCIQLOP-GUI_LIBRARIES})
21 SET(EXTERN_SHARED_LIBRARIES)
20 SET(EXTERN_SHARED_LIBRARIES)
22
21
23 INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR})
22 INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR})
24
23
25 # Add sqpcore to the list of libraries to use
24 # Add sqpcore to the list of libraries to use
26 list(APPEND LIBRARIES ${SQPCORE_LIBRARY_NAME})
25 list(APPEND LIBRARIES ${SQPCORE_LIBRARY_NAME})
27
26
28 # Include core directory
27 # Include core directory
29 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../core/include")
28 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../core/include")
30
29
31 # Add dependent shared libraries
30 # Add dependent shared libraries
32 list(APPEND SHARED_LIBRARIES ${SQPCORE_SHARED_LIBRARIES})
31 list(APPEND SHARED_LIBRARIES ${SQPCORE_SHARED_LIBRARIES})
33
32
34 # Retrieve the location of the dynamic library to copy it to the output path
33 # Retrieve the location of the dynamic library to copy it to the output path
35 #get_property(sqpcoreLocation TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY LOCATION)
34 #get_property(sqpcoreLocation TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY LOCATION)
36 list(APPEND SHARED_LIBRARIES_FROM_TARGETS ${sqpcoreLocation})
35 list(APPEND SHARED_LIBRARIES_FROM_TARGETS ${sqpcoreLocation})
37
36
38 #
37 #
39 # Compile the application
38 # Compile the application
40 #
39 #
41 FILE (GLOB_RECURSE APPLICATION_SOURCES
40 FILE (GLOB_RECURSE APPLICATION_SOURCES
42 ${SOURCES_DIR}/*.c
41 ${SOURCES_DIR}/*.c
43 ${SOURCES_DIR}/*.cpp
42 ${SOURCES_DIR}/*.cpp
44 ${SOURCES_DIR}/*.h)
43 ${SOURCES_DIR}/*.h)
45
44
46 # Headers files (.h)
45 # Headers files (.h)
47 FILE (GLOB_RECURSE PROJECT_HEADERS ${INCLUDE_FOLDER}/*.h)
46 FILE (GLOB_RECURSE PROJECT_HEADERS ${INCLUDE_FOLDER}/*.h)
48
47
49 # Ui files
48 # Ui files
50 FILE (GLOB_RECURSE PROJECT_FORMS ${UI_FOLDER}/*.ui)
49 FILE (GLOB_RECURSE PROJECT_FORMS ${UI_FOLDER}/*.ui)
51
50
52 # Resources files
51 # Resources files
53 FILE (GLOB_RECURSE PROJECT_RESOURCES ${RES_FOLDER}/*.qrc)
52 FILE (GLOB_RECURSE PROJECT_RESOURCES ${RES_FOLDER}/*.qrc)
54
53
55 # Retrieve resources files
54 # Retrieve resources files
56 FILE (GLOB_RECURSE APPLICATION_RESOURCES ${RES_FOLDER}/*.qrc)
55 FILE (GLOB_RECURSE APPLICATION_RESOURCES ${RES_FOLDER}/*.qrc)
57
56
58 QT5_ADD_RESOURCES(RCC_HDRS ${APPLICATION_RESOURCES} )
57 QT5_ADD_RESOURCES(RCC_HDRS ${APPLICATION_RESOURCES} )
59
58
60 QT5_WRAP_UI(UIS_HDRS
59 QT5_WRAP_UI(UIS_HDRS
61 ${PROJECT_FORMS}
60 ${PROJECT_FORMS}
62 )
61 )
63
62
64
63
65 ADD_EXECUTABLE(${EXECUTABLE_NAME} ${APPLICATION_SOURCES} ${RCC_HDRS} ${UIS_HDRS})
64 ADD_EXECUTABLE(${EXECUTABLE_NAME} ${APPLICATION_SOURCES} ${RCC_HDRS} ${UIS_HDRS})
66 set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD 14)
65 set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD 14)
67 set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
66 set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
68 target_link_libraries(${EXECUTABLE_NAME}
67 target_link_libraries(${EXECUTABLE_NAME}
69 ${LIBRARIES})
68 ${LIBRARIES})
70
69
71 # Link with Qt5 modules
70 # Link with Qt5 modules
72 qt5_use_modules(${EXECUTABLE_NAME} Core Widgets)
71 qt5_use_modules(${EXECUTABLE_NAME} Core Widgets)
73
72
74
73
75 # Add the files to the list of files to be analyzed
74 # Add the files to the list of files to be analyzed
76 LIST(APPEND CHECKSTYLE_INPUT_FILES ${APPLICATION_SOURCES})
75 LIST(APPEND CHECKSTYLE_INPUT_FILES ${APPLICATION_SOURCES})
77 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
76 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
78 # Vera++ exclusion files
77 # Vera++ exclusion files
79 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/path/to/exclusionFiles.tcl)
78 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/path/to/exclusionFiles.tcl)
80 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
79 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
81
80
82 #
81 #
83 # Compile the tests
82 # Compile the tests
84 #
83 #
85 IF(BUILD_TESTS)
84 IF(BUILD_TESTS)
86 INCLUDE_DIRECTORIES(${SOURCES_DIR})
85 INCLUDE_DIRECTORIES(${SOURCES_DIR})
87 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
86 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
88 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
87 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
89 SET( TEST_LIBRARIES ${LIBRARIES})
88 SET( TEST_LIBRARIES ${LIBRARIES})
90
89
91 FOREACH( testFile ${TESTS_SOURCES} )
90 FOREACH( testFile ${TESTS_SOURCES} )
92 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
91 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
93 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
92 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
94
93
95 # Add to the list of sources files all the sources in the same
94 # Add to the list of sources files all the sources in the same
96 # directory that aren't another test
95 # directory that aren't another test
97 FILE (GLOB currentTestSources
96 FILE (GLOB currentTestSources
98 ${testDirectory}/*.c
97 ${testDirectory}/*.c
99 ${testDirectory}/*.cpp
98 ${testDirectory}/*.cpp
100 ${testDirectory}/*.h)
99 ${testDirectory}/*.h)
101 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
100 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
102 LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
101 LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
103
102
104 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
103 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
105 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
104 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
106 qt5_use_modules(${testName} Test)
105 qt5_use_modules(${testName} Test)
107
106
108 ADD_TEST( NAME ${testName} COMMAND ${testName} )
107 ADD_TEST( NAME ${testName} COMMAND ${testName} )
109
108
110 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName})
109 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName})
111 ENDFOREACH( testFile )
110 ENDFOREACH( testFile )
112
111
113 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
112 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
114 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
113 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
115 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
114 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
116 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
115 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
117 ENDIF(BUILD_TESTS)
116 ENDIF(BUILD_TESTS)
118
117
119 #
118 #
120 # Set the files that must be formatted by clang-format.
119 # Set the files that must be formatted by clang-format.
121 #
120 #
122 LIST (APPEND FORMATTING_INPUT_FILES ${APPLICATION_SOURCES})
121 LIST (APPEND FORMATTING_INPUT_FILES ${APPLICATION_SOURCES})
123 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
122 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
124
123
125 #
124 #
126 # Set the directories that doxygen must browse to generate the
125 # Set the directories that doxygen must browse to generate the
127 # documentation.
126 # documentation.
128 #
127 #
129 # Source directories:
128 # Source directories:
130 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
129 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
131 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
130 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
132 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
131 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
133 # Source directories to exclude from the documentation generation
132 # Source directories to exclude from the documentation generation
134 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
133 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
135 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
134 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
136
135
137 #
136 #
138 # Set the directories with the sources to analyze and propagate the
137 # Set the directories with the sources to analyze and propagate the
139 # modification to the parent scope
138 # modification to the parent scope
140 #
139 #
141 # Source directories to analyze:
140 # Source directories to analyze:
142 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
141 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
143 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
142 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
144 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
143 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
145 # Source directories to exclude from the analysis
144 # Source directories to exclude from the analysis
146 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
145 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
147 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
146 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
@@ -1,37 +1,51
1 #
1 #
2 # Sciqlop_modules.cmake
2 # Sciqlop_modules.cmake
3 #
3 #
4 # Set ouptut directories
4 # Set ouptut directories
5 #
5 #
6 SET (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE})
6 SET (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE})
7 SET (LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE})
7 SET (LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE})
8
8 IF (UNIX)
9 SET (CONFIG_OUTPUT_PATH $ENV{HOME}/.config/QtProject)
10 ELSEIF(WIN32)
11 SET (CONFIG_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE}/app/QtProject)
12 ELSE()
13 SET (CONFIG_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE})
14 ENDIF()
9
15
10 #
16 #
11 # Compile the diffents modules
17 # Compile the diffents modules
12 #
18 #
13 set(sciqlop-core_DIR "${CMAKE_SOURCE_DIR}/core/cmake")
19 set(sciqlop-core_DIR "${CMAKE_SOURCE_DIR}/core/cmake")
14 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-core_DIR}")
20 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-core_DIR}")
15 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/core")
21 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/core")
16
22
17 set(sciqlop-gui_DIR "${CMAKE_SOURCE_DIR}/gui/cmake")
23 set(sciqlop-gui_DIR "${CMAKE_SOURCE_DIR}/gui/cmake")
18 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-gui_DIR}")
24 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-gui_DIR}")
19 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/gui")
25 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/gui")
20
26
21 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/app")
27 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/app")
22
28
29 # LOGGER
30 set(QTLOGGING_INI_FILE "${CMAKE_SOURCE_DIR}/config/QtProject/qtlogging.ini")
31 FILE(COPY ${QTLOGGING_INI_FILE} DESTINATION ${CONFIG_OUTPUT_PATH})
32
33
23 #
34 #
24 # Code formatting
35 # Code formatting
25 #
36 #
37 # Vera++ exclusion files
38 LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/formatting/vera-exclusions/exclusions.txt)
39 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
26 INCLUDE ("cmake/sciqlop_formatting.cmake")
40 INCLUDE ("cmake/sciqlop_formatting.cmake")
27
41
28 #
42 #
29 # Documentation generation
43 # Documentation generation
30 #
44 #
31 INCLUDE ("cmake/sciqlop_doxygen.cmake")
45 INCLUDE ("cmake/sciqlop_doxygen.cmake")
32
46
33 #
47 #
34 # Source code analysis
48 # Source code analysis
35 #
49 #
36 INCLUDE ("cmake/sciqlop_code_analysis.cmake")
50 INCLUDE ("cmake/sciqlop_code_analysis.cmake")
37 INCLUDE ("cmake/sciqlop_code_cppcheck.cmake")
51 INCLUDE ("cmake/sciqlop_code_cppcheck.cmake")
@@ -1,90 +1,99
1 #
1 #
2 # sciqlop_params : Define compilation parameters
2 # sciqlop_params : Define compilation parameters
3 #
3 #
4 # Debug or release
4 # Debug or release
5 #
5 #
6 # 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
6 # 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
7 #SET(SCIQLOP_BUILD_TYPE "Release" CACHE STRING "Choose to compile in Debug or Release mode")
7 #SET(SCIQLOP_BUILD_TYPE "Release" CACHE STRING "Choose to compile in Debug or Release mode")
8
8
9 #IF(SCIQLOP_BUILD_TYPE MATCHES "Debug")
9 #IF(SCIQLOP_BUILD_TYPE MATCHES "Debug")
10 # MESSAGE (STATUS "Build in Debug")
10 # MESSAGE (STATUS "Build in Debug")
11 # SET (CMAKE_BUILD_TYPE "Debug")
11 # SET (CMAKE_BUILD_TYPE "Debug")
12 # SET (DEBUG_SUFFIX "d")
12 # SET (DEBUG_SUFFIX "d")
13 #ELSE()
13 #ELSE()
14 # MESSAGE (STATUS "Build in Release")
14 # MESSAGE (STATUS "Build in Release")
15 # SET (CMAKE_BUILD_TYPE "Release")
15 # SET (CMAKE_BUILD_TYPE "Release")
16 # SET (SCIQLOP_BUILD_TYPE "Release")
16 # SET (SCIQLOP_BUILD_TYPE "Release")
17 # SET (DEBUG_SUFFIX "")
17 # SET (DEBUG_SUFFIX "")
18 #ENDIF()
18 #ENDIF()
19
19
20 IF(CMAKE_BUILD_TYPE MATCHES "Debug")
21 SET (CMAKE_BUILD_TYPE "Debug")
22 SET (DEBUG_SUFFIX "d")
23 ELSE()
24 MESSAGE (STATUS "Build in Release")
25 SET (SCIQLOP_BUILD_TYPE "Release")
26 SET (DEBUG_SUFFIX "")
27 ENDIF()
28
20 #
29 #
21 # Need to compile tests?
30 # Need to compile tests?
22 #
31 #
23 OPTION (BUILD_TESTS "Build the tests" OFF)
32 OPTION (BUILD_TESTS "Build the tests" OFF)
24 ENABLE_TESTING(${BUILD_TESTS})
33 ENABLE_TESTING(${BUILD_TESTS})
25
34
26 #
35 #
27 # Path to the folder for sciqlop's extern libraries.
36 # Path to the folder for sciqlop's extern libraries.
28 #
37 #
29 # When looking for an external library in sciqlop, we look to the following
38 # When looking for an external library in sciqlop, we look to the following
30 # folders:
39 # folders:
31 # - The specific folder for the library (generally of the form <LIBRARY>_ROOT_DIR
40 # - The specific folder for the library (generally of the form <LIBRARY>_ROOT_DIR
32 # - The global Sciqlop extern folder
41 # - The global Sciqlop extern folder
33 # - The system folders.
42 # - The system folders.
34 #
43 #
35 # If a dependency is found in the global extern folder or a specific folder for
44 # If a dependency is found in the global extern folder or a specific folder for
36 # the library, then it is installed with the sciqlop libraries. If it is found
45 # the library, then it is installed with the sciqlop libraries. If it is found
37 # in the system folders, it is not. This behavior can be overriden with the
46 # in the system folders, it is not. This behavior can be overriden with the
38 # <LIBRARY>_COPY_SHARED_LIBRARIES flag.
47 # <LIBRARY>_COPY_SHARED_LIBRARIES flag.
39 #
48 #
40 set(SCIQLOP_EXTERN_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/extern"
49 set(SCIQLOP_EXTERN_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/extern"
41 CACHE PATH "Path to the folder for sciqlop's extern libraries")
50 CACHE PATH "Path to the folder for sciqlop's extern libraries")
42 option(SCIQLOP_FORCE_UPDATE_EXT_ROOT_DIR "Force the <LIBRARY>_ROOT_DIR to be updated to the global sciqlop extern folder"
51 option(SCIQLOP_FORCE_UPDATE_EXT_ROOT_DIR "Force the <LIBRARY>_ROOT_DIR to be updated to the global sciqlop extern folder"
43 OFF)
52 OFF)
44
53
45 if (SCIQLOP_FORCE_UPDATE_EXT_ROOT_DIR)
54 if (SCIQLOP_FORCE_UPDATE_EXT_ROOT_DIR)
46 set(libRootDirForceValue FORCE)
55 set(libRootDirForceValue FORCE)
47 else()
56 else()
48 set(libRootDirForceValue)
57 set(libRootDirForceValue)
49 endif()
58 endif()
50
59
51
60
52
61
53 #
62 #
54 # Static or shared libraries
63 # Static or shared libraries
55 #
64 #
56 OPTION (BUILD_SHARED_LIBS "Build the shared libraries" ON)
65 OPTION (BUILD_SHARED_LIBS "Build the shared libraries" ON)
57
66
58 # Generate position independant code (-fPIC)
67 # Generate position independant code (-fPIC)
59 SET(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
68 SET(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
60
69
61 #
70 #
62 # Configure installation directories
71 # Configure installation directories
63 #
72 #
64 IF (UNIX)
73 IF (UNIX)
65 SET(defaultBin "bin")
74 SET(defaultBin "bin")
66 SET(defaultInc "include/sciqlop")
75 SET(defaultInc "include/sciqlop")
67
76
68 # 32 or 64 bits compiler
77 # 32 or 64 bits compiler
69 IF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
78 IF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
70 SET(defaultLib "lib64/sciqlop")
79 SET(defaultLib "lib64/sciqlop")
71 ELSE()
80 ELSE()
72 SET(defaultLib "lib/sciqlop")
81 SET(defaultLib "lib/sciqlop")
73 ENDIF()
82 ENDIF()
74
83
75 SET(defaultDoc "share/docs/sciqlop")
84 SET(defaultDoc "share/docs/sciqlop")
76 ELSE()
85 ELSE()
77 SET(defaultBin "bin")
86 SET(defaultBin "bin")
78 SET(defaultInc "include/sciqlop")
87 SET(defaultInc "include/sciqlop")
79 SET(defaultLib "lib/sciqlop")
88 SET(defaultLib "lib/sciqlop")
80 SET(defaultDoc "docs/sciqlop")
89 SET(defaultDoc "docs/sciqlop")
81 ENDIF()
90 ENDIF()
82
91
83 SET(INSTALL_BINARY_DIR "${defaultBin}" CACHE STRING
92 SET(INSTALL_BINARY_DIR "${defaultBin}" CACHE STRING
84 "Installation directory for binaries")
93 "Installation directory for binaries")
85 SET(INSTALL_LIBRARY_DIR "${defaultLib}" CACHE STRING
94 SET(INSTALL_LIBRARY_DIR "${defaultLib}" CACHE STRING
86 "Installation directory for libraries")
95 "Installation directory for libraries")
87 SET(INSTALL_INCLUDE_DIR "${defaultInc}" CACHE STRING
96 SET(INSTALL_INCLUDE_DIR "${defaultInc}" CACHE STRING
88 "Installation directory for headers")
97 "Installation directory for headers")
89 SET(INSTALL_DOCUMENTATION_DIR "${defaultDoc}" CACHE STRING
98 SET(INSTALL_DOCUMENTATION_DIR "${defaultDoc}" CACHE STRING
90 "Installation directory for documentations")
99 "Installation directory for documentations")
@@ -1,128 +1,128
1
1
2 ## core - CMakeLists.txt
2 ## core - CMakeLists.txt
3 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
3 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
4 SET(SQPCORE_LIBRARY_NAME "${LIBRARY_PREFFIX}_core${DEBUG_SUFFIX}")
4 SET(SQPCORE_LIBRARY_NAME "${LIBRARY_PREFFIX}_core${DEBUG_SUFFIX}")
5 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/")
5 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/")
6 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/")
6 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/")
7
7
8 # Include core directory
8 # Include core directory
9 include_directories("${INCLUDES_DIR}")
9 include_directories("${INCLUDES_DIR}")
10
10
11 # Set a variable to display a warning in the version files.
11 # Set a variable to display a warning in the version files.
12 SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.")
12 SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.")
13 # Generate the version file from the cmake version variables. The version
13 # Generate the version file from the cmake version variables. The version
14 # variables are defined in the cmake/sciqlop_version.cmake file.
14 # variables are defined in the cmake/sciqlop_version.cmake file.
15 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.h.in"
15 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.h.in"
16 "${INCLUDES_DIR}/Version.h")
16 "${INCLUDES_DIR}/Version.h")
17 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.cpp.in"
17 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.cpp.in"
18 "${SOURCES_DIR}/Version.cpp")
18 "${SOURCES_DIR}/Version.cpp")
19
19
20 #
20 #
21 # Find Qt modules
21 # Find Qt modules
22 #
22 #
23 SCIQLOP_FIND_QT(Core)
23 SCIQLOP_FIND_QT(Core)
24
24
25 #
25 #
26 # Compile the library library
26 # Compile the library library
27 #
27 #
28 FILE (GLOB_RECURSE MODULE_SOURCES
28 FILE (GLOB_RECURSE MODULE_SOURCES
29 ${INCLUDES_DIR}/*.h
29 ${INCLUDES_DIR}/*.h
30 ${SOURCES_DIR}/*.c
30 ${SOURCES_DIR}/*.c
31 ${SOURCES_DIR}/*.cpp
31 ${SOURCES_DIR}/*.cpp
32 ${SOURCES_DIR}/*.h)
32 ${SOURCES_DIR}/*.h)
33
33
34 ADD_LIBRARY(${SQPCORE_LIBRARY_NAME} ${MODULE_SOURCES})
34 ADD_LIBRARY(${SQPCORE_LIBRARY_NAME} ${MODULE_SOURCES})
35 set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
35 set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
36 set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
36 set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
37 TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME})
37 TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME})
38 qt5_use_modules(${SQPCORE_LIBRARY_NAME} Core)
38 qt5_use_modules(${SQPCORE_LIBRARY_NAME} Core)
39
39
40 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
40 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
41 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
41 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
42 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
42 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
43 IF(BUILD_SHARED_LIBS)
43 IF(BUILD_SHARED_LIBS)
44 SET_TARGET_PROPERTIES(${SQPCORE_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
44 SET_TARGET_PROPERTIES(${SQPCORE_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
45 ELSE()
45 ELSE()
46 TARGET_COMPILE_DEFINITIONS(${SQPCORE_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
46 TARGET_COMPILE_DEFINITIONS(${SQPCORE_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
47 ENDIF()
47 ENDIF()
48
48
49 # Set the variable to parent scope so that the other projects can copy the
49 # Set the variable to parent scope so that the other projects can copy the
50 # dependent shared libraries
50 # dependent shared libraries
51 SCIQLOP_SET_TO_PARENT_SCOPE(SQPCORE_LIBRARY_NAME)
51 SCIQLOP_SET_TO_PARENT_SCOPE(SQPCORE_LIBRARY_NAME)
52
52
53 # Copy extern shared libraries to the lib folder
53 # Copy extern shared libraries to the lib folder
54 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPCORE_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
54 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPCORE_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
55
55
56 # Add the files to the list of files to be analyzed
56 # Add the files to the list of files to be analyzed
57 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
57 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
58 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
58 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
59 # Vera++ exclusion files
59 # Vera++ exclusion files
60 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/path/to/exclusionFiles.tcl)
60 LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
61 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
61 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
62
62
63 #
63 #
64 # Compile the tests
64 # Compile the tests
65 #
65 #
66 IF(BUILD_TESTS)
66 IF(BUILD_TESTS)
67 INCLUDE_DIRECTORIES(${SOURCES_DIR})
67 INCLUDE_DIRECTORIES(${SOURCES_DIR})
68 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
68 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
69 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
69 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
70 SET( TEST_LIBRARIES ${SQPCORE_LIBRARY_NAME})
70 SET( TEST_LIBRARIES ${SQPCORE_LIBRARY_NAME})
71
71
72 FOREACH( testFile ${TESTS_SOURCES} )
72 FOREACH( testFile ${TESTS_SOURCES} )
73 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
73 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
74 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
74 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
75
75
76 # Add to the list of sources files all the sources in the same
76 # Add to the list of sources files all the sources in the same
77 # directory that aren't another test
77 # directory that aren't another test
78 FILE (GLOB currentTestSources
78 FILE (GLOB currentTestSources
79 ${testDirectory}/*.c
79 ${testDirectory}/*.c
80 ${testDirectory}/*.cpp
80 ${testDirectory}/*.cpp
81 ${testDirectory}/*.h)
81 ${testDirectory}/*.h)
82 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
82 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
83 LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
83 LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
84
84
85 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
85 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
86 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
86 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
87 qt5_use_modules(${testName} Test)
87 qt5_use_modules(${testName} Test)
88
88
89 ADD_TEST( NAME ${testName} COMMAND ${testName} )
89 ADD_TEST( NAME ${testName} COMMAND ${testName} )
90
90
91 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
91 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
92 ENDFOREACH( testFile )
92 ENDFOREACH( testFile )
93
93
94 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
94 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
95 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
95 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
96 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
96 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
97 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
97 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
98 ENDIF(BUILD_TESTS)
98 ENDIF(BUILD_TESTS)
99
99
100 #
100 #
101 # Set the files that must be formatted by clang-format.
101 # Set the files that must be formatted by clang-format.
102 #
102 #
103 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
103 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
104 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
104 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
105
105
106 #
106 #
107 # Set the directories that doxygen must browse to generate the
107 # Set the directories that doxygen must browse to generate the
108 # documentation.
108 # documentation.
109 #
109 #
110 # Source directories:
110 # Source directories:
111 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
111 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
112 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
112 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
113 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
113 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
114 # Source directories to exclude from the documentation generation
114 # Source directories to exclude from the documentation generation
115 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
115 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
116 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
116 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
117
117
118 #
118 #
119 # Set the directories with the sources to analyze and propagate the
119 # Set the directories with the sources to analyze and propagate the
120 # modification to the parent scope
120 # modification to the parent scope
121 #
121 #
122 # Source directories to analyze:
122 # Source directories to analyze:
123 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
123 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
124 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
124 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
125 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
125 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
126 # Source directories to exclude from the analysis
126 # Source directories to exclude from the analysis
127 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
127 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
128 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
128 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
@@ -1,461 +1,460
1 /*
1 /*
2 ====================================================================
2 ====================================================================
3 A Smart Pointer to IMPLementation (i.e. Smart PIMPL or just SPIMPL).
3 A Smart Pointer to IMPLementation (i.e. Smart PIMPL or just SPIMPL).
4 ====================================================================
4 ====================================================================
5
5
6 Version: 1.1
6 Version: 1.1
7
7
8 Latest version:
8 Latest version:
9 https://github.com/oliora/samples/blob/master/spimpl.h
9 https://github.com/oliora/samples/blob/master/spimpl.h
10 Rationale and description:
10 Rationale and description:
11 http://oliora.github.io/2015/12/29/pimpl-and-rule-of-zero.html
11 http://oliora.github.io/2015/12/29/pimpl-and-rule-of-zero.html
12
12
13 Copyright (c) 2015 Andrey Upadyshev (oliora@gmail.com)
13 Copyright (c) 2015 Andrey Upadyshev (oliora@gmail.com)
14
14
15 Distributed under the Boost Software License, Version 1.0.
15 Distributed under the Boost Software License, Version 1.0.
16 See http://www.boost.org/LICENSE_1_0.txt
16 See http://www.boost.org/LICENSE_1_0.txt
17
17
18 Changes history
18 Changes history
19 ---------------
19 ---------------
20 v1.1:
20 v1.1:
21 - auto_ptr support is disabled by default for C++17 compatibility
21 - auto_ptr support is disabled by default for C++17 compatibility
22 v1.0:
22 v1.0:
23 - Released
23 - Released
24 */
24 */
25
25
26 #ifndef SPIMPL_H_
26 #ifndef SPIMPL_H_
27 #define SPIMPL_H_
27 #define SPIMPL_H_
28
28
29 #include <cassert>
29 #include <cassert>
30 #include <memory>
30 #include <memory>
31 #include <type_traits>
31 #include <type_traits>
32
32
33
34 #if defined _MSC_VER && _MSC_VER < 1900 // MS Visual Studio before VS2015
33 #if defined _MSC_VER && _MSC_VER < 1900 // MS Visual Studio before VS2015
35 #define SPIMPL_NO_CPP11_NOEXCEPT
34 #define SPIMPL_NO_CPP11_NOEXCEPT
36 #define SPIMPL_NO_CPP11_CONSTEXPR
35 #define SPIMPL_NO_CPP11_CONSTEXPR
37 #define SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC
36 #define SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC
38 #endif
37 #endif
39
38
40 #if !defined SPIMPL_NO_CPP11_NOEXCEPT
39 #if !defined SPIMPL_NO_CPP11_NOEXCEPT
41 #define SPIMPL_NOEXCEPT noexcept
40 #define SPIMPL_NOEXCEPT noexcept
42 #else
41 #else
43 #define SPIMPL_NOEXCEPT
42 #define SPIMPL_NOEXCEPT
44 #endif
43 #endif
45
44
46 #if !defined SPIMPL_NO_CPP11_CONSTEXPR
45 #if !defined SPIMPL_NO_CPP11_CONSTEXPR
47 #define SPIMPL_CONSTEXPR constexpr
46 #define SPIMPL_CONSTEXPR constexpr
48 #else
47 #else
49 #define SPIMPL_CONSTEXPR
48 #define SPIMPL_CONSTEXPR
50 #endif
49 #endif
51
50
52 // define SPIMPL_HAS_AUTO_PTR to enable constructor and assignment operator that accept
51 // define SPIMPL_HAS_AUTO_PTR to enable constructor and assignment operator that accept
53 // std::auto_ptr
52 // std::auto_ptr
54 // TODO: auto detect std::auto_ptr support
53 // TODO: auto detect std::auto_ptr support
55
54
56
55
57 namespace spimpl {
56 namespace spimpl {
58 namespace details {
57 namespace details {
59 template <class T>
58 template <class T>
60 T *default_copy(T *src)
59 T *default_copy(T *src)
61 {
60 {
62 static_assert(sizeof(T) > 0, "default_copy cannot copy incomplete type");
61 static_assert(sizeof(T) > 0, "default_copy cannot copy incomplete type");
63 static_assert(!std::is_void<T>::value, "default_copy cannot copy incomplete type");
62 static_assert(!std::is_void<T>::value, "default_copy cannot copy incomplete type");
64 return new T(*src);
63 return new T(*src);
65 }
64 }
66
65
67 template <class T>
66 template <class T>
68 void default_delete(T *p) SPIMPL_NOEXCEPT
67 void default_delete(T *p) SPIMPL_NOEXCEPT
69 {
68 {
70 static_assert(sizeof(T) > 0, "default_delete cannot delete incomplete type");
69 static_assert(sizeof(T) > 0, "default_delete cannot delete incomplete type");
71 static_assert(!std::is_void<T>::value, "default_delete cannot delete incomplete type");
70 static_assert(!std::is_void<T>::value, "default_delete cannot delete incomplete type");
72 delete p;
71 delete p;
73 }
72 }
74
73
75 template <class T>
74 template <class T>
76 struct default_deleter {
75 struct default_deleter {
77 using type = void (*)(T *);
76 using type = void (*)(T *);
78 };
77 };
79
78
80 template <class T>
79 template <class T>
81 using default_deleter_t = typename default_deleter<T>::type;
80 using default_deleter_t = typename default_deleter<T>::type;
82
81
83 template <class T>
82 template <class T>
84 struct default_copier {
83 struct default_copier {
85 using type = T *(*)(T *);
84 using type = T *(*)(T *);
86 };
85 };
87
86
88 template <class T>
87 template <class T>
89 using default_copier_t = typename default_copier<T>::type;
88 using default_copier_t = typename default_copier<T>::type;
90
89
91 template <class T, class D, class C>
90 template <class T, class D, class C>
92 struct is_default_manageable
91 struct is_default_manageable
93 : public std::integral_constant<bool, std::is_same<D, default_deleter_t<T> >::value
92 : public std::integral_constant<bool, std::is_same<D, default_deleter_t<T> >::value
94 && std::is_same<C, default_copier_t<T> >::value> {
93 && std::is_same<C, default_copier_t<T> >::value> {
95 };
94 };
96 }
95 }
97
96
98
97
99 template <class T, class Deleter = details::default_deleter_t<T>,
98 template <class T, class Deleter = details::default_deleter_t<T>,
100 class Copier = details::default_copier_t<T> >
99 class Copier = details::default_copier_t<T> >
101 class impl_ptr {
100 class impl_ptr {
102 private:
101 private:
103 static_assert(!std::is_array<T>::value,
102 static_assert(!std::is_array<T>::value,
104 "impl_ptr specialization for arrays is not implemented");
103 "impl_ptr specialization for arrays is not implemented");
105 struct dummy_t_ {
104 struct dummy_t_ {
106 int dummy__;
105 int dummy__;
107 };
106 };
108
107
109 public:
108 public:
110 using pointer = T *;
109 using pointer = T *;
111 using element_type = T;
110 using element_type = T;
112 using copier_type = typename std::decay<Copier>::type;
111 using copier_type = typename std::decay<Copier>::type;
113 using deleter_type = typename std::decay<Deleter>::type;
112 using deleter_type = typename std::decay<Deleter>::type;
114 using unique_ptr_type = std::unique_ptr<T, deleter_type>;
113 using unique_ptr_type = std::unique_ptr<T, deleter_type>;
115 using is_default_manageable = details::is_default_manageable<T, deleter_type, copier_type>;
114 using is_default_manageable = details::is_default_manageable<T, deleter_type, copier_type>;
116
115
117 SPIMPL_CONSTEXPR impl_ptr() SPIMPL_NOEXCEPT : ptr_(nullptr, deleter_type{}),
116 SPIMPL_CONSTEXPR impl_ptr() SPIMPL_NOEXCEPT : ptr_(nullptr, deleter_type{}),
118 copier_(copier_type{})
117 copier_(copier_type{})
119 {
118 {
120 }
119 }
121
120
122 SPIMPL_CONSTEXPR impl_ptr(std::nullptr_t) SPIMPL_NOEXCEPT : impl_ptr() {}
121 SPIMPL_CONSTEXPR impl_ptr(std::nullptr_t) SPIMPL_NOEXCEPT : impl_ptr() {}
123
122
124 template <class D, class C>
123 template <class D, class C>
125 impl_ptr(pointer p, D &&d, C &&c,
124 impl_ptr(pointer p, D &&d, C &&c,
126 typename std::enable_if<std::is_convertible<D, deleter_type>::value
125 typename std::enable_if<std::is_convertible<D, deleter_type>::value
127 && std::is_convertible<C, copier_type>::value,
126 && std::is_convertible<C, copier_type>::value,
128 dummy_t_>::type
127 dummy_t_>::type
129 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(p), std::forward<D>(d)),
128 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(p), std::forward<D>(d)),
130 copier_(std::forward<C>(c))
129 copier_(std::forward<C>(c))
131 {
130 {
132 }
131 }
133
132
134 template <class U>
133 template <class U>
135 impl_ptr(U *u, typename std::enable_if<std::is_convertible<U *, pointer>::value
134 impl_ptr(U *u, typename std::enable_if<std::is_convertible<U *, pointer>::value
136 && is_default_manageable::value,
135 && is_default_manageable::value,
137 dummy_t_>::type
136 dummy_t_>::type
138 = dummy_t_()) SPIMPL_NOEXCEPT
137 = dummy_t_()) SPIMPL_NOEXCEPT
139 : impl_ptr(u, &details::default_delete<T>, &details::default_copy<T>)
138 : impl_ptr(u, &details::default_delete<T>, &details::default_copy<T>)
140 {
139 {
141 }
140 }
142
141
143 impl_ptr(const impl_ptr &r) : impl_ptr(r.clone()) {}
142 impl_ptr(const impl_ptr &r) : impl_ptr(r.clone()) {}
144
143
145 #ifndef SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC
144 #ifndef SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC
146 impl_ptr(impl_ptr &&r) SPIMPL_NOEXCEPT = default;
145 impl_ptr(impl_ptr &&r) SPIMPL_NOEXCEPT = default;
147 #else
146 #else
148 impl_ptr(impl_ptr &&r) SPIMPL_NOEXCEPT : ptr_(std::move(r.ptr_)), copier_(std::move(r.copier_))
147 impl_ptr(impl_ptr &&r) SPIMPL_NOEXCEPT : ptr_(std::move(r.ptr_)), copier_(std::move(r.copier_))
149 {
148 {
150 }
149 }
151 #endif
150 #endif
152
151
153 #ifdef SPIMPL_HAS_AUTO_PTR
152 #ifdef SPIMPL_HAS_AUTO_PTR
154 template <class U>
153 template <class U>
155 impl_ptr(std::auto_ptr<U> &&u, typename std::enable_if<std::is_convertible<U *, pointer>::value
154 impl_ptr(std::auto_ptr<U> &&u, typename std::enable_if<std::is_convertible<U *, pointer>::value
156 && is_default_manageable::value,
155 && is_default_manageable::value,
157 dummy_t_>::type
156 dummy_t_>::type
158 = dummy_t_()) SPIMPL_NOEXCEPT
157 = dummy_t_()) SPIMPL_NOEXCEPT
159 : ptr_(u.release(), &details::default_delete<T>),
158 : ptr_(u.release(), &details::default_delete<T>),
160 copier_(&details::default_copy<T>)
159 copier_(&details::default_copy<T>)
161 {
160 {
162 }
161 }
163 #endif
162 #endif
164
163
165 template <class U>
164 template <class U>
166 impl_ptr(std::unique_ptr<U> &&u,
165 impl_ptr(std::unique_ptr<U> &&u,
167 typename std::enable_if<std::is_convertible<U *, pointer>::value
166 typename std::enable_if<std::is_convertible<U *, pointer>::value
168 && is_default_manageable::value,
167 && is_default_manageable::value,
169 dummy_t_>::type
168 dummy_t_>::type
170 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(u.release(), &details::default_delete<T>),
169 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(u.release(), &details::default_delete<T>),
171 copier_(&details::default_copy<T>)
170 copier_(&details::default_copy<T>)
172 {
171 {
173 }
172 }
174
173
175 template <class U, class D, class C>
174 template <class U, class D, class C>
176 impl_ptr(std::unique_ptr<U, D> &&u, C &&c,
175 impl_ptr(std::unique_ptr<U, D> &&u, C &&c,
177 typename std::enable_if<std::is_convertible<U *, pointer>::value
176 typename std::enable_if<std::is_convertible<U *, pointer>::value
178 && std::is_convertible<D, deleter_type>::value
177 && std::is_convertible<D, deleter_type>::value
179 && std::is_convertible<C, copier_type>::value,
178 && std::is_convertible<C, copier_type>::value,
180 dummy_t_>::type
179 dummy_t_>::type
181 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(u)),
180 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(u)),
182 copier_(std::forward<C>(c))
181 copier_(std::forward<C>(c))
183 {
182 {
184 }
183 }
185
184
186 template <class U, class D, class C>
185 template <class U, class D, class C>
187 impl_ptr(impl_ptr<U, D, C> &&u,
186 impl_ptr(impl_ptr<U, D, C> &&u,
188 typename std::enable_if<std::is_convertible<U *, pointer>::value
187 typename std::enable_if<std::is_convertible<U *, pointer>::value
189 && std::is_convertible<D, deleter_type>::value
188 && std::is_convertible<D, deleter_type>::value
190 && std::is_convertible<C, copier_type>::value,
189 && std::is_convertible<C, copier_type>::value,
191 dummy_t_>::type
190 dummy_t_>::type
192 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(u.ptr_)),
191 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(u.ptr_)),
193 copier_(std::move(u.copier_))
192 copier_(std::move(u.copier_))
194 {
193 {
195 }
194 }
196
195
197 impl_ptr &operator=(const impl_ptr &r)
196 impl_ptr &operator=(const impl_ptr &r)
198 {
197 {
199 if (this == &r)
198 if (this == &r)
200 return *this;
199 return *this;
201
200
202 return operator=(r.clone());
201 return operator=(r.clone());
203 }
202 }
204
203
205 #ifndef SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC
204 #ifndef SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC
206 impl_ptr &operator=(impl_ptr &&r) SPIMPL_NOEXCEPT = default;
205 impl_ptr &operator=(impl_ptr &&r) SPIMPL_NOEXCEPT = default;
207 #else
206 #else
208 impl_ptr &operator=(impl_ptr &&r) SPIMPL_NOEXCEPT
207 impl_ptr &operator=(impl_ptr &&r) SPIMPL_NOEXCEPT
209 {
208 {
210 ptr_ = std::move(r.ptr_);
209 ptr_ = std::move(r.ptr_);
211 copier_ = std::move(r.copier_);
210 copier_ = std::move(r.copier_);
212 return *this;
211 return *this;
213 }
212 }
214 #endif
213 #endif
215
214
216 template <class U, class D, class C>
215 template <class U, class D, class C>
217 typename std::enable_if<std::is_convertible<U *, pointer>::value
216 typename std::enable_if<std::is_convertible<U *, pointer>::value
218 && std::is_convertible<D, deleter_type>::value
217 && std::is_convertible<D, deleter_type>::value
219 && std::is_convertible<C, copier_type>::value,
218 && std::is_convertible<C, copier_type>::value,
220 impl_ptr &>::type
219 impl_ptr &>::type
221 operator=(impl_ptr<U, D, C> &&u) SPIMPL_NOEXCEPT
220 operator=(impl_ptr<U, D, C> &&u) SPIMPL_NOEXCEPT
222 {
221 {
223 ptr_ = std::move(u.ptr_);
222 ptr_ = std::move(u.ptr_);
224 copier_ = std::move(u.copier_);
223 copier_ = std::move(u.copier_);
225 return *this;
224 return *this;
226 }
225 }
227
226
228 template <class U, class D, class C>
227 template <class U, class D, class C>
229 typename std::enable_if<std::is_convertible<U *, pointer>::value
228 typename std::enable_if<std::is_convertible<U *, pointer>::value
230 && std::is_convertible<D, deleter_type>::value
229 && std::is_convertible<D, deleter_type>::value
231 && std::is_convertible<C, copier_type>::value,
230 && std::is_convertible<C, copier_type>::value,
232 impl_ptr &>::type
231 impl_ptr &>::type
233 operator=(const impl_ptr<U, D, C> &u)
232 operator=(const impl_ptr<U, D, C> &u)
234 {
233 {
235 return operator=(u.clone());
234 return operator=(u.clone());
236 }
235 }
237
236
238 //
237 //
239
238
240 #ifdef SPIMPL_HAS_AUTO_PTR
239 #ifdef SPIMPL_HAS_AUTO_PTR
241 template <class U>
240 template <class U>
242 typename std::enable_if<std::is_convertible<U *, pointer>::value
241 typename std::enable_if<std::is_convertible<U *, pointer>::value
243 && is_default_manageable::value,
242 && is_default_manageable::value,
244 impl_ptr &>::type
243 impl_ptr &>::type
245 operator=(std::auto_ptr<U> &&u) SPIMPL_NOEXCEPT
244 operator=(std::auto_ptr<U> &&u) SPIMPL_NOEXCEPT
246 {
245 {
247 return operator=(impl_ptr(std::move(u)));
246 return operator=(impl_ptr(std::move(u)));
248 }
247 }
249 #endif
248 #endif
250
249
251 template <class U>
250 template <class U>
252 typename std::enable_if<std::is_convertible<U *, pointer>::value
251 typename std::enable_if<std::is_convertible<U *, pointer>::value
253 && is_default_manageable::value,
252 && is_default_manageable::value,
254 impl_ptr &>::type
253 impl_ptr &>::type
255 operator=(std::unique_ptr<U> &&u) SPIMPL_NOEXCEPT
254 operator=(std::unique_ptr<U> &&u) SPIMPL_NOEXCEPT
256 {
255 {
257 return operator=(impl_ptr(std::move(u)));
256 return operator=(impl_ptr(std::move(u)));
258 }
257 }
259
258
260 impl_ptr clone() const
259 impl_ptr clone() const
261 {
260 {
262 return impl_ptr(ptr_ ? copier_(ptr_.get()) : nullptr, ptr_.get_deleter(), copier_);
261 return impl_ptr(ptr_ ? copier_(ptr_.get()) : nullptr, ptr_.get_deleter(), copier_);
263 }
262 }
264
263
265 typename std::remove_reference<T>::type &operator*() const { return *ptr_; }
264 typename std::remove_reference<T>::type &operator*() const { return *ptr_; }
266 pointer operator->() const SPIMPL_NOEXCEPT { return get(); }
265 pointer operator->() const SPIMPL_NOEXCEPT { return get(); }
267 pointer get() const SPIMPL_NOEXCEPT { return ptr_.get(); }
266 pointer get() const SPIMPL_NOEXCEPT { return ptr_.get(); }
268
267
269 void swap(impl_ptr &u) SPIMPL_NOEXCEPT
268 void swap(impl_ptr &u) SPIMPL_NOEXCEPT
270 {
269 {
271 using std::swap;
270 using std::swap;
272 ptr_.swap(u.ptr_);
271 ptr_.swap(u.ptr_);
273 swap(copier_, u.copier_);
272 swap(copier_, u.copier_);
274 }
273 }
275
274
276 pointer release() SPIMPL_NOEXCEPT { return ptr_.release(); }
275 pointer release() SPIMPL_NOEXCEPT { return ptr_.release(); }
277
276
278 unique_ptr_type release_unique() SPIMPL_NOEXCEPT { return std::move(ptr_); }
277 unique_ptr_type release_unique() SPIMPL_NOEXCEPT { return std::move(ptr_); }
279
278
280 explicit operator bool() const SPIMPL_NOEXCEPT { return static_cast<bool>(ptr_); }
279 explicit operator bool() const SPIMPL_NOEXCEPT { return static_cast<bool>(ptr_); }
281
280
282 typename std::remove_reference<deleter_type>::type &get_deleter() SPIMPL_NOEXCEPT
281 typename std::remove_reference<deleter_type>::type &get_deleter() SPIMPL_NOEXCEPT
283 {
282 {
284 return ptr_.get_deleter();
283 return ptr_.get_deleter();
285 }
284 }
286 const typename std::remove_reference<deleter_type>::type &get_deleter() const SPIMPL_NOEXCEPT
285 const typename std::remove_reference<deleter_type>::type &get_deleter() const SPIMPL_NOEXCEPT
287 {
286 {
288 return ptr_.get_deleter();
287 return ptr_.get_deleter();
289 }
288 }
290
289
291 typename std::remove_reference<copier_type>::type &get_copier() SPIMPL_NOEXCEPT
290 typename std::remove_reference<copier_type>::type &get_copier() SPIMPL_NOEXCEPT
292 {
291 {
293 return copier_;
292 return copier_;
294 }
293 }
295 const typename std::remove_reference<copier_type>::type &get_copier() const SPIMPL_NOEXCEPT
294 const typename std::remove_reference<copier_type>::type &get_copier() const SPIMPL_NOEXCEPT
296 {
295 {
297 return copier_;
296 return copier_;
298 }
297 }
299
298
300 private:
299 private:
301 unique_ptr_type ptr_;
300 unique_ptr_type ptr_;
302 copier_type copier_;
301 copier_type copier_;
303 };
302 };
304
303
305
304
306 template <class T, class D, class C>
305 template <class T, class D, class C>
307 inline void swap(impl_ptr<T, D, C> &l, impl_ptr<T, D, C> &r) SPIMPL_NOEXCEPT
306 inline void swap(impl_ptr<T, D, C> &l, impl_ptr<T, D, C> &r) SPIMPL_NOEXCEPT
308 {
307 {
309 l.swap(r);
308 l.swap(r);
310 }
309 }
311
310
312
311
313 template <class T1, class D1, class C1, class T2, class D2, class C2>
312 template <class T1, class D1, class C1, class T2, class D2, class C2>
314 inline bool operator==(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
313 inline bool operator==(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
315 {
314 {
316 return l.get() == r.get();
315 return l.get() == r.get();
317 }
316 }
318
317
319 template <class T1, class D1, class C1, class T2, class D2, class C2>
318 template <class T1, class D1, class C1, class T2, class D2, class C2>
320 inline bool operator!=(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
319 inline bool operator!=(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
321 {
320 {
322 return !(l == r);
321 return !(l == r);
323 }
322 }
324
323
325 template <class T1, class D1, class C1, class T2, class D2, class C2>
324 template <class T1, class D1, class C1, class T2, class D2, class C2>
326 inline bool operator<(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
325 inline bool operator<(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
327 {
326 {
328 using P1 = typename impl_ptr<T1, D1, C1>::pointer;
327 using P1 = typename impl_ptr<T1, D1, C1>::pointer;
329 using P2 = typename impl_ptr<T2, D2, C2>::pointer;
328 using P2 = typename impl_ptr<T2, D2, C2>::pointer;
330 using CT = typename std::common_type<P1, P2>::type;
329 using CT = typename std::common_type<P1, P2>::type;
331 return std::less<CT>()(l.get(), r.get());
330 return std::less<CT>()(l.get(), r.get());
332 }
331 }
333
332
334 template <class T1, class D1, class C1, class T2, class D2, class C2>
333 template <class T1, class D1, class C1, class T2, class D2, class C2>
335 inline bool operator>(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
334 inline bool operator>(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
336 {
335 {
337 return r < l;
336 return r < l;
338 }
337 }
339
338
340 template <class T1, class D1, class C1, class T2, class D2, class C2>
339 template <class T1, class D1, class C1, class T2, class D2, class C2>
341 inline bool operator<=(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
340 inline bool operator<=(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
342 {
341 {
343 return !(r < l);
342 return !(r < l);
344 }
343 }
345
344
346 template <class T1, class D1, class C1, class T2, class D2, class C2>
345 template <class T1, class D1, class C1, class T2, class D2, class C2>
347 inline bool operator>=(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
346 inline bool operator>=(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
348 {
347 {
349 return !(l < r);
348 return !(l < r);
350 }
349 }
351
350
352 template <class T, class D, class C>
351 template <class T, class D, class C>
353 inline bool operator==(const impl_ptr<T, D, C> &p, std::nullptr_t) SPIMPL_NOEXCEPT
352 inline bool operator==(const impl_ptr<T, D, C> &p, std::nullptr_t) SPIMPL_NOEXCEPT
354 {
353 {
355 return !p;
354 return !p;
356 }
355 }
357
356
358 template <class T, class D, class C>
357 template <class T, class D, class C>
359 inline bool operator==(std::nullptr_t, const impl_ptr<T, D, C> &p) SPIMPL_NOEXCEPT
358 inline bool operator==(std::nullptr_t, const impl_ptr<T, D, C> &p) SPIMPL_NOEXCEPT
360 {
359 {
361 return !p;
360 return !p;
362 }
361 }
363
362
364 template <class T, class D, class C>
363 template <class T, class D, class C>
365 inline bool operator!=(const impl_ptr<T, D, C> &p, std::nullptr_t) SPIMPL_NOEXCEPT
364 inline bool operator!=(const impl_ptr<T, D, C> &p, std::nullptr_t) SPIMPL_NOEXCEPT
366 {
365 {
367 return static_cast<bool>(p);
366 return static_cast<bool>(p);
368 }
367 }
369
368
370 template <class T, class D, class C>
369 template <class T, class D, class C>
371 inline bool operator!=(std::nullptr_t, const impl_ptr<T, D, C> &p) SPIMPL_NOEXCEPT
370 inline bool operator!=(std::nullptr_t, const impl_ptr<T, D, C> &p) SPIMPL_NOEXCEPT
372 {
371 {
373 return static_cast<bool>(p);
372 return static_cast<bool>(p);
374 }
373 }
375
374
376 template <class T, class D, class C>
375 template <class T, class D, class C>
377 inline bool operator<(const impl_ptr<T, D, C> &l, std::nullptr_t)
376 inline bool operator<(const impl_ptr<T, D, C> &l, std::nullptr_t)
378 {
377 {
379 using P = typename impl_ptr<T, D, C>::pointer;
378 using P = typename impl_ptr<T, D, C>::pointer;
380 return std::less<P>()(l.get(), nullptr);
379 return std::less<P>()(l.get(), nullptr);
381 }
380 }
382
381
383 template <class T, class D, class C>
382 template <class T, class D, class C>
384 inline bool operator<(std::nullptr_t, const impl_ptr<T, D, C> &p)
383 inline bool operator<(std::nullptr_t, const impl_ptr<T, D, C> &p)
385 {
384 {
386 using P = typename impl_ptr<T, D, C>::pointer;
385 using P = typename impl_ptr<T, D, C>::pointer;
387 return std::less<P>()(nullptr, p.get());
386 return std::less<P>()(nullptr, p.get());
388 }
387 }
389
388
390 template <class T, class D, class C>
389 template <class T, class D, class C>
391 inline bool operator>(const impl_ptr<T, D, C> &p, std::nullptr_t)
390 inline bool operator>(const impl_ptr<T, D, C> &p, std::nullptr_t)
392 {
391 {
393 return nullptr < p;
392 return nullptr < p;
394 }
393 }
395
394
396 template <class T, class D, class C>
395 template <class T, class D, class C>
397 inline bool operator>(std::nullptr_t, const impl_ptr<T, D, C> &p)
396 inline bool operator>(std::nullptr_t, const impl_ptr<T, D, C> &p)
398 {
397 {
399 return p < nullptr;
398 return p < nullptr;
400 }
399 }
401
400
402 template <class T, class D, class C>
401 template <class T, class D, class C>
403 inline bool operator<=(const impl_ptr<T, D, C> &p, std::nullptr_t)
402 inline bool operator<=(const impl_ptr<T, D, C> &p, std::nullptr_t)
404 {
403 {
405 return !(nullptr < p);
404 return !(nullptr < p);
406 }
405 }
407
406
408 template <class T, class D, class C>
407 template <class T, class D, class C>
409 inline bool operator<=(std::nullptr_t, const impl_ptr<T, D, C> &p)
408 inline bool operator<=(std::nullptr_t, const impl_ptr<T, D, C> &p)
410 {
409 {
411 return !(p < nullptr);
410 return !(p < nullptr);
412 }
411 }
413
412
414 template <class T, class D, class C>
413 template <class T, class D, class C>
415 inline bool operator>=(const impl_ptr<T, D, C> &p, std::nullptr_t)
414 inline bool operator>=(const impl_ptr<T, D, C> &p, std::nullptr_t)
416 {
415 {
417 return !(p < nullptr);
416 return !(p < nullptr);
418 }
417 }
419
418
420 template <class T, class D, class C>
419 template <class T, class D, class C>
421 inline bool operator>=(std::nullptr_t, const impl_ptr<T, D, C> &p)
420 inline bool operator>=(std::nullptr_t, const impl_ptr<T, D, C> &p)
422 {
421 {
423 return !(nullptr < p);
422 return !(nullptr < p);
424 }
423 }
425
424
426
425
427 template <class T, class... Args>
426 template <class T, class... Args>
428 inline impl_ptr<T> make_impl(Args &&... args)
427 inline impl_ptr<T> make_impl(Args &&... args)
429 {
428 {
430 return impl_ptr<T>(new T(std::forward<Args>(args)...), &details::default_delete<T>,
429 return impl_ptr<T>(new T(std::forward<Args>(args)...), &details::default_delete<T>,
431 &details::default_copy<T>);
430 &details::default_copy<T>);
432 }
431 }
433
432
434
433
435 // Helpers to manage unique impl, stored in std::unique_ptr
434 // Helpers to manage unique impl, stored in std::unique_ptr
436
435
437 template <class T, class Deleter = void (*)(T *)>
436 template <class T, class Deleter = void (*)(T *)>
438 using unique_impl_ptr = std::unique_ptr<T, Deleter>;
437 using unique_impl_ptr = std::unique_ptr<T, Deleter>;
439
438
440 template <class T, class... Args>
439 template <class T, class... Args>
441 inline unique_impl_ptr<T> make_unique_impl(Args &&... args)
440 inline unique_impl_ptr<T> make_unique_impl(Args &&... args)
442 {
441 {
443 static_assert(!std::is_array<T>::value, "unique_impl_ptr does not support arrays");
442 static_assert(!std::is_array<T>::value, "unique_impl_ptr does not support arrays");
444 return unique_impl_ptr<T>(new T(std::forward<Args>(args)...), &details::default_delete<T>);
443 return unique_impl_ptr<T>(new T(std::forward<Args>(args)...), &details::default_delete<T>);
445 }
444 }
446 }
445 }
447
446
448 namespace std {
447 namespace std {
449 template <class T, class D, class C>
448 template <class T, class D, class C>
450 struct hash<spimpl::impl_ptr<T, D, C> > {
449 struct hash<spimpl::impl_ptr<T, D, C> > {
451 using argument_type = spimpl::impl_ptr<T, D, C>;
450 using argument_type = spimpl::impl_ptr<T, D, C>;
452 using result_type = size_t;
451 using result_type = size_t;
453
452
454 result_type operator()(const argument_type &p) const SPIMPL_NOEXCEPT
453 result_type operator()(const argument_type &p) const SPIMPL_NOEXCEPT
455 {
454 {
456 return hash<typename argument_type::pointer>()(p.get());
455 return hash<typename argument_type::pointer>()(p.get());
457 }
456 }
458 };
457 };
459 }
458 }
460
459
461 #endif // SPIMPL_H_
460 #endif // SPIMPL_H_
@@ -1,45 +1,48
1 #include "DataSource/DataSourceController.h"
1 #include "DataSource/DataSourceController.h"
2
2
3 #include <QMutex>
3 #include <QMutex>
4 #include <QThread>
4 #include <QThread>
5
5
6 Q_LOGGING_CATEGORY(LOG_DataSourceController, "dataSourceController")
6 #include <QDir>
7 #include <QStandardPaths>
8
9 Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController")
7
10
8 class DataSourceController::DataSourceControllerPrivate {
11 class DataSourceController::DataSourceControllerPrivate {
9 public:
12 public:
10 DataSourceControllerPrivate() {}
13 DataSourceControllerPrivate() {}
11
14
12 QMutex m_WorkingMutex;
15 QMutex m_WorkingMutex;
13 };
16 };
14
17
15 DataSourceController::DataSourceController(QObject *parent)
18 DataSourceController::DataSourceController(QObject *parent)
16 : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
19 : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
17 {
20 {
18 qCDebug(LOG_DataSourceController()) << tr("Construction du DataSourceController")
21 qCDebug(LOG_DataSourceController()) << tr("Construction du DataSourceController")
19 << QThread::currentThread();
22 << QThread::currentThread();
20 }
23 }
21
24
22 DataSourceController::~DataSourceController()
25 DataSourceController::~DataSourceController()
23 {
26 {
24 qCDebug(LOG_DataSourceController()) << tr("Desctruction du DataSourceController")
27 qCDebug(LOG_DataSourceController()) << tr("Desctruction du DataSourceController")
25 << QThread::currentThread();
28 << QThread::currentThread();
26 this->waitForFinish();
29 this->waitForFinish();
27 }
30 }
28
31
29 void DataSourceController::initialize()
32 void DataSourceController::initialize()
30 {
33 {
31 qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController")
34 qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController")
32 << QThread::currentThread();
35 << QThread::currentThread();
33 impl->m_WorkingMutex.lock();
36 impl->m_WorkingMutex.lock();
34 qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController END");
37 qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController END");
35 }
38 }
36
39
37 void DataSourceController::finalize()
40 void DataSourceController::finalize()
38 {
41 {
39 impl->m_WorkingMutex.unlock();
42 impl->m_WorkingMutex.unlock();
40 }
43 }
41
44
42 void DataSourceController::waitForFinish()
45 void DataSourceController::waitForFinish()
43 {
46 {
44 QMutexLocker locker(&impl->m_WorkingMutex);
47 QMutexLocker locker(&impl->m_WorkingMutex);
45 }
48 }
@@ -1,159 +1,158
1
1
2 ## gui - CMakeLists.txt
2 ## gui - CMakeLists.txt
3 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
3 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
4 SET(SQPGUI_LIBRARY_NAME "${LIBRARY_PREFFIX}_gui${DEBUG_SUFFIX}")
4 SET(SQPGUI_LIBRARY_NAME "${LIBRARY_PREFFIX}_gui${DEBUG_SUFFIX}")
5 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
5 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
6 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
6 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
7 SET(UI_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/ui")
7 SET(UI_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/ui")
8 SET(RES_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/resources")
8 SET(RES_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/resources")
9
9
10 # Include gui directory
10 # Include gui directory
11 include_directories("${INCLUDES_DIR}")
11 include_directories("${INCLUDES_DIR}")
12 include_directories("${CMAKE_CURRENT_BINARY_DIR}")
12 include_directories("${CMAKE_CURRENT_BINARY_DIR}")
13
13
14 # Set a variable to display a warning in the version files.
14 # Set a variable to display a warning in the version files.
15 SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.")
15 SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.")
16
16
17 #
17 #
18 # Find Qt modules
18 # Find Qt modules
19 #
19 #
20 SCIQLOP_FIND_QT(Core Widgets)
20 SCIQLOP_FIND_QT(Core Widgets)
21
21
22 #
22 #
23 # Find dependent libraries
23 # Find dependent libraries
24 # ========================
24 # ========================
25 find_package(sciqlop-core)
25 find_package(sciqlop-core)
26
26
27 message("Librairies inclues dans APP: ${SCIQLOP-CORE_LIBRARIES}")
28 SET(LIBRARIES ${SCIQLOP-CORE_LIBRARIES})
27 SET(LIBRARIES ${SCIQLOP-CORE_LIBRARIES})
29
28
30 INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR})
29 INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR})
31
30
32 # Add sqpcore to the list of libraries to use
31 # Add sqpcore to the list of libraries to use
33 list(APPEND LIBRARIES ${SQPCORE_LIBRARY_NAME})
32 list(APPEND LIBRARIES ${SQPCORE_LIBRARY_NAME})
34
33
35 # Add dependent shared libraries
34 # Add dependent shared libraries
36 list(APPEND SHARED_LIBRARIES ${SQPCORE_SHARED_LIBRARIES})
35 list(APPEND SHARED_LIBRARIES ${SQPCORE_SHARED_LIBRARIES})
37
36
38
37
39 # Ui files
38 # Ui files
40 FILE (GLOB_RECURSE PROJECT_FORMS ${UI_FOLDER}/*.ui)
39 FILE (GLOB_RECURSE PROJECT_FORMS ${UI_FOLDER}/*.ui)
41
40
42 # Resources files
41 # Resources files
43 FILE (GLOB_RECURSE PROJECT_RESOURCES ${RES_FOLDER}/*.qrc)
42 FILE (GLOB_RECURSE PROJECT_RESOURCES ${RES_FOLDER}/*.qrc)
44
43
45 #
44 #
46 # Compile the library library
45 # Compile the library library
47 #
46 #
48 FILE (GLOB_RECURSE MODULE_SOURCES
47 FILE (GLOB_RECURSE MODULE_SOURCES
49 ${INCLUDES_DIR}/*.h
48 ${INCLUDES_DIR}/*.h
50 ${SOURCES_DIR}/*.c
49 ${SOURCES_DIR}/*.c
51 ${SOURCES_DIR}/*.cpp
50 ${SOURCES_DIR}/*.cpp
52 ${SOURCES_DIR}/*.h
51 ${SOURCES_DIR}/*.h
53 ${PROJECT_FORMS})
52 ${PROJECT_FORMS})
54
53
55 QT5_ADD_RESOURCES(RCC_HDRS
54 QT5_ADD_RESOURCES(RCC_HDRS
56 ${PROJECT_RESOURCES}
55 ${PROJECT_RESOURCES}
57 )
56 )
58
57
59 QT5_WRAP_UI(UIS_HDRS
58 QT5_WRAP_UI(UIS_HDRS
60 ${PROJECT_FORMS}
59 ${PROJECT_FORMS}
61 )
60 )
62
61
63
62
64 ADD_LIBRARY(${SQPGUI_LIBRARY_NAME} ${MODULE_SOURCES} ${UIS_HDRS} ${RCC_HDRS})
63 ADD_LIBRARY(${SQPGUI_LIBRARY_NAME} ${MODULE_SOURCES} ${UIS_HDRS} ${RCC_HDRS})
65 set_property(TARGET ${SQPGUI_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
64 set_property(TARGET ${SQPGUI_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
66 set_property(TARGET ${SQPGUI_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
65 set_property(TARGET ${SQPGUI_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
67
66
68 TARGET_LINK_LIBRARIES(${SQPGUI_LIBRARY_NAME} ${LIBRARIES})
67 TARGET_LINK_LIBRARIES(${SQPGUI_LIBRARY_NAME} ${LIBRARIES})
69 qt5_use_modules(${SQPGUI_LIBRARY_NAME} Core Widgets)
68 qt5_use_modules(${SQPGUI_LIBRARY_NAME} Core Widgets)
70
69
71 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
70 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
72 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
71 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
73 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
72 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
74 IF(BUILD_SHARED_LIBS)
73 IF(BUILD_SHARED_LIBS)
75 SET_TARGET_PROPERTIES(${SQPGUI_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
74 SET_TARGET_PROPERTIES(${SQPGUI_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
76 ELSE()
75 ELSE()
77 TARGET_COMPILE_DEFINITIONS(${SQPGUI_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
76 TARGET_COMPILE_DEFINITIONS(${SQPGUI_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
78 ENDIF()
77 ENDIF()
79
78
80 # Set the variable to parent scope so that the other projects can copy the
79 # Set the variable to parent scope so that the other projects can copy the
81 # dependent shared libraries
80 # dependent shared libraries
82 SCIQLOP_SET_TO_PARENT_SCOPE(SQPGUI_LIBRARY_NAME)
81 SCIQLOP_SET_TO_PARENT_SCOPE(SQPGUI_LIBRARY_NAME)
83
82
84 # Copy extern shared libraries to the lib folder
83 # Copy extern shared libraries to the lib folder
85 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPGUI_LIBRARY_NAME})
84 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPGUI_LIBRARY_NAME})
86
85
87 # Add the files to the list of files to be analyzed
86 # Add the files to the list of files to be analyzed
88 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
87 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
89 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
88 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
90 # Vera++ exclusion files
89 # Vera++ exclusion files
91 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/path/to/exclusionFiles.tcl)
90 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/path/to/exclusionFiles.tcl)
92 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
91 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
93
92
94 #
93 #
95 # Compile the tests
94 # Compile the tests
96 #
95 #
97 IF(BUILD_TESTS)
96 IF(BUILD_TESTS)
98 INCLUDE_DIRECTORIES(${SOURCES_DIR})
97 INCLUDE_DIRECTORIES(${SOURCES_DIR})
99 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
98 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
100 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
99 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
101 SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME})
100 SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME})
102
101
103 FOREACH( testFile ${TESTS_SOURCES} )
102 FOREACH( testFile ${TESTS_SOURCES} )
104 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
103 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
105 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
104 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
106
105
107 # Add to the list of sources files all the sources in the same
106 # Add to the list of sources files all the sources in the same
108 # directory that aren't another test
107 # directory that aren't another test
109 FILE (GLOB currentTestSources
108 FILE (GLOB currentTestSources
110 ${testDirectory}/*.c
109 ${testDirectory}/*.c
111 ${testDirectory}/*.cpp
110 ${testDirectory}/*.cpp
112 ${testDirectory}/*.h)
111 ${testDirectory}/*.h)
113 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
112 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
114 LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
113 LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
115
114
116 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
115 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
117 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
116 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
118 qt5_use_modules(${testName} Test)
117 qt5_use_modules(${testName} Test)
119
118
120 ADD_TEST( NAME ${testName} COMMAND ${testName} )
119 ADD_TEST( NAME ${testName} COMMAND ${testName} )
121
120
122 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
121 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
123 ENDFOREACH( testFile )
122 ENDFOREACH( testFile )
124
123
125 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
124 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
126 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
125 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
127 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
126 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
128 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
127 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
129 ENDIF(BUILD_TESTS)
128 ENDIF(BUILD_TESTS)
130
129
131 #
130 #
132 # Set the files that must be formatted by clang-format.
131 # Set the files that must be formatted by clang-format.
133 #
132 #
134 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
133 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
135 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
134 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
136
135
137 #
136 #
138 # Set the directories that doxygen must browse to generate the
137 # Set the directories that doxygen must browse to generate the
139 # documentation.
138 # documentation.
140 #
139 #
141 # Source directories:
140 # Source directories:
142 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
141 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
143 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
142 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
144 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
143 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
145 # Source directories to exclude from the documentation generation
144 # Source directories to exclude from the documentation generation
146 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
145 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
147 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
146 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
148
147
149 #
148 #
150 # Set the directories with the sources to analyze and propagate the
149 # Set the directories with the sources to analyze and propagate the
151 # modification to the parent scope
150 # modification to the parent scope
152 #
151 #
153 # Source directories to analyze:
152 # Source directories to analyze:
154 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
153 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
155 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
154 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
156 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
155 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
157 # Source directories to exclude from the analysis
156 # Source directories to exclude from the analysis
158 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
157 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
159 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
158 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
@@ -1,33 +1,34
1 #ifndef SCIQLOP_SQPAPPLICATION_H
1 #ifndef SCIQLOP_SQPAPPLICATION_H
2 #define SCIQLOP_SQPAPPLICATION_H
2 #define SCIQLOP_SQPAPPLICATION_H
3
3
4 #include "SqpApplication.h"
4 #include "SqpApplication.h"
5
5
6 #include <QApplication>
6 #include <QApplication>
7 #include <QLoggingCategory>
7 #include <QLoggingCategory>
8
8
9 #include <Common/spimpl.h>
9 #include <Common/spimpl.h>
10
10
11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
12
12
13 /**
13 /**
14 * @brief The SqpApplication class aims to make the link between SciQlop
14 * @brief The SqpApplication class aims to make the link between SciQlop
15 * and its plugins. This is the intermediate class that SciQlop have to use
15 * and its plugins. This is the intermediate class that SciQlop have to use
16 * in the way to connect a data source. Please first use load method to intialize
16 * in the way to connect a data source. Please first use load method to intialize
17 * a plugin specified by its metadata name (JSON plugin source) then others specifics
17 * a plugin specified by its metadata name (JSON plugin source) then others specifics
18 * method will ba able to access it.
18 * method will ba able to access it.
19 * You can load a data source driver plugin then create a data source.
19 * You can load a data source driver plugin then create a data source.
20 */
20 */
21
21 class SqpApplication : public QApplication {
22 class SqpApplication : public QApplication {
22 Q_OBJECT
23 Q_OBJECT
23 public:
24 public:
24 explicit SqpApplication(int &argc, char **argv);
25 explicit SqpApplication(int &argc, char **argv);
25 virtual ~SqpApplication();
26 virtual ~SqpApplication();
26 void initialize();
27 void initialize();
27
28
28 private:
29 private:
29 class SqpApplicationPrivate;
30 class SqpApplicationPrivate;
30 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
31 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
31 };
32 };
32
33
33 #endif // SCIQLOP_SQPAPPLICATION_H
34 #endif // SCIQLOP_SQPAPPLICATION_H
@@ -1,46 +1,45
1 #include "SqpApplication.h"
1 #include "SqpApplication.h"
2
2
3 #include <DataSource/DataSourceController.h>
3 #include <DataSource/DataSourceController.h>
4 #include <QThread>
4 #include <QThread>
5
5
6 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
6 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
7
7
8 class SqpApplication::SqpApplicationPrivate {
8 class SqpApplication::SqpApplicationPrivate {
9 public:
9 public:
10 SqpApplicationPrivate() {}
10 SqpApplicationPrivate() {}
11 ~SqpApplicationPrivate()
11 virtual ~SqpApplicationPrivate()
12 {
12 {
13 qCInfo(LOG_SqpApplication()) << tr("Desctruction du SqpApplicationPrivate");
13 qCInfo(LOG_SqpApplication()) << tr("Desctruction du SqpApplicationPrivate");
14 ;
15 m_DataSourceControllerThread.quit();
14 m_DataSourceControllerThread.quit();
16 m_DataSourceControllerThread.wait();
15 m_DataSourceControllerThread.wait();
17 }
16 }
18
17
19 std::unique_ptr<DataSourceController> m_DataSourceController;
18 std::unique_ptr<DataSourceController> m_DataSourceController;
20 QThread m_DataSourceControllerThread;
19 QThread m_DataSourceControllerThread;
21 };
20 };
22
21
23
22
24 SqpApplication::SqpApplication(int &argc, char **argv)
23 SqpApplication::SqpApplication(int &argc, char **argv)
25 : QApplication(argc, argv), impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
24 : QApplication(argc, argv), impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
26 {
25 {
27 qCInfo(LOG_SqpApplication()) << tr("Construction du SqpApplication");
26 qCInfo(LOG_SqpApplication()) << tr("Construction du SqpApplication");
28
27
29 impl->m_DataSourceController = std::make_unique<DataSourceController>();
28 impl->m_DataSourceController = std::make_unique<DataSourceController>();
30 impl->m_DataSourceController->moveToThread(&impl->m_DataSourceControllerThread);
29 impl->m_DataSourceController->moveToThread(&impl->m_DataSourceControllerThread);
31
30
32 connect(&impl->m_DataSourceControllerThread, &QThread::started,
31 connect(&impl->m_DataSourceControllerThread, &QThread::started,
33 impl->m_DataSourceController.get(), &DataSourceController::initialize);
32 impl->m_DataSourceController.get(), &DataSourceController::initialize);
34 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
33 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
35 impl->m_DataSourceController.get(), &DataSourceController::finalize);
34 impl->m_DataSourceController.get(), &DataSourceController::finalize);
36
35
37 impl->m_DataSourceControllerThread.start();
36 impl->m_DataSourceControllerThread.start();
38 }
37 }
39
38
40 SqpApplication::~SqpApplication()
39 SqpApplication::~SqpApplication()
41 {
40 {
42 }
41 }
43
42
44 void SqpApplication::initialize()
43 void SqpApplication::initialize()
45 {
44 {
46 }
45 }
General Comments 0
You need to be logged in to leave comments. Login now