From 5cbeec46f38d835372ac67562fea70b729f28101 2017-06-07 13:51:50 From: Alexandre Leroux Date: 2017-06-07 13:51:50 Subject: [PATCH] Initializes plugin manager Plugin manager is used to load plugins into SciQlop --- diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 2e86af6..b764e17 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -16,7 +16,11 @@ CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.h.in" "${INCLUDES_DIR}/Version.h") CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.cpp.in" "${SOURCES_DIR}/Version.cpp") - + +# Find dependent modules +find_package(sciqlop-plugin) +INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR}) + # # Find Qt modules # diff --git a/core/include/Plugin/PluginManager.h b/core/include/Plugin/PluginManager.h new file mode 100644 index 0000000..b54c733 --- /dev/null +++ b/core/include/Plugin/PluginManager.h @@ -0,0 +1,34 @@ +#ifndef SCIQLOP_PLUGINMANAGER_H +#define SCIQLOP_PLUGINMANAGER_H + +#include + +#include + +class QDir; + +Q_DECLARE_LOGGING_CATEGORY(LOG_PluginManager) + +/** + * @brief The PluginManager class aims to handle the plugins loaded dynamically into SciQLop. + */ +class PluginManager { +public: + explicit PluginManager(); + + /** + * Loads plugins into SciQlop. The loaded plugins are those located in the directory passed in + * parameter + * @param pluginDir the directory containing the plugins + */ + void loadPlugins(const QDir &pluginDir); + + /// @returns the number of plugins loaded + int nbPluginsLoaded() const noexcept; + +private: + class PluginManagerPrivate; + spimpl::unique_impl_ptr impl; +}; + +#endif // SCIQLOP_PLUGINMANAGER_H diff --git a/core/src/Plugin/PluginManager.cpp b/core/src/Plugin/PluginManager.cpp new file mode 100644 index 0000000..d376bd7 --- /dev/null +++ b/core/src/Plugin/PluginManager.cpp @@ -0,0 +1,29 @@ +#include + +#include + +#include + +Q_LOGGING_CATEGORY(LOG_PluginManager, "PluginManager") + +struct PluginManager::PluginManagerPrivate { +}; + +PluginManager::PluginManager() : impl{spimpl::make_unique_impl()} +{ +} + +void PluginManager::loadPlugins(const QDir &pluginDir) +{ + // Load plugins + auto pluginInfoList = pluginDir.entryInfoList(QDir::Files, QDir::Name); + for (auto pluginInfo : qAsConst(pluginInfoList)) { + /// @todo ALX + } +} + +int PluginManager::nbPluginsLoaded() const noexcept +{ + /// @todo ALX + return 0; +}