aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/pluginloader.h
diff options
context:
space:
mode:
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/pluginloader.h')
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/pluginloader.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/pluginloader.h b/SQLiteStudio3/coreSQLiteStudio/pluginloader.h
new file mode 100644
index 0000000..5f18c9a
--- /dev/null
+++ b/SQLiteStudio3/coreSQLiteStudio/pluginloader.h
@@ -0,0 +1,35 @@
+#ifndef PLUGINLOADER_H
+#define PLUGINLOADER_H
+
+#include "coreSQLiteStudio_global.h"
+#include <QPluginLoader>
+#include <QList>
+#include <QHash>
+#include <QDebug>
+
+class Plugin;
+
+class API_EXPORT AbstractPluginLoader
+{
+ public:
+ virtual ~AbstractPluginLoader();
+
+ virtual bool add(QPluginLoader* loader, Plugin* plugin);
+ virtual bool test(Plugin* plugin) = 0;
+ QList<Plugin*> getPlugins() const;
+
+ private:
+ QHash<QPluginLoader*,Plugin*> plugins;
+};
+
+template <class T>
+class PluginLoader : public AbstractPluginLoader
+{
+ public:
+ bool test(Plugin* plugin)
+ {
+ return (dynamic_cast<T*>(plugin) != nullptr);
+ }
+};
+
+#endif // PLUGINLOADER_H