@@ -0,0 +1,12 | |||
|
1 | #ifndef SCIQLOP_COREGLOBAL_H | |
|
2 | #define SCIQLOP_COREGLOBAL_H | |
|
3 | ||
|
4 | #include <QtCore/QtGlobal> | |
|
5 | ||
|
6 | #ifdef CORE_LIB | |
|
7 | #define SCIQLOP_CORE_EXPORT Q_DECL_EXPORT | |
|
8 | #else | |
|
9 | #define SCIQLOP_CORE_EXPORT Q_DECL_IMPORT | |
|
10 | #endif | |
|
11 | ||
|
12 | #endif // SCIQLOP_COREGLOBAL_H |
@@ -1,153 +1,156 | |||
|
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 | # Find dependent modules |
|
21 | 21 | find_package(sciqlop-plugin) |
|
22 | 22 | INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR}) |
|
23 | 23 | |
|
24 | 24 | # |
|
25 | 25 | # Find Qt modules |
|
26 | 26 | # |
|
27 | 27 | SCIQLOP_FIND_QT(Core Network) |
|
28 | 28 | |
|
29 | 29 | # |
|
30 | 30 | # Compile the library library |
|
31 | 31 | # |
|
32 | ||
|
33 | ADD_DEFINITIONS(-DCORE_LIB) | |
|
34 | ||
|
32 | 35 | FILE (GLOB_RECURSE MODULE_SOURCES |
|
33 | 36 | ${INCLUDES_DIR}/*.h |
|
34 | 37 | ${SOURCES_DIR}/*.c |
|
35 | 38 | ${SOURCES_DIR}/*.cpp |
|
36 | 39 | ${SOURCES_DIR}/*.h) |
|
37 | 40 | |
|
38 | 41 | ADD_LIBRARY(${SQPCORE_LIBRARY_NAME} ${MODULE_SOURCES}) |
|
39 | 42 | set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD 14) |
|
40 | 43 | set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) |
|
41 | 44 | TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME}) |
|
42 | 45 | qt5_use_modules(${SQPCORE_LIBRARY_NAME} Core Network) |
|
43 | 46 | |
|
44 | 47 | INSTALL(TARGETS ${SQPCORE_LIBRARY_NAME} |
|
45 | 48 | RUNTIME DESTINATION ${INSTALL_BINARY_DIR} |
|
46 | 49 | LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} |
|
47 | 50 | ARCHIVE DESTINATION ${INSTALL_LIBRARY_DIR} |
|
48 | 51 | ) |
|
49 | 52 | |
|
50 | 53 | # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html |
|
51 | 54 | # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order. |
|
52 | 55 | # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets |
|
53 | 56 | IF(BUILD_SHARED_LIBS) |
|
54 | 57 | SET_TARGET_PROPERTIES(${SQPCORE_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT") |
|
55 | 58 | ELSE() |
|
56 | 59 | TARGET_COMPILE_DEFINITIONS(${SQPCORE_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES") |
|
57 | 60 | ENDIF() |
|
58 | 61 | |
|
59 | 62 | # Set the variable to parent scope so that the other projects can copy the |
|
60 | 63 | # dependent shared libraries |
|
61 | 64 | SCIQLOP_SET_TO_PARENT_SCOPE(SQPCORE_LIBRARY_NAME) |
|
62 | 65 | |
|
63 | 66 | # Copy extern shared libraries to the lib folder |
|
64 | 67 | SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPCORE_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES}) |
|
65 | 68 | |
|
66 | 69 | # Add the files to the list of files to be analyzed |
|
67 | 70 | LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES}) |
|
68 | 71 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) |
|
69 | 72 | # Vera++ exclusion files |
|
70 | 73 | LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt) |
|
71 | 74 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) |
|
72 | 75 | |
|
73 | 76 | # |
|
74 | 77 | # Compile the tests |
|
75 | 78 | # |
|
76 | 79 | IF(BUILD_TESTS) |
|
77 | 80 | INCLUDE_DIRECTORIES(${SOURCES_DIR}) |
|
78 | 81 | FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp) |
|
79 | 82 | FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h) |
|
80 | 83 | SET( TEST_LIBRARIES ${SQPCORE_LIBRARY_NAME}) |
|
81 | 84 | |
|
82 | 85 | SET(TARGETS_COV) |
|
83 | 86 | FOREACH( testFile ${TESTS_SOURCES} ) |
|
84 | 87 | GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) |
|
85 | 88 | GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) |
|
86 | 89 | |
|
87 | 90 | # Add to the list of sources files all the sources in the same |
|
88 | 91 | # directory that aren't another test |
|
89 | 92 | FILE (GLOB currentTestSources |
|
90 | 93 | ${testDirectory}/*.c |
|
91 | 94 | ${testDirectory}/*.cpp |
|
92 | 95 | ${testDirectory}/*.h) |
|
93 | 96 | LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) |
|
94 | 97 | # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) |
|
95 | 98 | |
|
96 | 99 | ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) |
|
97 | 100 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14) |
|
98 | 101 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON) |
|
99 | 102 | TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} ) |
|
100 | 103 | qt5_use_modules(${testName} Test) |
|
101 | 104 | |
|
102 | 105 | ADD_TEST( NAME ${testName} COMMAND ${testName} ) |
|
103 | 106 | |
|
104 | 107 | SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) |
|
105 | 108 | set(Coverage_NAME ${testName}) |
|
106 | 109 | if(UNIX) |
|
107 | 110 | SETUP_TARGET_FOR_COVERAGE(TARGET ${testName}_coverage OUTPUT ${testFile}-path NAME ${testFile} EXECUTABLE ${testName}) |
|
108 | 111 | LIST( APPEND TARGETS_COV ${testName}_coverage) |
|
109 | 112 | endif(UNIX) |
|
110 | 113 | |
|
111 | 114 | ENDFOREACH( testFile ) |
|
112 | 115 | |
|
113 | 116 | add_custom_target(coverage) |
|
114 | 117 | |
|
115 | 118 | FOREACH( target_cov ${TARGETS_COV} ) |
|
116 | 119 | add_custom_command(TARGET coverage PRE_BUILD COMMAND make ${target_cov}) |
|
117 | 120 | ENDFOREACH( target_cov ) |
|
118 | 121 | |
|
119 | 122 | LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) |
|
120 | 123 | LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) |
|
121 | 124 | LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) |
|
122 | 125 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) |
|
123 | 126 | ENDIF(BUILD_TESTS) |
|
124 | 127 | |
|
125 | 128 | # |
|
126 | 129 | # Set the files that must be formatted by clang-format. |
|
127 | 130 | # |
|
128 | 131 | LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES}) |
|
129 | 132 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) |
|
130 | 133 | |
|
131 | 134 | # |
|
132 | 135 | # Set the directories that doxygen must browse to generate the |
|
133 | 136 | # documentation. |
|
134 | 137 | # |
|
135 | 138 | # Source directories: |
|
136 | 139 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") |
|
137 | 140 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
138 | 141 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) |
|
139 | 142 | # Source directories to exclude from the documentation generation |
|
140 | 143 | #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") |
|
141 | 144 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) |
|
142 | 145 | |
|
143 | 146 | # |
|
144 | 147 | # Set the directories with the sources to analyze and propagate the |
|
145 | 148 | # modification to the parent scope |
|
146 | 149 | # |
|
147 | 150 | # Source directories to analyze: |
|
148 | 151 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
149 | 152 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") |
|
150 | 153 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) |
|
151 | 154 | # Source directories to exclude from the analysis |
|
152 | 155 | #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") |
|
153 | 156 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) |
@@ -1,72 +1,74 | |||
|
1 | 1 | #ifndef SCIQLOP_IDATAPROVIDER_H |
|
2 | 2 | #define SCIQLOP_IDATAPROVIDER_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <memory> |
|
5 | 7 | |
|
6 | 8 | #include <QObject> |
|
7 | 9 | #include <QUuid> |
|
8 | 10 | |
|
9 | 11 | #include <Common/MetaTypes.h> |
|
10 | 12 | |
|
11 | 13 | #include <Data/SqpDateTime.h> |
|
12 | 14 | |
|
13 | 15 | #include <functional> |
|
14 | 16 | |
|
15 | 17 | class DataProviderParameters; |
|
16 | 18 | class IDataSeries; |
|
17 | 19 | class QNetworkReply; |
|
18 | 20 | class QNetworkRequest; |
|
19 | 21 | |
|
20 | 22 | /** |
|
21 | 23 | * @brief The IDataProvider interface aims to declare a data provider. |
|
22 | 24 | * |
|
23 | 25 | * A data provider is an entity that generates data and returns it according to various parameters |
|
24 | 26 | * (time interval, product to retrieve the data, etc.) |
|
25 | 27 | * |
|
26 | 28 | * @sa IDataSeries |
|
27 | 29 | */ |
|
28 | class IDataProvider : public QObject { | |
|
30 | class SCIQLOP_CORE_EXPORT IDataProvider : public QObject { | |
|
29 | 31 | |
|
30 | 32 | Q_OBJECT |
|
31 | 33 | public: |
|
32 | 34 | virtual ~IDataProvider() noexcept = default; |
|
33 | 35 | |
|
34 | 36 | /** |
|
35 | 37 | * @brief requestDataLoading provide datas for the data identified by identifier and parameters |
|
36 | 38 | */ |
|
37 | 39 | virtual void requestDataLoading(QUuid identifier, const DataProviderParameters ¶meters) = 0; |
|
38 | 40 | |
|
39 | 41 | /** |
|
40 | 42 | * @brief requestDataAborting stop data loading of the data identified by identifier |
|
41 | 43 | */ |
|
42 | 44 | virtual void requestDataAborting(QUuid identifier) = 0; |
|
43 | 45 | |
|
44 | 46 | signals: |
|
45 | 47 | /** |
|
46 | 48 | * @brief dataProvided send dataSeries under dateTime and that corresponds of the data |
|
47 | 49 | * identified by identifier |
|
48 | 50 | */ |
|
49 | 51 | void dataProvided(QUuid identifier, std::shared_ptr<IDataSeries> dateSerie, |
|
50 | 52 | const SqpDateTime &dateTime); |
|
51 | 53 | |
|
52 | 54 | /** |
|
53 | 55 | * @brief dataProvided send dataSeries under dateTime and that corresponds of the data |
|
54 | 56 | * identified by identifier |
|
55 | 57 | */ |
|
56 | 58 | void dataProvidedProgress(QUuid identifier, double progress); |
|
57 | 59 | |
|
58 | 60 | |
|
59 | 61 | /** |
|
60 | 62 | * @brief requestConstructed send a request for the data identified by identifier |
|
61 | 63 | * @callback is the methode call by the reply of the request when it is finished. |
|
62 | 64 | */ |
|
63 | 65 | void requestConstructed(const QNetworkRequest &request, QUuid identifier, |
|
64 | 66 | std::function<void(QNetworkReply *, QUuid)> callback); |
|
65 | 67 | }; |
|
66 | 68 | |
|
67 | 69 | // Required for using shared_ptr in signals/slots |
|
68 | 70 | SCIQLOP_REGISTER_META_TYPE(IDATAPROVIDER_PTR_REGISTRY, std::shared_ptr<IDataProvider>) |
|
69 | 71 | SCIQLOP_REGISTER_META_TYPE(IDATAPROVIDER_FUNCTION_REGISTRY, |
|
70 | 72 | std::function<void(QNetworkReply *, QUuid)>) |
|
71 | 73 | |
|
72 | 74 | #endif // SCIQLOP_IDATAPROVIDER_H |
@@ -1,23 +1,25 | |||
|
1 | 1 | #ifndef SCIQLOP_SCALARSERIES_H |
|
2 | 2 | #define SCIQLOP_SCALARSERIES_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <Data/DataSeries.h> |
|
5 | 7 | |
|
6 | 8 | /** |
|
7 | 9 | * @brief The ScalarSeries class is the implementation for a data series representing a scalar. |
|
8 | 10 | */ |
|
9 | class ScalarSeries : public DataSeries<1> { | |
|
11 | class SCIQLOP_CORE_EXPORT ScalarSeries : public DataSeries<1> { | |
|
10 | 12 | public: |
|
11 | 13 | /** |
|
12 | 14 | * Ctor with two vectors. The vectors must have the same size, otherwise a ScalarSeries with no |
|
13 | 15 | * values will be created. |
|
14 | 16 | * @param xAxisData x-axis data |
|
15 | 17 | * @param valuesData values data |
|
16 | 18 | */ |
|
17 | 19 | explicit ScalarSeries(QVector<double> xAxisData, QVector<double> valuesData, |
|
18 | 20 | const Unit &xAxisUnit, const Unit &valuesUnit); |
|
19 | 21 | |
|
20 | 22 | std::unique_ptr<IDataSeries> clone() const; |
|
21 | 23 | }; |
|
22 | 24 | |
|
23 | 25 | #endif // SCIQLOP_SCALARSERIES_H |
@@ -1,92 +1,94 | |||
|
1 | 1 | #ifndef SCIQLOP_DATASOURCECONTROLLER_H |
|
2 | 2 | #define SCIQLOP_DATASOURCECONTROLLER_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <QLoggingCategory> |
|
5 | 7 | #include <QObject> |
|
6 | 8 | #include <QUuid> |
|
7 | 9 | |
|
8 | 10 | #include <Common/spimpl.h> |
|
9 | 11 | |
|
10 | 12 | Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController) |
|
11 | 13 | |
|
12 | 14 | class DataSourceItem; |
|
13 | 15 | class IDataProvider; |
|
14 | 16 | |
|
15 | 17 | /** |
|
16 | 18 | * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This |
|
17 | 19 | * is the intermediate class that SciQlop has to use in the way to connect a data source. Please |
|
18 | 20 | * first use register method to initialize a plugin specified by its metadata name (JSON plugin |
|
19 | 21 | * source) then others specifics method will be able to access it. You can load a data source driver |
|
20 | 22 | * plugin then create a data source. |
|
21 | 23 | */ |
|
22 | class DataSourceController : public QObject { | |
|
24 | class SCIQLOP_CORE_EXPORT DataSourceController : public QObject { | |
|
23 | 25 | Q_OBJECT |
|
24 | 26 | public: |
|
25 | 27 | explicit DataSourceController(QObject *parent = 0); |
|
26 | 28 | virtual ~DataSourceController(); |
|
27 | 29 | |
|
28 | 30 | /** |
|
29 | 31 | * Registers a data source. The method delivers a unique id that can be used afterwards to |
|
30 | 32 | * access to the data source properties (structure, connection parameters, data provider, etc.) |
|
31 | 33 | * @param dataSourceName the name of the data source |
|
32 | 34 | * @return the unique id with which the data source has been registered |
|
33 | 35 | */ |
|
34 | 36 | QUuid registerDataSource(const QString &dataSourceName) noexcept; |
|
35 | 37 | |
|
36 | 38 | /** |
|
37 | 39 | * Sets the structure of a data source. The controller takes ownership of the structure. |
|
38 | 40 | * @param dataSourceUid the unique id with which the data source has been registered into the |
|
39 | 41 | * controller. If it is invalid, the method has no effect. |
|
40 | 42 | * @param dataSourceItem the structure of the data source. It must be not null to be registered |
|
41 | 43 | * @sa registerDataSource() |
|
42 | 44 | */ |
|
43 | 45 | void setDataSourceItem(const QUuid &dataSourceUid, |
|
44 | 46 | std::unique_ptr<DataSourceItem> dataSourceItem) noexcept; |
|
45 | 47 | |
|
46 | 48 | /** |
|
47 | 49 | * Sets the data provider used to retrieve data from of a data source. The controller takes |
|
48 | 50 | * ownership of the provider. |
|
49 | 51 | * @param dataSourceUid the unique id with which the data source has been registered into the |
|
50 | 52 | * controller. If it is invalid, the method has no effect. |
|
51 | 53 | * @param dataProvider the provider of the data source |
|
52 | 54 | * @sa registerDataSource() |
|
53 | 55 | */ |
|
54 | 56 | void setDataProvider(const QUuid &dataSourceUid, |
|
55 | 57 | std::unique_ptr<IDataProvider> dataProvider) noexcept; |
|
56 | 58 | |
|
57 | 59 | /** |
|
58 | 60 | * Loads an item (product) as a variable in SciQlop |
|
59 | 61 | * @param dataSourceUid the unique id of the data source containing the item. It is used to get |
|
60 | 62 | * the data provider associated to the data source, and pass it to for the variable creation |
|
61 | 63 | * @param productItem the item to load |
|
62 | 64 | */ |
|
63 | 65 | void loadProductItem(const QUuid &dataSourceUid, const DataSourceItem &productItem) noexcept; |
|
64 | 66 | |
|
65 | 67 | public slots: |
|
66 | 68 | /// Manage init/end of the controller |
|
67 | 69 | void initialize(); |
|
68 | 70 | void finalize(); |
|
69 | 71 | |
|
70 | 72 | signals: |
|
71 | 73 | /// Signal emitted when a structure has been set for a data source |
|
72 | 74 | void dataSourceItemSet(DataSourceItem *dataSourceItem); |
|
73 | 75 | |
|
74 | 76 | /** |
|
75 | 77 | * Signal emitted when a variable creation is asked for a product |
|
76 | 78 | * @param variableName the name of the variable |
|
77 | 79 | * @param variableMetadata the metadata of the variable |
|
78 | 80 | * @param variableProvider the provider that will be used to retrieve the data of the variable |
|
79 | 81 | * (can be null) |
|
80 | 82 | */ |
|
81 | 83 | void variableCreationRequested(const QString &variableName, |
|
82 | 84 | const QVariantHash &variableMetadata, |
|
83 | 85 | std::shared_ptr<IDataProvider> variableProvider); |
|
84 | 86 | |
|
85 | 87 | private: |
|
86 | 88 | void waitForFinish(); |
|
87 | 89 | |
|
88 | 90 | class DataSourceControllerPrivate; |
|
89 | 91 | spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl; |
|
90 | 92 | }; |
|
91 | 93 | |
|
92 | 94 | #endif // SCIQLOP_DATASOURCECONTROLLER_H |
@@ -1,94 +1,96 | |||
|
1 | 1 | #ifndef SCIQLOP_DATASOURCEITEM_H |
|
2 | 2 | #define SCIQLOP_DATASOURCEITEM_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <Common/spimpl.h> |
|
5 | 7 | |
|
6 | 8 | #include <QVariant> |
|
7 | 9 | #include <QVector> |
|
8 | 10 | |
|
9 | 11 | class DataSourceItemAction; |
|
10 | 12 | |
|
11 | 13 | /** |
|
12 | 14 | * Possible types of an item |
|
13 | 15 | */ |
|
14 | 16 | enum class DataSourceItemType { NODE, PRODUCT, COMPONENT }; |
|
15 | 17 | |
|
16 | 18 | /** |
|
17 | 19 | * @brief The DataSourceItem class aims to represent a structure element of a data source. |
|
18 | 20 | * A data source has a tree structure that is made up of a main DataSourceItem object (root) |
|
19 | 21 | * containing other DataSourceItem objects (children). |
|
20 | 22 | * For each DataSourceItem can be associated a set of data representing it. |
|
21 | 23 | */ |
|
22 | class DataSourceItem { | |
|
24 | class SCIQLOP_CORE_EXPORT DataSourceItem { | |
|
23 | 25 | public: |
|
24 | 26 | /// Key associated with the name of the item |
|
25 | 27 | static const QString NAME_DATA_KEY; |
|
26 | 28 | |
|
27 | 29 | explicit DataSourceItem(DataSourceItemType type, const QString &name); |
|
28 | 30 | explicit DataSourceItem(DataSourceItemType type, QVariantHash data = {}); |
|
29 | 31 | |
|
30 | 32 | /// @return the actions of the item as a vector |
|
31 | 33 | QVector<DataSourceItemAction *> actions() const noexcept; |
|
32 | 34 | |
|
33 | 35 | /** |
|
34 | 36 | * Adds an action to the item. The item takes ownership of the action, and the action is |
|
35 | 37 | * automatically associated to the item |
|
36 | 38 | * @param action the action to add |
|
37 | 39 | */ |
|
38 | 40 | void addAction(std::unique_ptr<DataSourceItemAction> action) noexcept; |
|
39 | 41 | |
|
40 | 42 | /** |
|
41 | 43 | * Adds a child to the item. The item takes ownership of the child. |
|
42 | 44 | * @param child the child to add |
|
43 | 45 | */ |
|
44 | 46 | void appendChild(std::unique_ptr<DataSourceItem> child) noexcept; |
|
45 | 47 | |
|
46 | 48 | /** |
|
47 | 49 | * Returns the item's child associated to an index |
|
48 | 50 | * @param childIndex the index to search |
|
49 | 51 | * @return a pointer to the child if index is valid, nullptr otherwise |
|
50 | 52 | */ |
|
51 | 53 | DataSourceItem *child(int childIndex) const noexcept; |
|
52 | 54 | |
|
53 | 55 | int childCount() const noexcept; |
|
54 | 56 | |
|
55 | 57 | /** |
|
56 | 58 | * Get the data associated to a key |
|
57 | 59 | * @param key the key to search |
|
58 | 60 | * @return the data found if key is valid, default QVariant otherwise |
|
59 | 61 | */ |
|
60 | 62 | QVariant data(const QString &key) const noexcept; |
|
61 | 63 | |
|
62 | 64 | /// Gets all data |
|
63 | 65 | QVariantHash data() const noexcept; |
|
64 | 66 | |
|
65 | 67 | bool isRoot() const noexcept; |
|
66 | 68 | |
|
67 | 69 | QString name() const noexcept; |
|
68 | 70 | |
|
69 | 71 | /** |
|
70 | 72 | * Get the item's parent |
|
71 | 73 | * @return a pointer to the parent if it exists, nullptr if the item is a root |
|
72 | 74 | */ |
|
73 | 75 | DataSourceItem *parentItem() const noexcept; |
|
74 | 76 | |
|
75 | 77 | /** |
|
76 | 78 | * Sets or appends a value to a key |
|
77 | 79 | * @param key the key |
|
78 | 80 | * @param value the value |
|
79 | 81 | * @param append if true, the value is added to the values already existing for the key, |
|
80 | 82 | * otherwise it replaces the existing values |
|
81 | 83 | */ |
|
82 | 84 | void setData(const QString &key, const QVariant &value, bool append = false) noexcept; |
|
83 | 85 | |
|
84 | 86 | DataSourceItemType type() const noexcept; |
|
85 | 87 | |
|
86 | 88 | bool operator==(const DataSourceItem &other); |
|
87 | 89 | bool operator!=(const DataSourceItem &other); |
|
88 | 90 | |
|
89 | 91 | private: |
|
90 | 92 | class DataSourceItemPrivate; |
|
91 | 93 | spimpl::unique_impl_ptr<DataSourceItemPrivate> impl; |
|
92 | 94 | }; |
|
93 | 95 | |
|
94 | 96 | #endif // SCIQLOP_DATASOURCEITEMMODEL_H |
@@ -1,50 +1,52 | |||
|
1 | 1 | #ifndef SCIQLOP_DATASOURCEITEMACTION_H |
|
2 | 2 | #define SCIQLOP_DATASOURCEITEMACTION_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <Common/spimpl.h> |
|
5 | 7 | |
|
6 | 8 | #include <QLoggingCategory> |
|
7 | 9 | #include <QObject> |
|
8 | 10 | |
|
9 | 11 | #include <functional> |
|
10 | 12 | |
|
11 | 13 | Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceItemAction) |
|
12 | 14 | |
|
13 | 15 | class DataSourceItem; |
|
14 | 16 | |
|
15 | 17 | /** |
|
16 | 18 | * @brief The DataSourceItemAction class represents an action on a data source item. |
|
17 | 19 | * |
|
18 | 20 | * An action is a function that will be executed when the slot execute() is called. |
|
19 | 21 | */ |
|
20 | class DataSourceItemAction : public QObject { | |
|
22 | class SCIQLOP_CORE_EXPORT DataSourceItemAction : public QObject { | |
|
21 | 23 | |
|
22 | 24 | Q_OBJECT |
|
23 | 25 | |
|
24 | 26 | public: |
|
25 | 27 | /// Signature of the function associated to the action |
|
26 | 28 | using ExecuteFunction = std::function<void(DataSourceItem &dataSourceItem)>; |
|
27 | 29 | |
|
28 | 30 | /** |
|
29 | 31 | * Ctor |
|
30 | 32 | * @param name the name of the action |
|
31 | 33 | * @param fun the function that will be called when the action is executed |
|
32 | 34 | * @sa execute() |
|
33 | 35 | */ |
|
34 | 36 | explicit DataSourceItemAction(const QString &name, ExecuteFunction fun); |
|
35 | 37 | |
|
36 | 38 | QString name() const noexcept; |
|
37 | 39 | |
|
38 | 40 | /// Sets the data source item concerned by the action |
|
39 | 41 | void setDataSourceItem(DataSourceItem *dataSourceItem) noexcept; |
|
40 | 42 | |
|
41 | 43 | public slots: |
|
42 | 44 | /// Executes the action |
|
43 | 45 | void execute(); |
|
44 | 46 | |
|
45 | 47 | private: |
|
46 | 48 | class DataSourceItemActionPrivate; |
|
47 | 49 | spimpl::unique_impl_ptr<DataSourceItemActionPrivate> impl; |
|
48 | 50 | }; |
|
49 | 51 | |
|
50 | 52 | #endif // SCIQLOP_DATASOURCEITEMACTION_H |
@@ -1,46 +1,48 | |||
|
1 | 1 | #ifndef SCIQLOP_NETWORKCONTROLLER_H |
|
2 | 2 | #define SCIQLOP_NETWORKCONTROLLER_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <QLoggingCategory> |
|
5 | 7 | #include <QObject> |
|
6 | 8 | #include <QUuid> |
|
7 | 9 | |
|
8 | 10 | #include <Common/spimpl.h> |
|
9 | 11 | #include <functional> |
|
10 | 12 | |
|
11 | 13 | Q_DECLARE_LOGGING_CATEGORY(LOG_NetworkController) |
|
12 | 14 | |
|
13 | 15 | class QNetworkReply; |
|
14 | 16 | class QNetworkRequest; |
|
15 | 17 | |
|
16 | 18 | /** |
|
17 | 19 | * @brief The NetworkController class aims to handle all network connection of SciQlop. |
|
18 | 20 | */ |
|
19 | class NetworkController : public QObject { | |
|
21 | class SCIQLOP_CORE_EXPORT NetworkController : public QObject { | |
|
20 | 22 | Q_OBJECT |
|
21 | 23 | public: |
|
22 | 24 | explicit NetworkController(QObject *parent = 0); |
|
23 | 25 | |
|
24 | 26 | void initialize(); |
|
25 | 27 | void finalize(); |
|
26 | 28 | |
|
27 | 29 | public slots: |
|
28 | 30 | /// Execute request and call callback when the reply is finished. Identifier is attached to the |
|
29 | 31 | /// callback |
|
30 | 32 | void onProcessRequested(const QNetworkRequest &request, QUuid identifier, |
|
31 | 33 | std::function<void(QNetworkReply *, QUuid)> callback); |
|
32 | 34 | /// Cancel the request of identifier |
|
33 | 35 | void onReplyCanceled(QUuid identifier); |
|
34 | 36 | |
|
35 | 37 | signals: |
|
36 | 38 | void replyFinished(QNetworkReply *reply, QUuid identifier); |
|
37 | 39 | void replyDownloadProgress(QUuid identifier, double progress); |
|
38 | 40 | |
|
39 | 41 | private: |
|
40 | 42 | void waitForFinish(); |
|
41 | 43 | |
|
42 | 44 | class NetworkControllerPrivate; |
|
43 | 45 | spimpl::unique_impl_ptr<NetworkControllerPrivate> impl; |
|
44 | 46 | }; |
|
45 | 47 | |
|
46 | 48 | #endif // SCIQLOP_NETWORKCONTROLLER_H |
@@ -1,34 +1,36 | |||
|
1 | 1 | #ifndef SCIQLOP_PLUGINMANAGER_H |
|
2 | 2 | #define SCIQLOP_PLUGINMANAGER_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <Common/spimpl.h> |
|
5 | 7 | |
|
6 | 8 | #include <QLoggingCategory> |
|
7 | 9 | |
|
8 | 10 | class QDir; |
|
9 | 11 | |
|
10 | 12 | Q_DECLARE_LOGGING_CATEGORY(LOG_PluginManager) |
|
11 | 13 | |
|
12 | 14 | /** |
|
13 | 15 | * @brief The PluginManager class aims to handle the plugins loaded dynamically into SciQLop. |
|
14 | 16 | */ |
|
15 | class PluginManager { | |
|
17 | class SCIQLOP_CORE_EXPORT PluginManager { | |
|
16 | 18 | public: |
|
17 | 19 | explicit PluginManager(); |
|
18 | 20 | |
|
19 | 21 | /** |
|
20 | 22 | * Loads plugins into SciQlop. The loaded plugins are those located in the directory passed in |
|
21 | 23 | * parameter |
|
22 | 24 | * @param pluginDir the directory containing the plugins |
|
23 | 25 | */ |
|
24 | 26 | void loadPlugins(const QDir &pluginDir); |
|
25 | 27 | |
|
26 | 28 | /// @returns the number of plugins loaded |
|
27 | 29 | int nbPluginsLoaded() const noexcept; |
|
28 | 30 | |
|
29 | 31 | private: |
|
30 | 32 | class PluginManagerPrivate; |
|
31 | 33 | spimpl::unique_impl_ptr<PluginManagerPrivate> impl; |
|
32 | 34 | }; |
|
33 | 35 | |
|
34 | 36 | #endif // SCIQLOP_PLUGINMANAGER_H |
@@ -1,40 +1,42 | |||
|
1 | 1 | #ifndef SCIQLOP_TIMECONTROLLER_H |
|
2 | 2 | #define SCIQLOP_TIMECONTROLLER_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <Data/SqpDateTime.h> |
|
5 | 7 | |
|
6 | 8 | #include <QLoggingCategory> |
|
7 | 9 | #include <QObject> |
|
8 | 10 | |
|
9 | 11 | #include <Common/spimpl.h> |
|
10 | 12 | |
|
11 | 13 | |
|
12 | 14 | Q_DECLARE_LOGGING_CATEGORY(LOG_TimeController) |
|
13 | 15 | |
|
14 | 16 | /** |
|
15 | 17 | * @brief The TimeController class aims to handle the Time parameters notification in SciQlop. |
|
16 | 18 | */ |
|
17 | class TimeController : public QObject { | |
|
19 | class SCIQLOP_CORE_EXPORT TimeController : public QObject { | |
|
18 | 20 | Q_OBJECT |
|
19 | 21 | public: |
|
20 | 22 | explicit TimeController(QObject *parent = 0); |
|
21 | 23 | |
|
22 | 24 | SqpDateTime dateTime() const noexcept; |
|
23 | 25 | |
|
24 | 26 | signals: |
|
25 | 27 | /// Signal emitted to notify that time parameters has beed updated |
|
26 | 28 | void timeUpdated(SqpDateTime time); |
|
27 | 29 | |
|
28 | 30 | public slots: |
|
29 | 31 | /// Slot called when a new dateTime has been defined. |
|
30 | 32 | void onTimeToUpdate(SqpDateTime dateTime); |
|
31 | 33 | |
|
32 | 34 | /// Slot called when the dateTime has to be notified. Call timeUpdated signal |
|
33 | 35 | void onTimeNotify(); |
|
34 | 36 | |
|
35 | 37 | private: |
|
36 | 38 | class TimeControllerPrivate; |
|
37 | 39 | spimpl::unique_impl_ptr<TimeControllerPrivate> impl; |
|
38 | 40 | }; |
|
39 | 41 | |
|
40 | 42 | #endif // SCIQLOP_TIMECONTROLLER_H |
@@ -1,55 +1,57 | |||
|
1 | 1 | #ifndef SCIQLOP_VARIABLE_H |
|
2 | 2 | #define SCIQLOP_VARIABLE_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <Data/SqpDateTime.h> |
|
5 | 7 | |
|
6 | 8 | #include <QLoggingCategory> |
|
7 | 9 | #include <QObject> |
|
8 | 10 | |
|
9 | 11 | #include <Common/MetaTypes.h> |
|
10 | 12 | #include <Common/spimpl.h> |
|
11 | 13 | |
|
12 | 14 | Q_DECLARE_LOGGING_CATEGORY(LOG_Variable) |
|
13 | 15 | |
|
14 | 16 | class IDataSeries; |
|
15 | 17 | class QString; |
|
16 | 18 | |
|
17 | 19 | /** |
|
18 | 20 | * @brief The Variable class represents a variable in SciQlop. |
|
19 | 21 | */ |
|
20 | class Variable : public QObject { | |
|
22 | class SCIQLOP_CORE_EXPORT Variable : public QObject { | |
|
21 | 23 | |
|
22 | 24 | Q_OBJECT |
|
23 | 25 | |
|
24 | 26 | public: |
|
25 | 27 | explicit Variable(const QString &name, const SqpDateTime &dateTime, |
|
26 | 28 | const QVariantHash &metadata = {}); |
|
27 | 29 | |
|
28 | 30 | QString name() const noexcept; |
|
29 | 31 | SqpDateTime dateTime() const noexcept; |
|
30 | 32 | void setDateTime(const SqpDateTime &dateTime) noexcept; |
|
31 | 33 | |
|
32 | 34 | /// @return the data of the variable, nullptr if there is no data |
|
33 | 35 | IDataSeries *dataSeries() const noexcept; |
|
34 | 36 | |
|
35 | 37 | QVariantHash metadata() const noexcept; |
|
36 | 38 | |
|
37 | 39 | bool contains(const SqpDateTime &dateTime) const noexcept; |
|
38 | 40 | bool intersect(const SqpDateTime &dateTime) const noexcept; |
|
39 | 41 | bool isInside(const SqpDateTime &dateTime) const noexcept; |
|
40 | 42 | |
|
41 | 43 | public slots: |
|
42 | 44 | void setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept; |
|
43 | 45 | |
|
44 | 46 | signals: |
|
45 | 47 | void updated(); |
|
46 | 48 | |
|
47 | 49 | private: |
|
48 | 50 | class VariablePrivate; |
|
49 | 51 | spimpl::unique_impl_ptr<VariablePrivate> impl; |
|
50 | 52 | }; |
|
51 | 53 | |
|
52 | 54 | // Required for using shared_ptr in signals/slots |
|
53 | 55 | SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_REGISTRY, std::shared_ptr<Variable>) |
|
54 | 56 | |
|
55 | 57 | #endif // SCIQLOP_VARIABLE_H |
@@ -1,43 +1,45 | |||
|
1 | 1 | #ifndef SCIQLOP_VARIABLECACHECONTROLLER_H |
|
2 | 2 | #define SCIQLOP_VARIABLECACHECONTROLLER_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <QLoggingCategory> |
|
5 | 7 | #include <QObject> |
|
6 | 8 | |
|
7 | 9 | #include <Data/SqpDateTime.h> |
|
8 | 10 | |
|
9 | 11 | #include <QLoggingCategory> |
|
10 | 12 | |
|
11 | 13 | #include <Common/spimpl.h> |
|
12 | 14 | |
|
13 | 15 | Q_DECLARE_LOGGING_CATEGORY(LOG_VariableCacheController) |
|
14 | 16 | |
|
15 | 17 | class Variable; |
|
16 | 18 | |
|
17 | 19 | /// This class aims to store in the cache all of the dateTime already requested to the variable. |
|
18 | class VariableCacheController : public QObject { | |
|
20 | class SCIQLOP_CORE_EXPORT VariableCacheController : public QObject { | |
|
19 | 21 | Q_OBJECT |
|
20 | 22 | public: |
|
21 | 23 | explicit VariableCacheController(QObject *parent = 0); |
|
22 | 24 | |
|
23 | 25 | |
|
24 | 26 | void addDateTime(std::shared_ptr<Variable> variable, const SqpDateTime &dateTime); |
|
25 | 27 | |
|
26 | 28 | /// Clears cache concerning a variable |
|
27 | 29 | void clear(std::shared_ptr<Variable> variable) noexcept; |
|
28 | 30 | |
|
29 | 31 | /// Return all of the SqpDataTime part of the dateTime whose are not in the cache |
|
30 | 32 | QVector<SqpDateTime> provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable, |
|
31 | 33 | const SqpDateTime &dateTime); |
|
32 | 34 | |
|
33 | 35 | |
|
34 | 36 | QVector<SqpDateTime> dateCacheList(std::shared_ptr<Variable> variable) const noexcept; |
|
35 | 37 | |
|
36 | 38 | void displayCache(std::shared_ptr<Variable> variable) const; |
|
37 | 39 | |
|
38 | 40 | private: |
|
39 | 41 | class VariableCacheControllerPrivate; |
|
40 | 42 | spimpl::unique_impl_ptr<VariableCacheControllerPrivate> impl; |
|
41 | 43 | }; |
|
42 | 44 | |
|
43 | 45 | #endif // SCIQLOP_VARIABLECACHECONTROLLER_H |
@@ -1,95 +1,97 | |||
|
1 | 1 | #ifndef SCIQLOP_VARIABLECONTROLLER_H |
|
2 | 2 | #define SCIQLOP_VARIABLECONTROLLER_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <Data/SqpDateTime.h> |
|
5 | 7 | |
|
6 | 8 | #include <QLoggingCategory> |
|
7 | 9 | #include <QObject> |
|
8 | 10 | |
|
9 | 11 | #include <Common/spimpl.h> |
|
10 | 12 | |
|
11 | 13 | class IDataProvider; |
|
12 | 14 | class QItemSelectionModel; |
|
13 | 15 | class TimeController; |
|
14 | 16 | class Variable; |
|
15 | 17 | class VariableModel; |
|
16 | 18 | |
|
17 | 19 | Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController) |
|
18 | 20 | |
|
19 | 21 | /** |
|
20 | 22 | * @brief The VariableController class aims to handle the variables in SciQlop. |
|
21 | 23 | */ |
|
22 | class VariableController : public QObject { | |
|
24 | class SCIQLOP_CORE_EXPORT VariableController : public QObject { | |
|
23 | 25 | Q_OBJECT |
|
24 | 26 | public: |
|
25 | 27 | explicit VariableController(QObject *parent = 0); |
|
26 | 28 | virtual ~VariableController(); |
|
27 | 29 | |
|
28 | 30 | VariableModel *variableModel() noexcept; |
|
29 | 31 | QItemSelectionModel *variableSelectionModel() noexcept; |
|
30 | 32 | |
|
31 | 33 | void setTimeController(TimeController *timeController) noexcept; |
|
32 | 34 | |
|
33 | 35 | /** |
|
34 | 36 | * Deletes from the controller the variable passed in parameter. |
|
35 | 37 | * |
|
36 | 38 | * Delete a variable includes: |
|
37 | 39 | * - the deletion of the various references to the variable in SciQlop |
|
38 | 40 | * - the deletion of the model variable |
|
39 | 41 | * - the deletion of the provider associated with the variable |
|
40 | 42 | * - removing the cache associated with the variable |
|
41 | 43 | * |
|
42 | 44 | * @param variable the variable to delete from the controller. |
|
43 | 45 | */ |
|
44 | 46 | void deleteVariable(std::shared_ptr<Variable> variable) noexcept; |
|
45 | 47 | |
|
46 | 48 | /** |
|
47 | 49 | * Deletes from the controller the variables passed in parameter. |
|
48 | 50 | * @param variables the variables to delete from the controller. |
|
49 | 51 | * @sa deleteVariable() |
|
50 | 52 | */ |
|
51 | 53 | void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept; |
|
52 | 54 | |
|
53 | 55 | /** |
|
54 | 56 | * @brief abort the variable retrieve data progression |
|
55 | 57 | */ |
|
56 | 58 | void abortProgress(std::shared_ptr<Variable> variable); |
|
57 | 59 | |
|
58 | 60 | signals: |
|
59 | 61 | /// Signal emitted when a variable is about to be deleted from the controller |
|
60 | 62 | void variableAboutToBeDeleted(std::shared_ptr<Variable> variable); |
|
61 | 63 | |
|
62 | 64 | /// Signal emitted when a data acquisition is requested on a range for a variable |
|
63 | 65 | void rangeChanged(std::shared_ptr<Variable> variable, const SqpDateTime &range); |
|
64 | 66 | |
|
65 | 67 | public slots: |
|
66 | 68 | /// Request the data loading of the variable whithin dateTime |
|
67 | 69 | void onRequestDataLoading(std::shared_ptr<Variable> variable, const SqpDateTime &dateTime); |
|
68 | 70 | /** |
|
69 | 71 | * Creates a new variable and adds it to the model |
|
70 | 72 | * @param name the name of the new variable |
|
71 | 73 | * @param metadata the metadata of the new variable |
|
72 | 74 | * @param provider the data provider for the new variable |
|
73 | 75 | */ |
|
74 | 76 | void createVariable(const QString &name, const QVariantHash &metadata, |
|
75 | 77 | std::shared_ptr<IDataProvider> provider) noexcept; |
|
76 | 78 | |
|
77 | 79 | /// Update the temporal parameters of every selected variable to dateTime |
|
78 | 80 | void onDateTimeOnSelection(const SqpDateTime &dateTime); |
|
79 | 81 | |
|
80 | 82 | |
|
81 | 83 | void onVariableRetrieveDataInProgress(QUuid identifier, double progress); |
|
82 | 84 | |
|
83 | 85 | void onAbortProgressRequested(std::shared_ptr<Variable> variable); |
|
84 | 86 | |
|
85 | 87 | void initialize(); |
|
86 | 88 | void finalize(); |
|
87 | 89 | |
|
88 | 90 | private: |
|
89 | 91 | void waitForFinish(); |
|
90 | 92 | |
|
91 | 93 | class VariableControllerPrivate; |
|
92 | 94 | spimpl::unique_impl_ptr<VariableControllerPrivate> impl; |
|
93 | 95 | }; |
|
94 | 96 | |
|
95 | 97 | #endif // SCIQLOP_VARIABLECONTROLLER_H |
@@ -1,79 +1,80 | |||
|
1 | 1 | #ifndef SCIQLOP_VARIABLEMODEL_H |
|
2 | 2 | #define SCIQLOP_VARIABLEMODEL_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
4 | 5 | |
|
5 | 6 | #include <Data/SqpDateTime.h> |
|
6 | 7 | |
|
7 | 8 | #include <QAbstractTableModel> |
|
8 | 9 | #include <QLoggingCategory> |
|
9 | 10 | |
|
10 | 11 | #include <Common/MetaTypes.h> |
|
11 | 12 | #include <Common/spimpl.h> |
|
12 | 13 | |
|
13 | 14 | Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel) |
|
14 | 15 | |
|
15 | 16 | enum VariableRoles { ProgressRole = Qt::UserRole }; |
|
16 | 17 | |
|
17 | 18 | |
|
18 | 19 | class IDataSeries; |
|
19 | 20 | class Variable; |
|
20 | 21 | |
|
21 | 22 | /** |
|
22 | 23 | * @brief The VariableModel class aims to hold the variables that have been created in SciQlop |
|
23 | 24 | */ |
|
24 | class VariableModel : public QAbstractTableModel { | |
|
25 | class SCIQLOP_CORE_EXPORT VariableModel : public QAbstractTableModel { | |
|
25 | 26 | Q_OBJECT |
|
26 | 27 | public: |
|
27 | 28 | explicit VariableModel(QObject *parent = nullptr); |
|
28 | 29 | |
|
29 | 30 | /** |
|
30 | 31 | * Creates a new variable in the model |
|
31 | 32 | * @param name the name of the new variable |
|
32 | 33 | * @param dateTime the dateTime of the new variable |
|
33 | 34 | * @param metadata the metadata associated to the new variable |
|
34 | 35 | * @return the pointer to the new variable |
|
35 | 36 | */ |
|
36 | 37 | std::shared_ptr<Variable> createVariable(const QString &name, const SqpDateTime &dateTime, |
|
37 | 38 | const QVariantHash &metadata) noexcept; |
|
38 | 39 | |
|
39 | 40 | /** |
|
40 | 41 | * Deletes a variable from the model, if it exists |
|
41 | 42 | * @param variable the variable to delete |
|
42 | 43 | */ |
|
43 | 44 | void deleteVariable(std::shared_ptr<Variable> variable) noexcept; |
|
44 | 45 | |
|
45 | 46 | |
|
46 | 47 | std::shared_ptr<Variable> variable(int index) const; |
|
47 | 48 | |
|
48 | 49 | void setDataProgress(std::shared_ptr<Variable> variable, double progress); |
|
49 | 50 | |
|
50 | 51 | |
|
51 | 52 | // /////////////////////////// // |
|
52 | 53 | // QAbstractTableModel methods // |
|
53 | 54 | // /////////////////////////// // |
|
54 | 55 | |
|
55 | 56 | virtual int columnCount(const QModelIndex &parent = QModelIndex{}) const override; |
|
56 | 57 | virtual int rowCount(const QModelIndex &parent = QModelIndex{}) const override; |
|
57 | 58 | virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; |
|
58 | 59 | virtual QVariant headerData(int section, Qt::Orientation orientation, |
|
59 | 60 | int role = Qt::DisplayRole) const override; |
|
60 | 61 | |
|
61 | 62 | |
|
62 | 63 | void abortProgress(const QModelIndex &index); |
|
63 | 64 | |
|
64 | 65 | signals: |
|
65 | 66 | void abortProgessRequested(std::shared_ptr<Variable> variable); |
|
66 | 67 | |
|
67 | 68 | private: |
|
68 | 69 | class VariableModelPrivate; |
|
69 | 70 | spimpl::unique_impl_ptr<VariableModelPrivate> impl; |
|
70 | 71 | |
|
71 | 72 | private slots: |
|
72 | 73 | /// Slot called when data of a variable has been updated |
|
73 | 74 | void onVariableUpdated() noexcept; |
|
74 | 75 | }; |
|
75 | 76 | |
|
76 | 77 | // Registers QVector<int> metatype so it can be used in VariableModel::dataChanged() signal |
|
77 | 78 | SCIQLOP_REGISTER_META_TYPE(QVECTOR_INT_REGISTRY, QVector<int>) |
|
78 | 79 | |
|
79 | 80 | #endif // SCIQLOP_VARIABLEMODEL_H |
@@ -1,49 +1,51 | |||
|
1 | 1 | #ifndef SCIQLOP_VISUALIZATIONCONTROLLER_H |
|
2 | 2 | #define SCIQLOP_VISUALIZATIONCONTROLLER_H |
|
3 | 3 | |
|
4 | #include "CoreGlobal.h" | |
|
5 | ||
|
4 | 6 | #include <Data/SqpDateTime.h> |
|
5 | 7 | |
|
6 | 8 | #include <QLoggingCategory> |
|
7 | 9 | #include <QObject> |
|
8 | 10 | #include <QUuid> |
|
9 | 11 | |
|
10 | 12 | #include <Common/spimpl.h> |
|
11 | 13 | |
|
12 | 14 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationController) |
|
13 | 15 | |
|
14 | 16 | class DataSourceItem; |
|
15 | 17 | class Variable; |
|
16 | 18 | |
|
17 | 19 | /** |
|
18 | 20 | * @brief The VisualizationController class aims to make the link between SciQlop and its plugins. |
|
19 | 21 | * This is the intermediate class that SciQlop has to use in the way to connect a data source. |
|
20 | 22 | * Please first use register method to initialize a plugin specified by its metadata name (JSON |
|
21 | 23 | * plugin source) then others specifics method will be able to access it. You can load a data source |
|
22 | 24 | * driver plugin then create a data source. |
|
23 | 25 | */ |
|
24 | class VisualizationController : public QObject { | |
|
26 | class SCIQLOP_CORE_EXPORT VisualizationController : public QObject { | |
|
25 | 27 | Q_OBJECT |
|
26 | 28 | public: |
|
27 | 29 | explicit VisualizationController(QObject *parent = 0); |
|
28 | 30 | virtual ~VisualizationController(); |
|
29 | 31 | |
|
30 | 32 | signals: |
|
31 | 33 | /// Signal emitted when a variable is about to be deleted from SciQlop |
|
32 | 34 | void variableAboutToBeDeleted(std::shared_ptr<Variable> variable); |
|
33 | 35 | |
|
34 | 36 | /// Signal emitted when a data acquisition is requested on a range for a variable |
|
35 | 37 | void rangeChanged(std::shared_ptr<Variable> variable, const SqpDateTime &range); |
|
36 | 38 | |
|
37 | 39 | public slots: |
|
38 | 40 | /// Manage init/end of the controller |
|
39 | 41 | void initialize(); |
|
40 | 42 | void finalize(); |
|
41 | 43 | |
|
42 | 44 | private: |
|
43 | 45 | void waitForFinish(); |
|
44 | 46 | |
|
45 | 47 | class VisualizationControllerPrivate; |
|
46 | 48 | spimpl::unique_impl_ptr<VisualizationControllerPrivate> impl; |
|
47 | 49 | }; |
|
48 | 50 | |
|
49 | 51 | #endif // SCIQLOP_VISUALIZATIONCONTROLLER_H |
General Comments 0
You need to be logged in to leave comments.
Login now