##// END OF EJS Templates
Merge branch 'feature/MockPlugin' into develop
Alexandre Leroux -
r97:e88fe2163a70 merge
parent child
Show More
@@ -0,0 +1,145
1 ## mockplugin - CMakeLists.txt
2 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
3 SET(SQPMOCKPLUGIN_LIBRARY_NAME "${LIBRARY_PREFFIX}_mockplugin${DEBUG_SUFFIX}")
4 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
5 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
6 SET(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
7
8 # Include mockplugin directory
9 INCLUDE_DIRECTORIES(${INCLUDES_DIR})
10 INCLUDE_DIRECTORIES(${RESOURCES_DIR})
11
12 #
13 # Find Qt modules
14 #
15 SCIQLOP_FIND_QT(Core Widgets)
16
17 #
18 # Find dependent libraries
19 # ========================
20
21 # sciqlop plugin
22 find_package(sciqlop-plugin)
23 INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR})
24
25 # sciqlop core
26 find_package(sciqlop-core)
27 INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR})
28 list(APPEND LIBRARIES ${SCIQLOP-CORE_LIBRARIES})
29
30 # sciqlop gui
31 find_package(sciqlop-gui)
32 INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR})
33 list(APPEND LIBRARIES ${SCIQLOP-GUI_LIBRARIES})
34
35 # Resources files
36 FILE (GLOB_RECURSE PROJECT_RESOURCES ${RESOURCES_DIR}/*.json)
37
38 #
39 # Compile the library
40 #
41 FILE (GLOB_RECURSE MODULE_SOURCES
42 ${INCLUDES_DIR}/*.h
43 ${SOURCES_DIR}/*.c
44 ${SOURCES_DIR}/*.cpp
45 ${SOURCES_DIR}/*.h
46 ${PROJECT_RESOURCES})
47
48 ADD_LIBRARY(${SQPMOCKPLUGIN_LIBRARY_NAME} ${MODULE_SOURCES})
49 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
50 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
51
52 TARGET_LINK_LIBRARIES(${SQPMOCKPLUGIN_LIBRARY_NAME} ${LIBRARIES})
53 qt5_use_modules(${SQPMOCKPLUGIN_LIBRARY_NAME} Core Widgets)
54
55 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
56 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
57 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
58 IF(BUILD_SHARED_LIBS)
59 SET_TARGET_PROPERTIES(${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
60 ELSE()
61 TARGET_COMPILE_DEFINITIONS(${SQPMOCKPLUGIN_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
62 ENDIF()
63
64 # Set the variable to parent scope so that the other projects can copy the
65 # dependent shared libraries
66 SCIQLOP_SET_TO_PARENT_SCOPE(SQPMOCKPLUGIN_LIBRARY_NAME)
67
68 # Copy extern shared libraries to the lib folder
69 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPMOCKPLUGIN_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
70
71 # Add the files to the list of files to be analyzed
72 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
73 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
74 # Vera++ exclusion files
75 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
76 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
77
78 #
79 # Compile the tests
80 #
81 IF(BUILD_TESTS)
82 INCLUDE_DIRECTORIES(${SOURCES_DIR})
83 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
84 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
85 SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME})
86
87 FOREACH( testFile ${TESTS_SOURCES} )
88 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
89 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
90
91 # Add to the list of sources files all the sources in the same
92 # directory that aren't another test
93 FILE (GLOB currentTestSources
94 ${testDirectory}/*.c
95 ${testDirectory}/*.cpp
96 ${testDirectory}/*.h)
97 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
98 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
99
100 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
101 set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14)
102 set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON)
103 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
104 qt5_use_modules(${testName} Test)
105
106 ADD_TEST( NAME ${testName} COMMAND ${testName} )
107
108 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
109 ENDFOREACH( testFile )
110
111 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
112 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
113 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
114 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
115 ENDIF(BUILD_TESTS)
116
117 #
118 # Set the files that must be formatted by clang-format.
119 #
120 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
121 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
122
123 #
124 # Set the directories that doxygen must browse to generate the
125 # documentation.
126 #
127 # Source directories:
128 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
129 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
130 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
131 # Source directories to exclude from the documentation generation
132 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
133 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
134
135 #
136 # Set the directories with the sources to analyze and propagate the
137 # modification to the parent scope
138 #
139 # Source directories to analyze:
140 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
141 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
142 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
143 # Source directories to exclude from the analysis
144 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
145 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
@@ -0,0 +1,21
1 # - Try to find sciqlop-mockplugin
2 # Once done this will define
3 # SCIQLOP-MOCKPLUGIN_FOUND - System has sciqlop-mockplugin
4 # SCIQLOP-MOCKPLUGIN_INCLUDE_DIR - The sciqlop-mockplugin include directories
5 # SCIQLOP-MOCKPLUGIN_LIBRARIES - The libraries needed to use sciqlop-mockplugin
6
7 if(SCIQLOP-MOCKPLUGIN_FOUND)
8 return()
9 endif(SCIQLOP-MOCKPLUGIN_FOUND)
10
11 set(SCIQLOP-MOCKPLUGIN_INCLUDE_DIR ${sciqlop-mockplugin_DIR}/../include)
12
13 set (OS_LIB_EXTENSION "so")
14
15 if(WIN32)
16 set (OS_LIB_EXTENSION "dll")
17 endif(WIN32)
18 # TODO: Add Mac Support
19 set(SCIQLOP-MOCKPLUGIN_LIBRARIES ${LIBRARY_OUTPUT_PATH}/libsciqlop_mockplugin${DEBUG_SUFFIX}.${OS_LIB_EXTENSION})
20
21 set(SCIQLOP-MOCKPLUGIN_FOUND TRUE)
@@ -0,0 +1,27
1 #ifndef SCIQLOP_MOCKPLUGIN_H
2 #define SCIQLOP_MOCKPLUGIN_H
3
4 #include <Plugin/IPlugin.h>
5
6 #include <QLoggingCategory>
7
8 #include <memory>
9
10 Q_DECLARE_LOGGING_CATEGORY(LOG_MockPlugin)
11
12 class DataSourceItem;
13
14 class MockPlugin : public QObject, public IPlugin {
15 Q_OBJECT
16 Q_INTERFACES(IPlugin)
17 Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE "mockplugin.json")
18 public:
19 /// @sa IPlugin::initialize()
20 void initialize() override;
21
22 private:
23 /// Creates the data source item relative to the plugin
24 std::unique_ptr<DataSourceItem> createDataSourceItem() const noexcept;
25 };
26
27 #endif // SCIQLOP_MOCKPLUGIN_H
@@ -0,0 +1,3
1 {
2 "name" : "MockPlugin"
3 }
@@ -0,0 +1,55
1 #include <MockPlugin.h>
2
3 #include <DataSource/DataSourceController.h>
4 #include <DataSource/DataSourceItem.h>
5
6 #include <SqpApplication.h>
7
8 Q_LOGGING_CATEGORY(LOG_MockPlugin, "MockPlugin")
9
10 namespace {
11
12 /// Name of the data source
13 const auto DATA_SOURCE_NAME = QStringLiteral("MMS");
14
15 } // namespace
16
17 void MockPlugin::initialize()
18 {
19 if (auto app = sqpApp) {
20 // Registers to the data source controller
21 auto &dataSourceController = app->dataSourceController();
22 auto dataSourceUid = dataSourceController.registerDataSource(DATA_SOURCE_NAME);
23
24 dataSourceController.setDataSourceItem(dataSourceUid, createDataSourceItem());
25 }
26 else {
27 qCWarning(LOG_MockPlugin()) << tr("Can't access to SciQlop application");
28 }
29 }
30
31 std::unique_ptr<DataSourceItem> MockPlugin::createDataSourceItem() const noexcept
32 {
33 // Magnetic field products
34 auto fgmProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
35 QVector<QVariant>{QStringLiteral("FGM")});
36 auto scProduct = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT,
37 QVector<QVariant>{QStringLiteral("SC")});
38
39 auto magneticFieldFolder = std::make_unique<DataSourceItem>(
40 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Magnetic field")});
41 magneticFieldFolder->appendChild(std::move(fgmProduct));
42 magneticFieldFolder->appendChild(std::move(scProduct));
43
44 // Electric field products
45 auto electricFieldFolder = std::make_unique<DataSourceItem>(
46 DataSourceItemType::NODE, QVector<QVariant>{QStringLiteral("Electric field")});
47
48 // Root
49 auto root = std::make_unique<DataSourceItem>(DataSourceItemType::NODE,
50 QVector<QVariant>{DATA_SOURCE_NAME});
51 root->appendChild(std::move(magneticFieldFolder));
52 root->appendChild(std::move(electricFieldFolder));
53
54 return std::move(root);
55 }
@@ -35,6 +35,13 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/gui")
35 35
36 36 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/app")
37 37
38 OPTION (BUILD_PLUGINS "Build the plugins" OFF)
39 IF(BUILD_PLUGINS)
40 set(sciqlop-mockplugin_DIR "${CMAKE_SOURCE_DIR}/plugins/mockplugin/cmake")
41 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-mockplugin_DIR}")
42 ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/plugins/mockplugin")
43 ENDIF(BUILD_PLUGINS)
44
38 45 # LOGGER
39 46 set(QTLOGGING_INI_FILE "${CMAKE_SOURCE_DIR}/config/QtProject/qtlogging.ini")
40 47 FILE(COPY ${QTLOGGING_INI_FILE} DESTINATION ${CONFIG_OUTPUT_PATH})
General Comments 6
Under Review
author

Pull request updated. Auto status change to "Under Review"

Changed commits:
  * 1 added
  * 0 removed

Changed files:
  * M app/src/MainWindow.cpp
Approved
author

Status change > Approved

You need to be logged in to leave comments. Login now