From e9be288f7ce6ed7861a5ed381e2e16ae730524ad Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Tue, 29 Sep 2020 21:55:44 +0200 Subject: Add topImplementedInterface(). Minor cleaning. --- src/plugincontainer.h | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'src/plugincontainer.h') diff --git a/src/plugincontainer.h b/src/plugincontainer.h index 7eb59a0f..8672606b 100644 --- a/src/plugincontainer.h +++ b/src/plugincontainer.h @@ -19,6 +19,7 @@ class IUserInterface; #ifndef Q_MOC_RUN #include #include +#include #endif // Q_MOC_RUN #include @@ -46,6 +47,28 @@ private: static const unsigned int PROBLEM_PLUGINSNOTLOADED = 1; + /** + * This typedefs defines the order of plugin interface. This is increasing order of + * importance". + * + * @note IPlugin is the less important interface, followed by IPluginDiagnose and + * IPluginFileMapper as those are usually implemented together with another interface. + * Other interfaces are in a alphabetical order since it is unlikely a plugin will + * implement multiple ones. + */ + using PluginTypeOrder = + boost::mp11::mp_transform< + std::add_pointer_t, + boost::mp11::mp_list< + MOBase::IPluginGame, MOBase::IPluginInstaller, MOBase::IPluginModPage, MOBase::IPluginPreview, + MOBase::IPluginProxy, MOBase::IPluginTool, MOBase::IPluginDiagnose, MOBase::IPluginFileMapper, + MOBase::IPlugin + > + >; + + static_assert( + boost::mp11::mp_size::value == boost::mp11::mp_size::value - 1); + public: /** @@ -56,7 +79,19 @@ public: * * @return the (localized) names of interfaces implemented by this plugin. */ - QStringList implementedInterfaces(const MOBase::IPlugin *plugin) const; + QStringList implementedInterfaces(MOBase::IPlugin *plugin) const; + + /** + * @brief Return the (localized) name of the most important interface implemented by + * the given plugin. + * + * The order of interfaces is defined in X. + * + * @param plugin The plugin to retrieve the interface for. + * + * @return the (localized) name of the most important interface implemented by this plugin. + */ + QString topImplementedInterface(MOBase::IPlugin* plugin) const; PluginContainer(OrganizerCore *organizer); virtual ~PluginContainer(); @@ -114,6 +149,16 @@ signals: private: + /** + * @brief Find the QObject* corresponding to the given plugin. + * + * @param plugin The plugin to find the QObject* for. + * + * @return a QObject* for the given plugin. + */ + QObject* as_qobject(MOBase::IPlugin* plugin) const; + + bool verifyPlugin(MOBase::IPlugin *plugin); void registerGame(MOBase::IPluginGame *game); bool registerPlugin(QObject *pluginObj, const QString &fileName); -- cgit v1.3.1