From 0680eca4ecce599028ab623850114a3d08b7d059 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Tue, 25 Jun 2024 18:03:31 +0000 Subject: [PATCH 1/3] Changelog. Signed-off-by: Chris Lalancette --- qt_dotgraph/CHANGELOG.rst | 5 +++++ qt_gui/CHANGELOG.rst | 3 +++ qt_gui_app/CHANGELOG.rst | 3 +++ qt_gui_core/CHANGELOG.rst | 3 +++ qt_gui_cpp/CHANGELOG.rst | 3 +++ qt_gui_py_common/CHANGELOG.rst | 3 +++ 6 files changed, 20 insertions(+) diff --git a/qt_dotgraph/CHANGELOG.rst b/qt_dotgraph/CHANGELOG.rst index a70e5532..bb35a413 100644 --- a/qt_dotgraph/CHANGELOG.rst +++ b/qt_dotgraph/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog for package qt_dotgraph ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- +* Skip running the tests on Windows Debug. (`#292 `_) +* Contributors: Chris Lalancette + 2.8.0 (2024-04-26) ------------------ diff --git a/qt_gui/CHANGELOG.rst b/qt_gui/CHANGELOG.rst index 7c1c8bd9..351edfb9 100644 --- a/qt_gui/CHANGELOG.rst +++ b/qt_gui/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package qt_gui ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 2.8.0 (2024-04-26) ------------------ diff --git a/qt_gui_app/CHANGELOG.rst b/qt_gui_app/CHANGELOG.rst index 057fac41..99ad94f7 100644 --- a/qt_gui_app/CHANGELOG.rst +++ b/qt_gui_app/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package qt_gui_app ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 2.8.0 (2024-04-26) ------------------ diff --git a/qt_gui_core/CHANGELOG.rst b/qt_gui_core/CHANGELOG.rst index 55001784..0822873b 100644 --- a/qt_gui_core/CHANGELOG.rst +++ b/qt_gui_core/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package qt_gui_core ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 2.8.0 (2024-04-26) ------------------ diff --git a/qt_gui_cpp/CHANGELOG.rst b/qt_gui_cpp/CHANGELOG.rst index 1664fbc9..5048bbc7 100644 --- a/qt_gui_cpp/CHANGELOG.rst +++ b/qt_gui_cpp/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package qt_gui_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 2.8.0 (2024-04-26) ------------------ diff --git a/qt_gui_py_common/CHANGELOG.rst b/qt_gui_py_common/CHANGELOG.rst index 034f24a0..78843ab3 100644 --- a/qt_gui_py_common/CHANGELOG.rst +++ b/qt_gui_py_common/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package qt_gui_py_common ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 2.8.0 (2024-04-26) ------------------ From b6f5c5399615079a1f8729e40e90ab652e562875 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Tue, 25 Jun 2024 18:03:42 +0000 Subject: [PATCH 2/3] 2.8.1 --- qt_dotgraph/CHANGELOG.rst | 4 ++-- qt_dotgraph/package.xml | 2 +- qt_gui/CHANGELOG.rst | 4 ++-- qt_gui/package.xml | 2 +- qt_gui_app/CHANGELOG.rst | 4 ++-- qt_gui_app/package.xml | 2 +- qt_gui_core/CHANGELOG.rst | 4 ++-- qt_gui_core/package.xml | 2 +- qt_gui_cpp/CHANGELOG.rst | 4 ++-- qt_gui_cpp/package.xml | 2 +- qt_gui_py_common/CHANGELOG.rst | 4 ++-- qt_gui_py_common/package.xml | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/qt_dotgraph/CHANGELOG.rst b/qt_dotgraph/CHANGELOG.rst index bb35a413..f6d4fcbf 100644 --- a/qt_dotgraph/CHANGELOG.rst +++ b/qt_dotgraph/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package qt_dotgraph ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +2.8.1 (2024-06-25) +------------------ * Skip running the tests on Windows Debug. (`#292 `_) * Contributors: Chris Lalancette diff --git a/qt_dotgraph/package.xml b/qt_dotgraph/package.xml index 2debb005..028ee3db 100644 --- a/qt_dotgraph/package.xml +++ b/qt_dotgraph/package.xml @@ -1,6 +1,6 @@ qt_dotgraph - 2.8.0 + 2.8.1 qt_dotgraph provides helpers to work with dot graphs. diff --git a/qt_gui/CHANGELOG.rst b/qt_gui/CHANGELOG.rst index 351edfb9..74bc6789 100644 --- a/qt_gui/CHANGELOG.rst +++ b/qt_gui/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package qt_gui ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +2.8.1 (2024-06-25) +------------------ 2.8.0 (2024-04-26) ------------------ diff --git a/qt_gui/package.xml b/qt_gui/package.xml index 4f967523..7b51117c 100644 --- a/qt_gui/package.xml +++ b/qt_gui/package.xml @@ -1,6 +1,6 @@ qt_gui - 2.8.0 + 2.8.1 qt_gui provides the infrastructure for an integrated graphical user interface based on Qt. It is extensible with Python- and C++-based plugins (implemented in separate packages) which can contribute arbitrary widgets. diff --git a/qt_gui_app/CHANGELOG.rst b/qt_gui_app/CHANGELOG.rst index 99ad94f7..502fe6ae 100644 --- a/qt_gui_app/CHANGELOG.rst +++ b/qt_gui_app/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package qt_gui_app ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +2.8.1 (2024-06-25) +------------------ 2.8.0 (2024-04-26) ------------------ diff --git a/qt_gui_app/package.xml b/qt_gui_app/package.xml index 9a566bb4..2c8a6339 100644 --- a/qt_gui_app/package.xml +++ b/qt_gui_app/package.xml @@ -1,6 +1,6 @@ qt_gui_app - 2.8.0 + 2.8.1 qt_gui_app provides the main to start an instance of the integrated graphical user interface provided by qt_gui. diff --git a/qt_gui_core/CHANGELOG.rst b/qt_gui_core/CHANGELOG.rst index 0822873b..26f3dff2 100644 --- a/qt_gui_core/CHANGELOG.rst +++ b/qt_gui_core/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package qt_gui_core ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +2.8.1 (2024-06-25) +------------------ 2.8.0 (2024-04-26) ------------------ diff --git a/qt_gui_core/package.xml b/qt_gui_core/package.xml index 00a017d6..04527edc 100644 --- a/qt_gui_core/package.xml +++ b/qt_gui_core/package.xml @@ -1,6 +1,6 @@ qt_gui_core - 2.8.0 + 2.8.1 Integration of the ROS package system and ROS-specific plugins for a Qt-based GUI. diff --git a/qt_gui_cpp/CHANGELOG.rst b/qt_gui_cpp/CHANGELOG.rst index 5048bbc7..53391c6b 100644 --- a/qt_gui_cpp/CHANGELOG.rst +++ b/qt_gui_cpp/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package qt_gui_cpp ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +2.8.1 (2024-06-25) +------------------ 2.8.0 (2024-04-26) ------------------ diff --git a/qt_gui_cpp/package.xml b/qt_gui_cpp/package.xml index 54d6d3d8..41d16cd3 100644 --- a/qt_gui_cpp/package.xml +++ b/qt_gui_cpp/package.xml @@ -1,6 +1,6 @@ qt_gui_cpp - 2.8.0 + 2.8.1 qt_gui_cpp provides the foundation for C++-bindings for qt_gui and creates bindings for every generator available. At least one specific binding must be available in order to use C++-plugins. diff --git a/qt_gui_py_common/CHANGELOG.rst b/qt_gui_py_common/CHANGELOG.rst index 78843ab3..d0511184 100644 --- a/qt_gui_py_common/CHANGELOG.rst +++ b/qt_gui_py_common/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package qt_gui_py_common ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +2.8.1 (2024-06-25) +------------------ 2.8.0 (2024-04-26) ------------------ diff --git a/qt_gui_py_common/package.xml b/qt_gui_py_common/package.xml index f746ef4a..48b344d4 100644 --- a/qt_gui_py_common/package.xml +++ b/qt_gui_py_common/package.xml @@ -1,6 +1,6 @@ qt_gui_py_common - 2.8.0 + 2.8.1 qt_gui_py_common provides common functionality for GUI plugins written in Python. From 93dc7e34fbb04cf5b9cde8eee86338888570980d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Hern=C3=A1ndez=20Cordero?= Date: Tue, 9 Jul 2024 14:53:32 +0200 Subject: [PATCH 3/3] Deprecated h headers (#294) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alejandro Hernández Cordero --- qt_gui_cpp/CMakeLists.txt | 9 +- .../qt_gui_cpp/composite_plugin_provider.h | 52 +-- .../qt_gui_cpp/composite_plugin_provider.hpp | 84 ++++ qt_gui_cpp/include/qt_gui_cpp/generic_proxy.h | 31 +- .../include/qt_gui_cpp/generic_proxy.hpp | 64 +++ qt_gui_cpp/include/qt_gui_cpp/plugin.h | 80 +--- qt_gui_cpp/include/qt_gui_cpp/plugin.hpp | 113 +++++ qt_gui_cpp/include/qt_gui_cpp/plugin_bridge.h | 48 +- .../include/qt_gui_cpp/plugin_bridge.hpp | 81 ++++ .../include/qt_gui_cpp/plugin_context.h | 90 +--- .../include/qt_gui_cpp/plugin_context.hpp | 124 +++++ .../include/qt_gui_cpp/plugin_descriptor.h | 49 +- .../include/qt_gui_cpp/plugin_descriptor.hpp | 82 ++++ .../include/qt_gui_cpp/plugin_provider.h | 44 +- .../include/qt_gui_cpp/plugin_provider.hpp | 77 ++++ .../qt_gui_cpp/recursive_plugin_provider.h | 36 +- .../qt_gui_cpp/recursive_plugin_provider.hpp | 69 +++ .../ros_pluginlib_plugin_provider.h | 390 +--------------- .../ros_pluginlib_plugin_provider.hpp | 423 ++++++++++++++++++ ...lib_plugin_provider_for_plugin_providers.h | 14 +- ...b_plugin_provider_for_plugin_providers.hpp | 46 ++ ...os_pluginlib_plugin_provider_for_plugins.h | 13 +- ..._pluginlib_plugin_provider_for_plugins.hpp | 46 ++ qt_gui_cpp/include/qt_gui_cpp/settings.h | 59 +-- qt_gui_cpp/include/qt_gui_cpp/settings.hpp | 92 ++++ .../qt_gui_cpp/composite_plugin_provider.cpp | 2 +- qt_gui_cpp/src/qt_gui_cpp/generic_proxy.cpp | 2 +- qt_gui_cpp/src/qt_gui_cpp/plugin_bridge.cpp | 9 +- qt_gui_cpp/src/qt_gui_cpp/plugin_context.cpp | 2 +- .../src/qt_gui_cpp/plugin_descriptor.cpp | 2 +- qt_gui_cpp/src/qt_gui_cpp/plugin_provider.cpp | 2 +- .../qt_gui_cpp/recursive_plugin_provider.cpp | 2 +- qt_gui_cpp/src/qt_gui_cpp/settings.cpp | 2 +- qt_gui_cpp/src/qt_gui_cpp_shiboken/global.h | 24 +- .../composite_plugin_provider.sip | 2 +- .../src/qt_gui_cpp_sip/generic_proxy.sip | 2 +- qt_gui_cpp/src/qt_gui_cpp_sip/plugin.sip | 2 +- .../src/qt_gui_cpp_sip/plugin_bridge.sip | 2 +- .../src/qt_gui_cpp_sip/plugin_context.sip | 2 +- .../src/qt_gui_cpp_sip/plugin_descriptor.sip | 2 +- .../src/qt_gui_cpp_sip/plugin_provider.sip | 2 +- .../recursive_plugin_provider.sip | 2 +- ...b_plugin_provider_for_plugin_providers.sip | 2 +- ..._pluginlib_plugin_provider_for_plugins.sip | 2 +- qt_gui_cpp/src/qt_gui_cpp_sip/settings.sip | 2 +- 45 files changed, 1399 insertions(+), 886 deletions(-) create mode 100644 qt_gui_cpp/include/qt_gui_cpp/composite_plugin_provider.hpp create mode 100644 qt_gui_cpp/include/qt_gui_cpp/generic_proxy.hpp create mode 100644 qt_gui_cpp/include/qt_gui_cpp/plugin.hpp create mode 100644 qt_gui_cpp/include/qt_gui_cpp/plugin_bridge.hpp create mode 100644 qt_gui_cpp/include/qt_gui_cpp/plugin_context.hpp create mode 100644 qt_gui_cpp/include/qt_gui_cpp/plugin_descriptor.hpp create mode 100644 qt_gui_cpp/include/qt_gui_cpp/plugin_provider.hpp create mode 100644 qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.hpp create mode 100644 qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.hpp create mode 100644 qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugin_providers.hpp create mode 100644 qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugins.hpp create mode 100644 qt_gui_cpp/include/qt_gui_cpp/settings.hpp diff --git a/qt_gui_cpp/CMakeLists.txt b/qt_gui_cpp/CMakeLists.txt index 1e8121a6..f424ae4d 100644 --- a/qt_gui_cpp/CMakeLists.txt +++ b/qt_gui_cpp/CMakeLists.txt @@ -39,9 +39,9 @@ set(qt_gui_cpp_SRCS ) set(qt_gui_cpp_HDRS - include/qt_gui_cpp/plugin.h - include/qt_gui_cpp/plugin_bridge.h - include/qt_gui_cpp/plugin_context.h + include/qt_gui_cpp/plugin.hpp + include/qt_gui_cpp/plugin_bridge.hpp + include/qt_gui_cpp/plugin_context.hpp ) qt5_wrap_cpp(qt_gui_cpp_MOCS ${qt_gui_cpp_HDRS}) @@ -83,9 +83,6 @@ install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib RUNTIME DESTINATION bin) -# TODO(brawner) add ament_lint_auto tests here. Much of the c++ code needs to -# be updated for ROS2 style - if(BUILD_TESTING) find_package(ament_cmake_pytest REQUIRED) diff --git a/qt_gui_cpp/include/qt_gui_cpp/composite_plugin_provider.h b/qt_gui_cpp/include/qt_gui_cpp/composite_plugin_provider.h index a5bac65c..b43b5f28 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/composite_plugin_provider.h +++ b/qt_gui_cpp/include/qt_gui_cpp/composite_plugin_provider.h @@ -33,52 +33,10 @@ #ifndef qt_gui_cpp__CompositePluginProvider_H #define qt_gui_cpp__CompositePluginProvider_H -#include "plugin_descriptor.h" -#include "plugin_provider.h" - -#include -#include -#include -#include - -namespace qt_gui_cpp -{ - -class CompositePluginProvider - : public PluginProvider -{ - -public: - - CompositePluginProvider(const QList& plugin_providers = QList()); - - virtual ~CompositePluginProvider(); - - /** - * @note The ownership of the plugin providers is transferred to the callee. - */ - virtual void set_plugin_providers(const QList& plugin_providers); - - virtual QList discover_descriptors(QObject* discovery_data); - - virtual void* load(const QString& plugin_id, PluginContext* plugin_context); - - virtual Plugin* load_plugin(const QString& plugin_id, PluginContext* plugin_context); - - virtual void unload(void* plugin_instance); - - virtual void shutdown(); - -private: - - QList plugin_providers_; - - QMap > discovered_plugins_; - - QMap running_plugins_; - -}; - -} // namespace +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header is deprecated, \ +include instead. +// *INDENT-ON* +#include "./composite_plugin_provider.hpp" #endif // qt_gui_cpp__CompositePluginProvider_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/composite_plugin_provider.hpp b/qt_gui_cpp/include/qt_gui_cpp/composite_plugin_provider.hpp new file mode 100644 index 00000000..1f8e40ed --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/composite_plugin_provider.hpp @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__CompositePluginProvider_HPP +#define qt_gui_cpp__CompositePluginProvider_HPP + +#include "plugin_descriptor.hpp" +#include "plugin_provider.hpp" + +#include +#include +#include +#include + +namespace qt_gui_cpp +{ + +class CompositePluginProvider + : public PluginProvider +{ + +public: + + CompositePluginProvider(const QList& plugin_providers = QList()); + + virtual ~CompositePluginProvider(); + + /** + * @note The ownership of the plugin providers is transferred to the callee. + */ + virtual void set_plugin_providers(const QList& plugin_providers); + + virtual QList discover_descriptors(QObject* discovery_data); + + virtual void* load(const QString& plugin_id, PluginContext* plugin_context); + + virtual Plugin* load_plugin(const QString& plugin_id, PluginContext* plugin_context); + + virtual void unload(void* plugin_instance); + + virtual void shutdown(); + +private: + + QList plugin_providers_; + + QMap > discovered_plugins_; + + QMap running_plugins_; + +}; + +} // namespace + +#endif // qt_gui_cpp__CompositePluginProvider_HPP diff --git a/qt_gui_cpp/include/qt_gui_cpp/generic_proxy.h b/qt_gui_cpp/include/qt_gui_cpp/generic_proxy.h index 14057487..3d2a8bef 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/generic_proxy.h +++ b/qt_gui_cpp/include/qt_gui_cpp/generic_proxy.h @@ -33,32 +33,11 @@ #ifndef qt_gui_cpp__GenericProxy_H #define qt_gui_cpp__GenericProxy_H -#include +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header is deprecated, \ +include instead. +// *INDENT-ON* -namespace qt_gui_cpp -{ - -class GenericProxy -{ - -public: - - GenericProxy(QObject* obj = 0); - - QObject* proxiedObject(); - - void setProxiedObject(QObject* obj); - - bool invokeMethod(const char* member, QGenericArgument val0 = QGenericArgument(), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), QGenericArgument val4 = QGenericArgument(), QGenericArgument val5 = QGenericArgument(), QGenericArgument val6 = QGenericArgument(), QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument()); - - bool invokeMethodWithReturn(const char* member, QGenericReturnArgument ret = QGenericReturnArgument(0, 0), QGenericArgument val0 = QGenericArgument(), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), QGenericArgument val4 = QGenericArgument(), QGenericArgument val5 = QGenericArgument(), QGenericArgument val6 = QGenericArgument(), QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument()); - -private: - - QObject* object_; - -}; - -} // namespace +#include "./generic_proxy.hpp" #endif // qt_gui_cpp__GenericProxy_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/generic_proxy.hpp b/qt_gui_cpp/include/qt_gui_cpp/generic_proxy.hpp new file mode 100644 index 00000000..c75f4840 --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/generic_proxy.hpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__GenericProxy_HPP +#define qt_gui_cpp__GenericProxy_HPP + +#include + +namespace qt_gui_cpp +{ + +class GenericProxy +{ + +public: + + GenericProxy(QObject* obj = 0); + + QObject* proxiedObject(); + + void setProxiedObject(QObject* obj); + + bool invokeMethod(const char* member, QGenericArgument val0 = QGenericArgument(), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), QGenericArgument val4 = QGenericArgument(), QGenericArgument val5 = QGenericArgument(), QGenericArgument val6 = QGenericArgument(), QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument()); + + bool invokeMethodWithReturn(const char* member, QGenericReturnArgument ret = QGenericReturnArgument(0, 0), QGenericArgument val0 = QGenericArgument(), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), QGenericArgument val4 = QGenericArgument(), QGenericArgument val5 = QGenericArgument(), QGenericArgument val6 = QGenericArgument(), QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument()); + +private: + + QObject* object_; + +}; + +} // namespace + +#endif // qt_gui_cpp__GenericProxy_HPP diff --git a/qt_gui_cpp/include/qt_gui_cpp/plugin.h b/qt_gui_cpp/include/qt_gui_cpp/plugin.h index 2164f010..ab71180a 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/plugin.h +++ b/qt_gui_cpp/include/qt_gui_cpp/plugin.h @@ -33,81 +33,11 @@ #ifndef qt_gui_cpp__Plugin_H #define qt_gui_cpp__Plugin_H -#include "plugin_bridge.h" -#include "plugin_context.h" -#include "settings.h" +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header is deprecated, \ +include instead. +// *INDENT-ON* -#include - -namespace qt_gui_cpp -{ - -/** - * The base class for C++ plugins. - */ -class Plugin - : public QObject -{ - - Q_OBJECT - -public: - - /** - * Construct the plugin. - * All initialization should be performed in initPlugin(). - */ - Plugin() - : QObject() - {} - - /** - * Instantiate the plugin. - * @param the plugin context - */ - virtual void initPlugin(PluginContext& /*context*/) - {} - - /** - * Shutdown and clean up the plugin before unloading. - */ - virtual void shutdownPlugin() - {} - - /** - * Save the intrinsic state of the plugin to the plugin-specific or instance-specific settings. - * @param the plugin-specific settings - * @param the instance-specific settings - */ - virtual void saveSettings(Settings& /*plugin_settings*/, Settings& /*instance_settings*/) const - {} - - /** - * Restore the intrinsic state of the plugin from the plugin-specific or instance-specific settings. - * @param the plugin-specific settings - * @param the instance-specific settings - */ - virtual void restoreSettings(const Settings& /*plugin_settings*/, const Settings& /*instance_settings*/) - {} - - /** - * Indicate if the plugin has configuration dialog which could be triggered by an icon in the title bar of the dock widgets. - * @return true if the plugin implements triggerConfiguration() - */ - virtual bool hasConfiguration() const - { - return false; - } - - /** - * Trigger a configuration dialog. - * If this method is reimplemented hasConfiguration() should also be reimplemented and return true. - */ - virtual void triggerConfiguration() - {} - -}; - -} // namespace +#include "./plugin.hpp" #endif // qt_gui_cpp__Plugin_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/plugin.hpp b/qt_gui_cpp/include/qt_gui_cpp/plugin.hpp new file mode 100644 index 00000000..0656ae36 --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/plugin.hpp @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__Plugin_HPP +#define qt_gui_cpp__Plugin_HPP + +#include "plugin_bridge.hpp" +#include "plugin_context.hpp" +#include "settings.hpp" + +#include + +namespace qt_gui_cpp +{ + +/** + * The base class for C++ plugins. + */ +class Plugin + : public QObject +{ + + Q_OBJECT + +public: + + /** + * Construct the plugin. + * All initialization should be performed in initPlugin(). + */ + Plugin() + : QObject() + {} + + /** + * Instantiate the plugin. + * @param the plugin context + */ + virtual void initPlugin(PluginContext& /*context*/) + {} + + /** + * Shutdown and clean up the plugin before unloading. + */ + virtual void shutdownPlugin() + {} + + /** + * Save the intrinsic state of the plugin to the plugin-specific or instance-specific settings. + * @param the plugin-specific settings + * @param the instance-specific settings + */ + virtual void saveSettings(Settings& /*plugin_settings*/, Settings& /*instance_settings*/) const + {} + + /** + * Restore the intrinsic state of the plugin from the plugin-specific or instance-specific settings. + * @param the plugin-specific settings + * @param the instance-specific settings + */ + virtual void restoreSettings(const Settings& /*plugin_settings*/, const Settings& /*instance_settings*/) + {} + + /** + * Indicate if the plugin has configuration dialog which could be triggered by an icon in the title bar of the dock widgets. + * @return true if the plugin implements triggerConfiguration() + */ + virtual bool hasConfiguration() const + { + return false; + } + + /** + * Trigger a configuration dialog. + * If this method is reimplemented hasConfiguration() should also be reimplemented and return true. + */ + virtual void triggerConfiguration() + {} + +}; + +} // namespace + +#endif // qt_gui_cpp__Plugin_HPP diff --git a/qt_gui_cpp/include/qt_gui_cpp/plugin_bridge.h b/qt_gui_cpp/include/qt_gui_cpp/plugin_bridge.h index 3f5bdf1e..3c66a7cc 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/plugin_bridge.h +++ b/qt_gui_cpp/include/qt_gui_cpp/plugin_bridge.h @@ -33,49 +33,11 @@ #ifndef qt_gui_cpp__PluginBridge_H #define qt_gui_cpp__PluginBridge_H -#include +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header is deprecated, \ +include instead. +// *INDENT-ON* -namespace qt_gui_cpp -{ - -class Plugin; -class PluginContext; -class PluginProvider; - -class PluginBridge - : public QObject -{ - - Q_OBJECT - -public: - - PluginBridge(); - - virtual bool load_plugin(PluginProvider* provider, const QString& plugin_id, PluginContext* plugin_context); - - virtual void unload_plugin(); - - virtual bool has_configuration() const; - - virtual void trigger_configuration(); - -public slots: - - virtual void shutdown_plugin(); - - virtual void save_settings(QObject* plugin_settings, QObject* instance_settings); - - virtual void restore_settings(QObject* plugin_settings, QObject* instance_settings); - -private: - - PluginProvider* provider_; - - Plugin* plugin_; - -}; - -} // namespace +#include "./plugin_bridge.hpp" #endif // qt_gui_cpp__PluginBridge_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/plugin_bridge.hpp b/qt_gui_cpp/include/qt_gui_cpp/plugin_bridge.hpp new file mode 100644 index 00000000..21d321a2 --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/plugin_bridge.hpp @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__PluginBridge_HPP +#define qt_gui_cpp__PluginBridge_HPP + +#include + +namespace qt_gui_cpp +{ + +class Plugin; +class PluginContext; +class PluginProvider; + +class PluginBridge + : public QObject +{ + + Q_OBJECT + +public: + + PluginBridge(); + + virtual bool load_plugin(PluginProvider* provider, const QString& plugin_id, PluginContext* plugin_context); + + virtual void unload_plugin(); + + virtual bool has_configuration() const; + + virtual void trigger_configuration(); + +public slots: + + virtual void shutdown_plugin(); + + virtual void save_settings(QObject* plugin_settings, QObject* instance_settings); + + virtual void restore_settings(QObject* plugin_settings, QObject* instance_settings); + +private: + + PluginProvider* provider_; + + Plugin* plugin_; + +}; + +} // namespace + +#endif // qt_gui_cpp__PluginBridge_HPP diff --git a/qt_gui_cpp/include/qt_gui_cpp/plugin_context.h b/qt_gui_cpp/include/qt_gui_cpp/plugin_context.h index fc7dee7a..78ce1f78 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/plugin_context.h +++ b/qt_gui_cpp/include/qt_gui_cpp/plugin_context.h @@ -33,92 +33,12 @@ #ifndef qt_gui_cpp__PluginContext_H #define qt_gui_cpp__PluginContext_H -#include "generic_proxy.h" +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header is deprecated, \ +include instead. +// *INDENT-ON* -#include -#include -#include -#include -// Upstream issue: https://codereview.qt-project.org/c/qt/qtbase/+/272258 -#if __GNUC__ >= 9 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-copy" -#endif -#include -#if __GNUC__ >= 9 -# pragma GCC diagnostic pop -#endif -#include +#include "./plugin_context.hpp" -namespace qt_gui_cpp -{ - -/** - * PluginContext providing information to the plugin and exposing methods for the plugin to interact with the framework. - * It relays all methods to the corresponding plugin handler. - */ -class PluginContext - : public QObject -{ - - Q_OBJECT - -public: - - PluginContext(QObject* obj, int serial_number, const QStringList& argv); - - PluginContext(const PluginContext& other); - - /** - * Return the serial number of the plugin. - * For a specific type of plugin each instance gets a serial number (which is the first currently not used positive integer at construction time). - * @return The serial number - */ - int serialNumber() const; - - /** - * Return the command line arguments of the plugin. - * @return The arguments without a program name at the beginning - */ - const QStringList& argv() const; - - /** - * Add a widget to the UI. - * The widget is embedded into a new QDockWidget which itself is added to the QMainWindow. - * This method can be called once for each widget a plugin would like to add and at any point in time (until the calling plugin has been shutdown). - * @note The ownership of the widget pointer is transferred to the callee which will delete it when the plugin is shut down. - * @param widget The widget to add - */ - void addWidget(QWidget* widget); - - /** - * Remove a previously added widget from the UI. - * @note The ownership of the widget pointer is transferred back to the caller which is responsible of deleting it. - * @param widget The widget to remove - */ - void removeWidget(QWidget* widget); - - /** - * Close the plugin. - * The framework will call `Plugin.shutdown_plugin()` and unload it afterwards. - */ - void closePlugin(); - - /** - * Reload the plugin. - */ - void reloadPlugin(); - -protected: - - GenericProxy proxy_; - - int serial_number_; - - QStringList argv_; - -}; - -} // namespace #endif // qt_gui_cpp__PluginContext_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/plugin_context.hpp b/qt_gui_cpp/include/qt_gui_cpp/plugin_context.hpp new file mode 100644 index 00000000..6046289f --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/plugin_context.hpp @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__PluginContext_HPP +#define qt_gui_cpp__PluginContext_HPP + +#include "generic_proxy.hpp" + +#include +#include +#include +#include +// Upstream issue: https://codereview.qt-project.org/c/qt/qtbase/+/272258 +#if __GNUC__ >= 9 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-copy" +#endif +#include +#if __GNUC__ >= 9 +# pragma GCC diagnostic pop +#endif +#include + +namespace qt_gui_cpp +{ + +/** + * PluginContext providing information to the plugin and exposing methods for the plugin to interact with the framework. + * It relays all methods to the corresponding plugin handler. + */ +class PluginContext + : public QObject +{ + + Q_OBJECT + +public: + + PluginContext(QObject* obj, int serial_number, const QStringList& argv); + + PluginContext(const PluginContext& other); + + /** + * Return the serial number of the plugin. + * For a specific type of plugin each instance gets a serial number (which is the first currently not used positive integer at construction time). + * @return The serial number + */ + int serialNumber() const; + + /** + * Return the command line arguments of the plugin. + * @return The arguments without a program name at the beginning + */ + const QStringList& argv() const; + + /** + * Add a widget to the UI. + * The widget is embedded into a new QDockWidget which itself is added to the QMainWindow. + * This method can be called once for each widget a plugin would like to add and at any point in time (until the calling plugin has been shutdown). + * @note The ownership of the widget pointer is transferred to the callee which will delete it when the plugin is shut down. + * @param widget The widget to add + */ + void addWidget(QWidget* widget); + + /** + * Remove a previously added widget from the UI. + * @note The ownership of the widget pointer is transferred back to the caller which is responsible of deleting it. + * @param widget The widget to remove + */ + void removeWidget(QWidget* widget); + + /** + * Close the plugin. + * The framework will call `Plugin.shutdown_plugin()` and unload it afterwards. + */ + void closePlugin(); + + /** + * Reload the plugin. + */ + void reloadPlugin(); + +protected: + + GenericProxy proxy_; + + int serial_number_; + + QStringList argv_; + +}; + +} // namespace + +#endif // qt_gui_cpp__PluginContext_HPP diff --git a/qt_gui_cpp/include/qt_gui_cpp/plugin_descriptor.h b/qt_gui_cpp/include/qt_gui_cpp/plugin_descriptor.h index 85a38e51..909fd33f 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/plugin_descriptor.h +++ b/qt_gui_cpp/include/qt_gui_cpp/plugin_descriptor.h @@ -33,50 +33,11 @@ #ifndef qt_gui_cpp__PluginDescriptor_H #define qt_gui_cpp__PluginDescriptor_H -#include -#include -#include +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header is deprecated, \ +include instead. +// *INDENT-ON* -namespace qt_gui_cpp -{ - -class PluginDescriptor -{ - -public: - - PluginDescriptor(const QString& plugin_id, const QMap& attributes = (QMap())); - - const QString& pluginId() const; - - const QMap& attributes() const; - - QMap& attributes(); - - const QMap& actionAttributes() const; - - void setActionAttributes(const QString& label, const QString& statustip = QString(), const QString& icon = QString(), const QString& icontype = QString()); - - int countGroups() const; - - QMap group(int index) const; - - void addGroupAttributes(const QString& label, const QString& statustip = QString(), const QString& icon = QString(), const QString& icontype = QString()); - - QMap toDictionary() const; - -protected: - - QString plugin_id_; - - QMap attributes_; - - QMap action_attributes_; - - QVector > groups_; - -}; - -} // namespace +#include "./plugin_descriptor.hpp" #endif // qt_gui_cpp__PluginDescriptor_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/plugin_descriptor.hpp b/qt_gui_cpp/include/qt_gui_cpp/plugin_descriptor.hpp new file mode 100644 index 00000000..07684139 --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/plugin_descriptor.hpp @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__PluginDescriptor_HPP +#define qt_gui_cpp__PluginDescriptor_HPP + +#include +#include +#include + +namespace qt_gui_cpp +{ + +class PluginDescriptor +{ + +public: + + PluginDescriptor(const QString& plugin_id, const QMap& attributes = (QMap())); + + const QString& pluginId() const; + + const QMap& attributes() const; + + QMap& attributes(); + + const QMap& actionAttributes() const; + + void setActionAttributes(const QString& label, const QString& statustip = QString(), const QString& icon = QString(), const QString& icontype = QString()); + + int countGroups() const; + + QMap group(int index) const; + + void addGroupAttributes(const QString& label, const QString& statustip = QString(), const QString& icon = QString(), const QString& icontype = QString()); + + QMap toDictionary() const; + +protected: + + QString plugin_id_; + + QMap attributes_; + + QMap action_attributes_; + + QVector > groups_; + +}; + +} // namespace + +#endif // qt_gui_cpp__PluginDescriptor_HPP diff --git a/qt_gui_cpp/include/qt_gui_cpp/plugin_provider.h b/qt_gui_cpp/include/qt_gui_cpp/plugin_provider.h index d5ef0759..6a5d898d 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/plugin_provider.h +++ b/qt_gui_cpp/include/qt_gui_cpp/plugin_provider.h @@ -33,45 +33,11 @@ #ifndef qt_gui_cpp__PluginProvider_H #define qt_gui_cpp__PluginProvider_H -#include "plugin.h" -#include "plugin_context.h" -#include "plugin_descriptor.h" +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header is deprecated, \ +include instead. +// *INDENT-ON* -#include -#include -#include - -namespace qt_gui_cpp -{ - -class PluginProvider -{ - -public: - - PluginProvider(); - - virtual ~PluginProvider(); - - virtual QMap discover(QObject* discovery_data); - - /** - * @attention Ownership of returned PluginDescriptor's is transfered to the caller - */ - virtual QList discover_descriptors(QObject* discovery_data); - - virtual void* load(const QString& plugin_id, PluginContext* plugin_context); - - virtual Plugin* load_plugin(const QString& plugin_id, PluginContext* plugin_context); - - virtual void unload(void* plugin_instance); - - virtual void unload_plugin(Plugin* plugin_instance); - - virtual void shutdown(); - -}; - -} // namespace +#include "./plugin_provider.hpp" #endif // qt_gui_cpp__PluginProvider_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/plugin_provider.hpp b/qt_gui_cpp/include/qt_gui_cpp/plugin_provider.hpp new file mode 100644 index 00000000..5dbb076a --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/plugin_provider.hpp @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__PluginProvider_HPP +#define qt_gui_cpp__PluginProvider_HPP + +#include "plugin.hpp" +#include "plugin_context.hpp" +#include "plugin_descriptor.hpp" + +#include +#include +#include + +namespace qt_gui_cpp +{ + +class PluginProvider +{ + +public: + + PluginProvider(); + + virtual ~PluginProvider(); + + virtual QMap discover(QObject* discovery_data); + + /** + * @attention Ownership of returned PluginDescriptor's is transfered to the caller + */ + virtual QList discover_descriptors(QObject* discovery_data); + + virtual void* load(const QString& plugin_id, PluginContext* plugin_context); + + virtual Plugin* load_plugin(const QString& plugin_id, PluginContext* plugin_context); + + virtual void unload(void* plugin_instance); + + virtual void unload_plugin(Plugin* plugin_instance); + + virtual void shutdown(); + +}; + +} // namespace + +#endif // qt_gui_cpp__PluginProvider_HPP diff --git a/qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.h b/qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.h index 087b578a..43437bb0 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.h +++ b/qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.h @@ -33,37 +33,11 @@ #ifndef qt_gui_cpp__RecursivePluginProvider_H #define qt_gui_cpp__RecursivePluginProvider_H -#include "composite_plugin_provider.h" -#include "ros_pluginlib_plugin_provider_for_plugin_providers.h" +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header is deprecated, \ +include instead. +// *INDENT-ON* -#include -#include -#include - -namespace qt_gui_cpp -{ - -class RecursivePluginProvider - : public CompositePluginProvider -{ - -public: - - RecursivePluginProvider(RosPluginlibPluginProvider_ForPluginProviders* plugin_provider); - - virtual ~RecursivePluginProvider(); - - virtual QMap discover(QObject* discovery_data); - - virtual void shutdown(); - -private: - - RosPluginlibPluginProvider_ForPluginProviders* plugin_provider_; - QList providers_; - -}; - -} // namespace +#include "./recursive_plugin_provider.hpp" #endif // qt_gui_cpp__RecursivePluginProvider_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.hpp b/qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.hpp new file mode 100644 index 00000000..427377c7 --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/recursive_plugin_provider.hpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__RecursivePluginProvider_HPP +#define qt_gui_cpp__RecursivePluginProvider_HPP + +#include "composite_plugin_provider.hpp" +#include "ros_pluginlib_plugin_provider_for_plugin_providers.hpp" + +#include +#include +#include + +namespace qt_gui_cpp +{ + +class RecursivePluginProvider + : public CompositePluginProvider +{ + +public: + + RecursivePluginProvider(RosPluginlibPluginProvider_ForPluginProviders* plugin_provider); + + virtual ~RecursivePluginProvider(); + + virtual QMap discover(QObject* discovery_data); + + virtual void shutdown(); + +private: + + RosPluginlibPluginProvider_ForPluginProviders* plugin_provider_; + QList providers_; + +}; + +} // namespace + +#endif // qt_gui_cpp__RecursivePluginProvider_HPP diff --git a/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.h b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.h index 054e6c87..78f74f4b 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.h +++ b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.h @@ -33,391 +33,11 @@ #ifndef qt_gui_cpp__RosPluginlibPluginProvider_H #define qt_gui_cpp__RosPluginlibPluginProvider_H -// Pluginlib has an optional dependency on boost::shared_ptr, which is not required here -// On machines without boost, including pluginlib/class_loader.hpp requires defining this flag to -// disable that dependency. Mosty notably these are the machines configured on ci.ros2.org -#define PLUGINLIB__DISABLE_BOOST_FUNCTIONS +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header is deprecated, \ +include instead. +// *INDENT-ON* -#include "plugin.h" -#include "plugin_context.h" -#include "plugin_descriptor.h" -#include "plugin_provider.h" - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace qt_gui_cpp -{ - -template -class RosPluginlibPluginProvider - : public QObject - , public PluginProvider -{ - -public: - - static RosPluginlibPluginProvider* create_instance(const QString& export_tag, const QString& base_class_type) - { - return new RosPluginlibPluginProvider(export_tag, base_class_type); - } - - RosPluginlibPluginProvider(const QString& export_tag, const QString& base_class_type) - : QObject() - , PluginProvider() - , export_tag_(export_tag) - , base_class_type_(base_class_type) - , class_loader_(0) - { - unload_libraries_event_ = QEvent::registerEventType(); - } - - virtual ~RosPluginlibPluginProvider() - { - if (class_loader_) - { - delete class_loader_; - } - } - - virtual QMap discover(QObject* discovery_data) - { - return PluginProvider::discover(discovery_data); - } - - virtual QList discover_descriptors(QObject* discovery_data) - { - if (class_loader_) - { - delete class_loader_; - } - - Settings discovery_settings(discovery_data); - QString key = "qt_gui_cpp.RosPluginlibPluginProvider/" + export_tag_ + " " + base_class_type_; - bool is_cached = discovery_settings.contains(key); - - std::vector plugin_xml_paths; - // reuse plugin paths from cache if available - if (is_cached) - { - QStringList paths = discovery_settings.value(key).toStringList(); - for (QStringList::const_iterator it = paths.begin(); it != paths.end(); it++) - { - plugin_xml_paths.push_back(it->toStdString()); - } - } - else - { - qDebug("RosPluginlibPluginProvider::discover_descriptors() crawling for plugins of type '%s' and base class '%s'", export_tag_.toStdString().c_str(), base_class_type_.toStdString().c_str()); - } - class_loader_ = new pluginlib::ClassLoader(export_tag_.toStdString(), base_class_type_.toStdString(), std::string("plugin"), plugin_xml_paths); - - if (!is_cached) - { - // save discovered paths - std::vector paths = class_loader_->getPluginXmlPaths(); - QStringList qpaths; - for (std::vector::const_iterator it = paths.begin(); it != paths.end(); it++) - { - qpaths.push_back(it->c_str()); - } - discovery_settings.setValue(key, qpaths); - } - - QList descriptors; - - std::vector classes = class_loader_->getDeclaredClasses(); - for (std::vector::iterator it = classes.begin(); it != classes.end(); it++) - { - std::string lookup_name = *it; - - std::string name = class_loader_->getName(lookup_name); - std::string plugin_xml = class_loader_->getPluginManifestPath(lookup_name); - std::filesystem::path p(plugin_xml); - std::string plugin_path = p.parent_path().string(); - - QMap attributes; - attributes["class_name"] = name.c_str(); - attributes["class_type"] = class_loader_->getClassType(lookup_name).c_str(); - attributes["class_base_class_type"] = class_loader_->getBaseClassType().c_str(); - attributes["package_name"] = class_loader_->getClassPackage(lookup_name).c_str(); - attributes["plugin_path"] = plugin_path.c_str(); - - // check if plugin is available - //std::string library_path = class_loader_->getClassLibraryPath(lookup_name); - //attributes["not_available"] = !std::ifstream(library_path.c_str()) ? QString("library ").append(lookup_name.c_str()).append(" not found (may be it must be built?)") : ""; - attributes["not_available"] = ""; - - PluginDescriptor* plugin_descriptor = new PluginDescriptor(lookup_name.c_str(), attributes); - QString label = name.c_str(); - QString statustip = class_loader_->getClassDescription(lookup_name).c_str(); - QString icon; - QString icontype; - parseManifest(lookup_name, plugin_path, label, statustip, icon, icontype, plugin_descriptor); - plugin_descriptor->setActionAttributes(label, statustip, icon, icontype); - - // add plugin descriptor - descriptors.append(plugin_descriptor); - } - return descriptors; - } - - virtual void* load(const QString& plugin_id, PluginContext* plugin_context) - { - return load_explicit_type(plugin_id, plugin_context); - } - - virtual Plugin* load_plugin(const QString& plugin_id, PluginContext* plugin_context) - { - T* instance = load_explicit_type(plugin_id, plugin_context); - if (instance == 0) - { - return 0; - } - Plugin* plugin = dynamic_cast(instance); - if (plugin == 0) - { - // TODO: garbage instance - qWarning("RosPluginlibPluginProvider::load_plugin() called on non-plugin plugin provider"); - return 0; - } - return plugin; - } - - virtual T* load_explicit_type(const QString& plugin_id, PluginContext* plugin_context) - { - std::string lookup_name = plugin_id.toStdString(); - - if (!class_loader_->isClassAvailable(lookup_name)) - { - qWarning("RosPluginlibPluginProvider::load_explicit_type(%s) class not available", lookup_name.c_str()); - return 0; - } - - std::shared_ptr instance; - try - { - instance = create_plugin(lookup_name, plugin_context); - } - catch (pluginlib::LibraryLoadException& e) - { - qWarning("RosPluginlibPluginProvider::load_explicit_type(%s) could not load library (%s)", lookup_name.c_str(), e.what()); - return 0; - } - catch (pluginlib::PluginlibException& e) - { - qWarning("RosPluginlibPluginProvider::load_explicit_type(%s) failed creating instance (%s)", lookup_name.c_str(), e.what()); - return 0; - } - - if (!instance) - { - qWarning("RosPluginlibPluginProvider::load_explicit_type(%s) failed creating instance", lookup_name.c_str()); - return 0; - } - - // pass context to plugin - Plugin* plugin = dynamic_cast(&*instance); - if (plugin) - { - try - { - init_plugin(plugin_id, plugin_context, plugin); - } - catch (std::exception& e) - { - // TODO: garbage instance - qWarning("RosPluginlibPluginProvider::load_explicit_type(%s) failed initializing plugin (%s)", lookup_name.c_str(), e.what()); - return 0; - } - } - - //qDebug("RosPluginlibPluginProvider::load_explicit_type(%s) succeeded", lookup_name.c_str()); - instances_[&*instance] = instance; - - return &*instance; - } - - virtual void unload(void* instance) - { - if (!instances_.contains(instance)) - { - qCritical("RosPluginlibPluginProvider::unload() instance not found"); - return; - } - - std::shared_ptr pointer = instances_.take(instance); - libraries_to_unload_.append(pointer); - - QCoreApplication::postEvent(this, new QEvent(static_cast(unload_libraries_event_))); - } - - bool event(QEvent* e) - { - if (e->type() == unload_libraries_event_) - { - libraries_to_unload_.clear(); - return true; - } - return QObject::event(e); - } - -protected: - - virtual std::shared_ptr create_plugin(const std::string& lookup_name, PluginContext* /*plugin_context*/ = 0) - { - return class_loader_->createSharedInstance(lookup_name); - } - - virtual void init_plugin(const QString& /*plugin_id*/, PluginContext* plugin_context, Plugin* plugin) - { - plugin->initPlugin(*plugin_context); - } - -private: - - template - struct TinyXMLAPIChoice - { - template< - // the function signature must use a template argument to trigger SFINAE - typename TDoc, - // T needs to be an explicit argument for std::enable_if to have a type - typename TType = TVersion, - // only enable for TinyXML versions >= 6 - typename = typename std::enable_if::value>::type - > - static void warningWithErrorStr(const std::string & manifest_path, const TDoc & doc, std::true_type * = nullptr) - { - qWarning("RosPluginlibPluginProvider::parseManifest() could not load manifest \"%s\" (%s)", manifest_path.c_str(), doc.ErrorStr()); - } - template< - typename TDoc, - typename TType = TVersion, - typename = typename std::enable_if::value>::type - > - static void warningWithErrorStr(const std::string & manifest_path, const TDoc & doc, std::false_type * = nullptr) - { - qWarning("RosPluginlibPluginProvider::parseManifest() could not load manifest \"%s\" (%s, %s)", manifest_path.c_str(), doc.GetErrorStr1(), doc.GetErrorStr2()); - } - }; - - bool parseManifest(const std::string& lookup_name, const std::string& plugin_path, QString& label, QString& statustip, QString& icon, QString& icontype, PluginDescriptor* plugin_descriptor) - { - //qDebug("RosPluginlibPluginProvider::parseManifest()"); - - std::string manifest_path = class_loader_->getPluginManifestPath(lookup_name); - //qDebug("RosPluginlibPluginProvider::parseManifest() manifest_path \"%s\"", manifest_path.c_str()); - tinyxml2::XMLDocument doc; - tinyxml2::XMLError result = doc.LoadFile(manifest_path.c_str()); - if (result != tinyxml2::XML_SUCCESS) - { - TinyXMLAPIChoice= 6)>>::warningWithErrorStr(manifest_path, doc); - return false; - } - - // search library-tag with specific path-attribute - std::string class_type = class_loader_->getClassType(lookup_name); - tinyxml2::XMLElement* library_element = doc.FirstChildElement("library"); - while (library_element) - { - // search class-tag with specific type- and base_class_type-attribute - tinyxml2::XMLElement* class_element = library_element->FirstChildElement("class"); - while (class_element) - { - if (class_type.compare(class_element->Attribute("type")) == 0 && base_class_type_.compare(class_element->Attribute("base_class_type")) == 0) - { - tinyxml2::XMLElement* qtgui_element = class_element->FirstChildElement("qtgui"); - if (qtgui_element) - { - // extract meta information - parseActionAttributes(qtgui_element, plugin_path, label, statustip, icon, icontype); - - // extract grouping information - tinyxml2::XMLElement* group_element = qtgui_element->FirstChildElement("group"); - while (group_element) - { - QString group_label; - QString group_statustip; - QString group_icon; - QString group_icontype; - parseActionAttributes(group_element, plugin_path, group_label, group_statustip, group_icon, group_icontype); - plugin_descriptor->addGroupAttributes(group_label, group_statustip, group_icon, group_icontype); - - group_element = group_element->NextSiblingElement("group"); - } - } - return true; - } - class_element = class_element->NextSiblingElement("class"); - } - break; - - library_element = library_element->NextSiblingElement("library"); - } - - qWarning("RosPluginlibPluginProvider::parseManifest() could not handle manifest \"%s\"", manifest_path.c_str()); - return false; - } - - void parseActionAttributes(tinyxml2::XMLElement* element, const std::string& plugin_path, QString& label, QString& statustip, QString& icon, QString& icontype) - { - tinyxml2::XMLElement* child_element; - if ((child_element = element->FirstChildElement("label")) != 0) - { - label = child_element->GetText(); - } - if ((child_element = element->FirstChildElement("icon")) != 0) - { - icontype = child_element->Attribute("type"); - if (icontype == "file") - { - // prepend base path - icon = plugin_path.c_str(); - icon += "/"; - icon += child_element->GetText(); - } - else - { - icon = child_element->GetText(); - } - } - if ((child_element = element->FirstChildElement("statustip")) != 0) - { - statustip = child_element->GetText(); - } - } - - void unload_pending_libraries() - { - } - - QString export_tag_; - - QString base_class_type_; - - int unload_libraries_event_; - - pluginlib::ClassLoader* class_loader_; - - QMap > instances_; - - QList > libraries_to_unload_; - -}; - -} // namespace +#include "./ros_pluginlib_plugin_provider.hpp" #endif // qt_gui_cpp__RosPluginlibPluginProvider_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.hpp b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.hpp new file mode 100644 index 00000000..a83ea8ac --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider.hpp @@ -0,0 +1,423 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__RosPluginlibPluginProvider_HPP +#define qt_gui_cpp__RosPluginlibPluginProvider_HPP + +// Pluginlib has an optional dependency on boost::shared_ptr, which is not required here +// On machines without boost, including pluginlib/class_loader.hpp requires defining this flag to +// disable that dependency. Mosty notably these are the machines configured on ci.ros2.org +#define PLUGINLIB__DISABLE_BOOST_FUNCTIONS + +#include "plugin.hpp" +#include "plugin_context.hpp" +#include "plugin_descriptor.hpp" +#include "plugin_provider.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace qt_gui_cpp +{ + +template +class RosPluginlibPluginProvider + : public QObject + , public PluginProvider +{ + +public: + + static RosPluginlibPluginProvider* create_instance(const QString& export_tag, const QString& base_class_type) + { + return new RosPluginlibPluginProvider(export_tag, base_class_type); + } + + RosPluginlibPluginProvider(const QString& export_tag, const QString& base_class_type) + : QObject() + , PluginProvider() + , export_tag_(export_tag) + , base_class_type_(base_class_type) + , class_loader_(0) + { + unload_libraries_event_ = QEvent::registerEventType(); + } + + virtual ~RosPluginlibPluginProvider() + { + if (class_loader_) + { + delete class_loader_; + } + } + + virtual QMap discover(QObject* discovery_data) + { + return PluginProvider::discover(discovery_data); + } + + virtual QList discover_descriptors(QObject* discovery_data) + { + if (class_loader_) + { + delete class_loader_; + } + + Settings discovery_settings(discovery_data); + QString key = "qt_gui_cpp.RosPluginlibPluginProvider/" + export_tag_ + " " + base_class_type_; + bool is_cached = discovery_settings.contains(key); + + std::vector plugin_xml_paths; + // reuse plugin paths from cache if available + if (is_cached) + { + QStringList paths = discovery_settings.value(key).toStringList(); + for (QStringList::const_iterator it = paths.begin(); it != paths.end(); it++) + { + plugin_xml_paths.push_back(it->toStdString()); + } + } + else + { + qDebug("RosPluginlibPluginProvider::discover_descriptors() crawling for plugins of type '%s' and base class '%s'", export_tag_.toStdString().c_str(), base_class_type_.toStdString().c_str()); + } + class_loader_ = new pluginlib::ClassLoader(export_tag_.toStdString(), base_class_type_.toStdString(), std::string("plugin"), plugin_xml_paths); + + if (!is_cached) + { + // save discovered paths + std::vector paths = class_loader_->getPluginXmlPaths(); + QStringList qpaths; + for (std::vector::const_iterator it = paths.begin(); it != paths.end(); it++) + { + qpaths.push_back(it->c_str()); + } + discovery_settings.setValue(key, qpaths); + } + + QList descriptors; + + std::vector classes = class_loader_->getDeclaredClasses(); + for (std::vector::iterator it = classes.begin(); it != classes.end(); it++) + { + std::string lookup_name = *it; + + std::string name = class_loader_->getName(lookup_name); + std::string plugin_xml = class_loader_->getPluginManifestPath(lookup_name); + std::filesystem::path p(plugin_xml); + std::string plugin_path = p.parent_path().string(); + + QMap attributes; + attributes["class_name"] = name.c_str(); + attributes["class_type"] = class_loader_->getClassType(lookup_name).c_str(); + attributes["class_base_class_type"] = class_loader_->getBaseClassType().c_str(); + attributes["package_name"] = class_loader_->getClassPackage(lookup_name).c_str(); + attributes["plugin_path"] = plugin_path.c_str(); + + // check if plugin is available + //std::string library_path = class_loader_->getClassLibraryPath(lookup_name); + //attributes["not_available"] = !std::ifstream(library_path.c_str()) ? QString("library ").append(lookup_name.c_str()).append(" not found (may be it must be built?)") : ""; + attributes["not_available"] = ""; + + PluginDescriptor* plugin_descriptor = new PluginDescriptor(lookup_name.c_str(), attributes); + QString label = name.c_str(); + QString statustip = class_loader_->getClassDescription(lookup_name).c_str(); + QString icon; + QString icontype; + parseManifest(lookup_name, plugin_path, label, statustip, icon, icontype, plugin_descriptor); + plugin_descriptor->setActionAttributes(label, statustip, icon, icontype); + + // add plugin descriptor + descriptors.append(plugin_descriptor); + } + return descriptors; + } + + virtual void* load(const QString& plugin_id, PluginContext* plugin_context) + { + return load_explicit_type(plugin_id, plugin_context); + } + + virtual Plugin* load_plugin(const QString& plugin_id, PluginContext* plugin_context) + { + T* instance = load_explicit_type(plugin_id, plugin_context); + if (instance == 0) + { + return 0; + } + Plugin* plugin = dynamic_cast(instance); + if (plugin == 0) + { + // TODO: garbage instance + qWarning("RosPluginlibPluginProvider::load_plugin() called on non-plugin plugin provider"); + return 0; + } + return plugin; + } + + virtual T* load_explicit_type(const QString& plugin_id, PluginContext* plugin_context) + { + std::string lookup_name = plugin_id.toStdString(); + + if (!class_loader_->isClassAvailable(lookup_name)) + { + qWarning("RosPluginlibPluginProvider::load_explicit_type(%s) class not available", lookup_name.c_str()); + return 0; + } + + std::shared_ptr instance; + try + { + instance = create_plugin(lookup_name, plugin_context); + } + catch (pluginlib::LibraryLoadException& e) + { + qWarning("RosPluginlibPluginProvider::load_explicit_type(%s) could not load library (%s)", lookup_name.c_str(), e.what()); + return 0; + } + catch (pluginlib::PluginlibException& e) + { + qWarning("RosPluginlibPluginProvider::load_explicit_type(%s) failed creating instance (%s)", lookup_name.c_str(), e.what()); + return 0; + } + + if (!instance) + { + qWarning("RosPluginlibPluginProvider::load_explicit_type(%s) failed creating instance", lookup_name.c_str()); + return 0; + } + + // pass context to plugin + Plugin* plugin = dynamic_cast(&*instance); + if (plugin) + { + try + { + init_plugin(plugin_id, plugin_context, plugin); + } + catch (std::exception& e) + { + // TODO: garbage instance + qWarning("RosPluginlibPluginProvider::load_explicit_type(%s) failed initializing plugin (%s)", lookup_name.c_str(), e.what()); + return 0; + } + } + + //qDebug("RosPluginlibPluginProvider::load_explicit_type(%s) succeeded", lookup_name.c_str()); + instances_[&*instance] = instance; + + return &*instance; + } + + virtual void unload(void* instance) + { + if (!instances_.contains(instance)) + { + qCritical("RosPluginlibPluginProvider::unload() instance not found"); + return; + } + + std::shared_ptr pointer = instances_.take(instance); + libraries_to_unload_.append(pointer); + + QCoreApplication::postEvent(this, new QEvent(static_cast(unload_libraries_event_))); + } + + bool event(QEvent* e) + { + if (e->type() == unload_libraries_event_) + { + libraries_to_unload_.clear(); + return true; + } + return QObject::event(e); + } + +protected: + + virtual std::shared_ptr create_plugin(const std::string& lookup_name, PluginContext* /*plugin_context*/ = 0) + { + return class_loader_->createSharedInstance(lookup_name); + } + + virtual void init_plugin(const QString& /*plugin_id*/, PluginContext* plugin_context, Plugin* plugin) + { + plugin->initPlugin(*plugin_context); + } + +private: + + template + struct TinyXMLAPIChoice + { + template< + // the function signature must use a template argument to trigger SFINAE + typename TDoc, + // T needs to be an explicit argument for std::enable_if to have a type + typename TType = TVersion, + // only enable for TinyXML versions >= 6 + typename = typename std::enable_if::value>::type + > + static void warningWithErrorStr(const std::string & manifest_path, const TDoc & doc, std::true_type * = nullptr) + { + qWarning("RosPluginlibPluginProvider::parseManifest() could not load manifest \"%s\" (%s)", manifest_path.c_str(), doc.ErrorStr()); + } + template< + typename TDoc, + typename TType = TVersion, + typename = typename std::enable_if::value>::type + > + static void warningWithErrorStr(const std::string & manifest_path, const TDoc & doc, std::false_type * = nullptr) + { + qWarning("RosPluginlibPluginProvider::parseManifest() could not load manifest \"%s\" (%s, %s)", manifest_path.c_str(), doc.GetErrorStr1(), doc.GetErrorStr2()); + } + }; + + bool parseManifest(const std::string& lookup_name, const std::string& plugin_path, QString& label, QString& statustip, QString& icon, QString& icontype, PluginDescriptor* plugin_descriptor) + { + //qDebug("RosPluginlibPluginProvider::parseManifest()"); + + std::string manifest_path = class_loader_->getPluginManifestPath(lookup_name); + //qDebug("RosPluginlibPluginProvider::parseManifest() manifest_path \"%s\"", manifest_path.c_str()); + tinyxml2::XMLDocument doc; + tinyxml2::XMLError result = doc.LoadFile(manifest_path.c_str()); + if (result != tinyxml2::XML_SUCCESS) + { + TinyXMLAPIChoice= 6)>>::warningWithErrorStr(manifest_path, doc); + return false; + } + + // search library-tag with specific path-attribute + std::string class_type = class_loader_->getClassType(lookup_name); + tinyxml2::XMLElement* library_element = doc.FirstChildElement("library"); + while (library_element) + { + // search class-tag with specific type- and base_class_type-attribute + tinyxml2::XMLElement* class_element = library_element->FirstChildElement("class"); + while (class_element) + { + if (class_type.compare(class_element->Attribute("type")) == 0 && base_class_type_.compare(class_element->Attribute("base_class_type")) == 0) + { + tinyxml2::XMLElement* qtgui_element = class_element->FirstChildElement("qtgui"); + if (qtgui_element) + { + // extract meta information + parseActionAttributes(qtgui_element, plugin_path, label, statustip, icon, icontype); + + // extract grouping information + tinyxml2::XMLElement* group_element = qtgui_element->FirstChildElement("group"); + while (group_element) + { + QString group_label; + QString group_statustip; + QString group_icon; + QString group_icontype; + parseActionAttributes(group_element, plugin_path, group_label, group_statustip, group_icon, group_icontype); + plugin_descriptor->addGroupAttributes(group_label, group_statustip, group_icon, group_icontype); + + group_element = group_element->NextSiblingElement("group"); + } + } + return true; + } + class_element = class_element->NextSiblingElement("class"); + } + break; + + library_element = library_element->NextSiblingElement("library"); + } + + qWarning("RosPluginlibPluginProvider::parseManifest() could not handle manifest \"%s\"", manifest_path.c_str()); + return false; + } + + void parseActionAttributes(tinyxml2::XMLElement* element, const std::string& plugin_path, QString& label, QString& statustip, QString& icon, QString& icontype) + { + tinyxml2::XMLElement* child_element; + if ((child_element = element->FirstChildElement("label")) != 0) + { + label = child_element->GetText(); + } + if ((child_element = element->FirstChildElement("icon")) != 0) + { + icontype = child_element->Attribute("type"); + if (icontype == "file") + { + // prepend base path + icon = plugin_path.c_str(); + icon += "/"; + icon += child_element->GetText(); + } + else + { + icon = child_element->GetText(); + } + } + if ((child_element = element->FirstChildElement("statustip")) != 0) + { + statustip = child_element->GetText(); + } + } + + void unload_pending_libraries() + { + } + + QString export_tag_; + + QString base_class_type_; + + int unload_libraries_event_; + + pluginlib::ClassLoader* class_loader_; + + QMap > instances_; + + QList > libraries_to_unload_; + +}; + +} // namespace + +#endif // qt_gui_cpp__RosPluginlibPluginProvider_HPP diff --git a/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugin_providers.h b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugin_providers.h index 635d42a4..a270c504 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugin_providers.h +++ b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugin_providers.h @@ -33,14 +33,12 @@ #ifndef qt_gui_cpp__RosPluginlibPluginProvider_ForPluginProviders_H #define qt_gui_cpp__RosPluginlibPluginProvider_ForPluginProviders_H -#include "plugin_provider.h" -#include "ros_pluginlib_plugin_provider.h" +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header \ +is deprecated, include \ +instead. +// *INDENT-ON* -namespace qt_gui_cpp -{ - -typedef RosPluginlibPluginProvider RosPluginlibPluginProvider_ForPluginProviders; - -} // namespace +#include "./ros_pluginlib_plugin_provider_for_plugin_providers.hpp" #endif // qt_gui_cpp__RosPluginlibPluginProvider_ForPluginProviders_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugin_providers.hpp b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugin_providers.hpp new file mode 100644 index 00000000..8be2b2df --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugin_providers.hpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__RosPluginlibPluginProvider_ForPluginProviders_HPP +#define qt_gui_cpp__RosPluginlibPluginProvider_ForPluginProviders_HPP + +#include "plugin_provider.hpp" +#include "ros_pluginlib_plugin_provider.hpp" + +namespace qt_gui_cpp +{ + +typedef RosPluginlibPluginProvider RosPluginlibPluginProvider_ForPluginProviders; + +} // namespace + +#endif // qt_gui_cpp__RosPluginlibPluginProvider_ForPluginProviders_HPP diff --git a/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugins.h b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugins.h index c4d06604..d87e6bd3 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugins.h +++ b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugins.h @@ -33,14 +33,11 @@ #ifndef qt_gui_cpp__RosPluginlibPluginProvider_ForPlugins_H #define qt_gui_cpp__RosPluginlibPluginProvider_ForPlugins_H -#include "plugin.h" -#include "ros_pluginlib_plugin_provider.h" +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header is deprecated, \ +include instead. +// *INDENT-ON* -namespace qt_gui_cpp -{ - -typedef RosPluginlibPluginProvider RosPluginlibPluginProvider_ForPlugins; - -} // namespace +#include "./ros_pluginlib_plugin_provider_for_plugins.hpp" #endif // qt_gui_cpp__RosPluginlibPluginProvider_ForPlugins_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugins.hpp b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugins.hpp new file mode 100644 index 00000000..09f96ea2 --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/ros_pluginlib_plugin_provider_for_plugins.hpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__RosPluginlibPluginProvider_ForPlugins_HPP +#define qt_gui_cpp__RosPluginlibPluginProvider_ForPlugins_HPP + +#include "plugin.hpp" +#include "ros_pluginlib_plugin_provider.hpp" + +namespace qt_gui_cpp +{ + +typedef RosPluginlibPluginProvider RosPluginlibPluginProvider_ForPlugins; + +} // namespace + +#endif // qt_gui_cpp__RosPluginlibPluginProvider_ForPlugins_HPP diff --git a/qt_gui_cpp/include/qt_gui_cpp/settings.h b/qt_gui_cpp/include/qt_gui_cpp/settings.h index e9dc426a..b7397afd 100644 --- a/qt_gui_cpp/include/qt_gui_cpp/settings.h +++ b/qt_gui_cpp/include/qt_gui_cpp/settings.h @@ -33,60 +33,11 @@ #ifndef qt_gui_cpp__Settings_H #define qt_gui_cpp__Settings_H -#include "generic_proxy.h" +// *INDENT-OFF* (prevent uncrustify from adding indention below) +#warning Including header is deprecated, \ +include instead. +// *INDENT-ON* -#include -#include -// Upstream issue: https://codereview.qt-project.org/c/qt/qtbase/+/272258 -#if __GNUC__ >= 9 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-copy" -#endif -#include -#if __GNUC__ >= 9 -# pragma GCC diagnostic pop -#endif - -namespace qt_gui_cpp -{ - -class Settings -{ - -public: - - Settings(QObject* obj); - - Settings getSettings(const QString& prefix); - - QStringList allKeys() const; - -// int beginReadArray(const QString& prefix); - -// void beginWriteArray(const QString& prefix, int size = -1); - - QStringList childGroups() const; - - QStringList childKeys() const; - - bool contains(const QString& key) const; - -// void endArray(); - - void remove(const QString& key); - -// void setArrayIndex(int i); - - void setValue(const QString& key, const QVariant& value); - - QVariant value(const QString& key, const QVariant& defaultValue = QVariant()) const; - -protected: - - GenericProxy proxy_; - -}; - -} // namespace +#include "./settings.hpp" #endif // qt_gui_cpp__Settings_H diff --git a/qt_gui_cpp/include/qt_gui_cpp/settings.hpp b/qt_gui_cpp/include/qt_gui_cpp/settings.hpp new file mode 100644 index 00000000..d819e5d2 --- /dev/null +++ b/qt_gui_cpp/include/qt_gui_cpp/settings.hpp @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2011, Dirk Thomas, TU Darmstadt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TU Darmstadt nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef qt_gui_cpp__Settings_HPP +#define qt_gui_cpp__Settings_HPP + +#include "generic_proxy.hpp" + +#include +#include +// Upstream issue: https://codereview.qt-project.org/c/qt/qtbase/+/272258 +#if __GNUC__ >= 9 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-copy" +#endif +#include +#if __GNUC__ >= 9 +# pragma GCC diagnostic pop +#endif + +namespace qt_gui_cpp +{ + +class Settings +{ + +public: + + Settings(QObject* obj); + + Settings getSettings(const QString& prefix); + + QStringList allKeys() const; + +// int beginReadArray(const QString& prefix); + +// void beginWriteArray(const QString& prefix, int size = -1); + + QStringList childGroups() const; + + QStringList childKeys() const; + + bool contains(const QString& key) const; + +// void endArray(); + + void remove(const QString& key); + +// void setArrayIndex(int i); + + void setValue(const QString& key, const QVariant& value); + + QVariant value(const QString& key, const QVariant& defaultValue = QVariant()) const; + +protected: + + GenericProxy proxy_; + +}; + +} // namespace + +#endif // qt_gui_cpp__Settings_HPP diff --git a/qt_gui_cpp/src/qt_gui_cpp/composite_plugin_provider.cpp b/qt_gui_cpp/src/qt_gui_cpp/composite_plugin_provider.cpp index 177d32a4..b4d9274c 100644 --- a/qt_gui_cpp/src/qt_gui_cpp/composite_plugin_provider.cpp +++ b/qt_gui_cpp/src/qt_gui_cpp/composite_plugin_provider.cpp @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include diff --git a/qt_gui_cpp/src/qt_gui_cpp/generic_proxy.cpp b/qt_gui_cpp/src/qt_gui_cpp/generic_proxy.cpp index 4f12eeaa..cd9b95f9 100644 --- a/qt_gui_cpp/src/qt_gui_cpp/generic_proxy.cpp +++ b/qt_gui_cpp/src/qt_gui_cpp/generic_proxy.cpp @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include diff --git a/qt_gui_cpp/src/qt_gui_cpp/plugin_bridge.cpp b/qt_gui_cpp/src/qt_gui_cpp/plugin_bridge.cpp index cf4a759f..a8df5456 100644 --- a/qt_gui_cpp/src/qt_gui_cpp/plugin_bridge.cpp +++ b/qt_gui_cpp/src/qt_gui_cpp/plugin_bridge.cpp @@ -30,11 +30,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include - -#include -#include -#include +#include +#include +#include +#include #include diff --git a/qt_gui_cpp/src/qt_gui_cpp/plugin_context.cpp b/qt_gui_cpp/src/qt_gui_cpp/plugin_context.cpp index 225c2485..28986e4c 100644 --- a/qt_gui_cpp/src/qt_gui_cpp/plugin_context.cpp +++ b/qt_gui_cpp/src/qt_gui_cpp/plugin_context.cpp @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include diff --git a/qt_gui_cpp/src/qt_gui_cpp/plugin_descriptor.cpp b/qt_gui_cpp/src/qt_gui_cpp/plugin_descriptor.cpp index 6b14c68b..d8834a8b 100644 --- a/qt_gui_cpp/src/qt_gui_cpp/plugin_descriptor.cpp +++ b/qt_gui_cpp/src/qt_gui_cpp/plugin_descriptor.cpp @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include namespace qt_gui_cpp { diff --git a/qt_gui_cpp/src/qt_gui_cpp/plugin_provider.cpp b/qt_gui_cpp/src/qt_gui_cpp/plugin_provider.cpp index 0ba83124..c4e76305 100644 --- a/qt_gui_cpp/src/qt_gui_cpp/plugin_provider.cpp +++ b/qt_gui_cpp/src/qt_gui_cpp/plugin_provider.cpp @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include namespace qt_gui_cpp { diff --git a/qt_gui_cpp/src/qt_gui_cpp/recursive_plugin_provider.cpp b/qt_gui_cpp/src/qt_gui_cpp/recursive_plugin_provider.cpp index ece493bb..55734f56 100644 --- a/qt_gui_cpp/src/qt_gui_cpp/recursive_plugin_provider.cpp +++ b/qt_gui_cpp/src/qt_gui_cpp/recursive_plugin_provider.cpp @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include diff --git a/qt_gui_cpp/src/qt_gui_cpp/settings.cpp b/qt_gui_cpp/src/qt_gui_cpp/settings.cpp index 166d1594..ea89d0b7 100644 --- a/qt_gui_cpp/src/qt_gui_cpp/settings.cpp +++ b/qt_gui_cpp/src/qt_gui_cpp/settings.cpp @@ -30,7 +30,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include diff --git a/qt_gui_cpp/src/qt_gui_cpp_shiboken/global.h b/qt_gui_cpp/src/qt_gui_cpp_shiboken/global.h index e8dc05ed..655e5786 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_shiboken/global.h +++ b/qt_gui_cpp/src/qt_gui_cpp_shiboken/global.h @@ -38,15 +38,15 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/composite_plugin_provider.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/composite_plugin_provider.sip index 5a72ffe7..4141df5f 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/composite_plugin_provider.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/composite_plugin_provider.sip @@ -5,7 +5,7 @@ class CompositePluginProvider : qt_gui_cpp::PluginProvider { %TypeHeaderCode -#include +#include %End public: diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/generic_proxy.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/generic_proxy.sip index 47699e57..970511e0 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/generic_proxy.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/generic_proxy.sip @@ -4,7 +4,7 @@ namespace qt_gui_cpp class GenericProxy { %TypeHeaderCode -#include +#include %End public: diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin.sip index c4b939e8..f1425bfb 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin.sip @@ -5,7 +5,7 @@ class Plugin : QObject { %TypeHeaderCode -#include +#include %End public: diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_bridge.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_bridge.sip index 8686646e..586f0627 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_bridge.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_bridge.sip @@ -5,7 +5,7 @@ class PluginBridge : QObject { %TypeHeaderCode -#include +#include %End public: diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_context.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_context.sip index 1d37a37d..7465eb04 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_context.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_context.sip @@ -4,7 +4,7 @@ namespace qt_gui_cpp class PluginContext { %TypeHeaderCode -#include +#include %End public: diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_descriptor.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_descriptor.sip index 84c31234..ebc44c79 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_descriptor.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_descriptor.sip @@ -4,7 +4,7 @@ namespace qt_gui_cpp class PluginDescriptor { %TypeHeaderCode -#include +#include %End public: diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_provider.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_provider.sip index 3a753c1f..55918c8e 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_provider.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/plugin_provider.sip @@ -4,7 +4,7 @@ namespace qt_gui_cpp class PluginProvider { %TypeHeaderCode -#include +#include %End public: diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/recursive_plugin_provider.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/recursive_plugin_provider.sip index 0bbbc9b5..d0131740 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/recursive_plugin_provider.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/recursive_plugin_provider.sip @@ -5,7 +5,7 @@ class RecursivePluginProvider : qt_gui_cpp::CompositePluginProvider { %TypeHeaderCode -#include +#include %End public: diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugin_providers.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugin_providers.sip index cddd9220..f5a71e7d 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugin_providers.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugin_providers.sip @@ -6,7 +6,7 @@ class RosPluginlibPluginProvider_ForPluginProviders , qt_gui_cpp::PluginProvider { %TypeHeaderCode -#include +#include %End public: diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugins.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugins.sip index 4a4d5688..4ec47007 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugins.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/ros_pluginlib_plugin_provider_for_plugins.sip @@ -6,7 +6,7 @@ class RosPluginlibPluginProvider_ForPlugins , qt_gui_cpp::PluginProvider { %TypeHeaderCode -#include +#include %End public: diff --git a/qt_gui_cpp/src/qt_gui_cpp_sip/settings.sip b/qt_gui_cpp/src/qt_gui_cpp_sip/settings.sip index 2cd896bd..1502af0f 100644 --- a/qt_gui_cpp/src/qt_gui_cpp_sip/settings.sip +++ b/qt_gui_cpp/src/qt_gui_cpp_sip/settings.sip @@ -4,7 +4,7 @@ namespace qt_gui_cpp class Settings { %TypeHeaderCode -#include +#include %End public: