summaryrefslogtreecommitdiff
path: root/src/plugincontainer.h
diff options
context:
space:
mode:
authorMikaƫl Capelle <capelle.mikael@gmail.com>2020-10-01 18:52:35 +0200
committerGitHub <noreply@github.com>2020-10-01 18:52:35 +0200
commit4167e6768e3d82f831982588347a5a8606fe82f6 (patch)
treeb31dc6b9711ed0681d28beb5a1314f10474950ce /src/plugincontainer.h
parentcd3f496a5b9f6cc090c66a226d4f7f7557c9a8e1 (diff)
parent475fc0b813497d81aed92b0659cb2213dd9ce14f (diff)
Merge pull request #1248 from Holt59/iplugin-interface-improvements
Better display of MO2 plugins
Diffstat (limited to 'src/plugincontainer.h')
-rw-r--r--src/plugincontainer.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/plugincontainer.h b/src/plugincontainer.h
index d405198a..07363ee7 100644
--- a/src/plugincontainer.h
+++ b/src/plugincontainer.h
@@ -19,6 +19,7 @@ class IUserInterface;
#ifndef Q_MOC_RUN
#include <boost/fusion/container.hpp>
#include <boost/fusion/include/at_key.hpp>
+#include <boost/mp11.hpp>
#endif // Q_MOC_RUN
#include <vector>
@@ -46,6 +47,37 @@ 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<PluginTypeOrder>::value == boost::mp11::mp_size<PluginContainer::PluginMap>::value - 1);
+
+public:
+
+ /**
+ * @brief Retrieved the (localized) names of the various plugin interfaces.
+ *
+ * @return the (localized) names of the various plugin interfaces.
+ */
+ static QStringList pluginInterfaces();
+
public:
PluginContainer(OrganizerCore *organizer);
@@ -56,16 +88,60 @@ public:
void loadPlugins();
void unloadPlugins();
+ /**
+ * @brief Find the game plugin corresponding to the given name.
+ *
+ * @param name The name of the game to find a plugin for (as returned by
+ * IPluginGame::gameName()).
+ *
+ * @return the game plugin for the given name, or a null pointer if no
+ * plugin exists for this game.
+ */
MOBase::IPluginGame *managedGame(const QString &name) const;
+ /**
+ * @brief Retrieve the list of plugins of the given type.
+ *
+ * @return the list of plugins of the specified type.
+ *
+ * @tparam T The type of plugin to retrieve.
+ */
template <typename T>
const std::vector<T*> &plugins() const {
typename boost::fusion::result_of::at_key<const PluginMap, T>::type temp = boost::fusion::at_key<T>(m_Plugins);
return temp;
}
+ /**
+ * @brief Retrieved the (localized) names of interfaces implemented by the given
+ * plugin.
+ *
+ * @param plugin The plugin to retrieve interface for.
+ *
+ * @return the (localized) names of interfaces implemented by this plugin.
+ */
+ 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;
+
+ /**
+ * @return the preview generator.
+ */
const PreviewGenerator &previewGenerator() const;
+ /**
+ * @return the list of plugin file names, including proxied plugins.
+ */
QStringList pluginFileNames() const;
public: // IPluginDiagnose interface
@@ -82,6 +158,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);