1 | /* |
2 | SPDX-FileCopyrightText: 2021-2023 Alexander Lohnau <alexander.lohnau@gmx.de> |
3 | SPDX-License-Identifier: LGPL-2.0-or-later |
4 | */ |
5 | |
6 | #include "kcoreaddons_export.h" |
7 | #include "kstaticpluginhelpers_p.h" |
8 | |
9 | typedef QHash<QString, QMap<QString, QStaticPlugin>> StaticPluginMap; |
10 | Q_GLOBAL_STATIC(StaticPluginMap, s_staticPlugins) |
11 | |
12 | QMap<QString, QStaticPlugin> KStaticPluginHelpers::staticPlugins(const QString &directory) |
13 | { |
14 | return s_staticPlugins->value(key: directory); |
15 | } |
16 | |
17 | std::optional<QStaticPlugin> KStaticPluginHelpers::findById(const QString &directory, const QString &pluginId) |
18 | { |
19 | const auto staticPlugins = s_staticPlugins->value(key: directory); |
20 | const auto it = staticPlugins.constFind(key: pluginId); |
21 | return it == staticPlugins.end() ? std::nullopt : std::optional(it.value()); |
22 | } |
23 | |
24 | // Used in autogenerated code, see kcoreaddons_target_static_plugins |
25 | KCOREADDONS_EXPORT void kRegisterStaticPluginFunction(const QString &pluginId, const QString &directory, QStaticPlugin plugin) |
26 | { |
27 | (*s_staticPlugins)[directory].insert(key: pluginId, value: plugin); |
28 | } |
29 | |