Refactor: Move plugin file support handling to PluginFactory

This commit is contained in:
Lukas W
2015-02-05 17:22:23 +01:00
parent 863df4e3e6
commit 35e1c4ed89
8 changed files with 48 additions and 49 deletions

View File

@@ -45,6 +45,8 @@ public:
static void init();
static void destroy();
// TODO: Remove me. Replace calls like `if( Engine::hasGUI() )` with
// `if (gui)` (gui defined in "GuiApplication.h"
static bool hasGUI();
// core
@@ -89,12 +91,6 @@ public:
}
static void updateFramesPerTick();
static const QMap<QString, QString> & pluginFileHandling()
{
return s_pluginFileHandling;
}
private:
// small helper function which sets the pointer to NULL before actually deleting
// the object it refers to
@@ -118,10 +114,6 @@ private:
static Ladspa2LMMS * s_ladspaManager;
static QMap<QString, QString> s_pluginFileHandling;
static void initPluginFileHandling();
friend class GuiApplication;
};

View File

@@ -38,13 +38,15 @@ class EXPORT PluginFactory
public:
struct PluginInfo
{
PluginInfo() : library(nullptr), descriptor(nullptr) {}
const QString name() const;
QFileInfo file;
QLibrary* library;
Plugin::Descriptor* descriptor;
bool isNull() const {return library == 0;}
};
typedef QList<PluginInfo> PluginInfoList;
typedef QList<PluginInfo*> PluginInfoList;
typedef QMultiMap<Plugin::PluginTypes, Plugin::Descriptor*> DescriptorMap;
PluginFactory();
@@ -60,6 +62,8 @@ public:
/// Returns a list of all found plugins' PluginFactory::PluginInfo objects.
const PluginInfoList& pluginInfos() const;
/// Returns a plugin that support the given file extension
const PluginInfo pluginSupportingExtension(const QString& ext);
/// Returns the PluginInfo object of the plugin with the given name.
/// If the plugin is not found, an empty PluginInfo is returned (use
@@ -76,6 +80,7 @@ public slots:
private:
DescriptorMap m_descriptors;
PluginInfoList m_pluginInfos;
QMap<QString, PluginInfo*> m_pluginByExt;
QHash<QString, QString> m_errors;