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