00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __PLUGINLOADER_H__
00025 #define __PLUGINLOADER_H__
00026
00027 #include <QList>
00028 #include <QString>
00029
00030 #include "global.h"
00031
00032 #ifdef Q_OS_WIN32
00033 #include <windows.h>
00034
00035 #ifdef _MSC_VER
00036 #pragma warning(disable: 4251)
00037 #endif
00038
00039 #endif
00040
00041 class EnginePlugin;
00042
00043 class MAIN_EXPORT PluginLoader
00044 {
00045 public:
00050 class MAIN_EXPORT Plugin
00051 {
00052 public:
00057 Plugin(unsigned int type, QString file);
00058 ~Plugin();
00059
00063 void *function(const char* func) const;
00064
00065 void initConfig();
00066
00067 bool isValid() const { return library != NULL; }
00068
00069 const EnginePlugin *info;
00070
00071 private:
00072 void unload();
00073
00074 QString file;
00075
00076 #ifdef Q_OS_WIN32
00077 HMODULE library;
00078 #else
00079 void *library;
00080 #endif
00081 };
00082
00087 PluginLoader(unsigned int type, const QStringList &baseDirectories, const char* directory, int directoryLength=-1);
00088 ~PluginLoader();
00089
00093 void clearPlugins();
00094
00098 void initConfig();
00099
00103 const unsigned int numPlugins() const;
00104
00111 int pluginIndexFromName(const QString& name) const;
00112
00116 void resetPluginsDirectory(const QString& pluginsDirectory);
00117
00121 const Plugin* operator[] (unsigned int index) const;
00122
00123 private:
00124 bool filesInDir();
00125
00126 unsigned int type;
00127 QString pluginsDirectory;
00128 QList<Plugin *> pluginsList;
00129 };
00130
00131 #endif