libqutim 0.2.80.1
|
00001 /**************************************************************************** 00002 ** 00003 ** qutIM - instant messenger 00004 ** 00005 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru> 00006 ** 00007 ***************************************************************************** 00008 ** 00009 ** $QUTIM_BEGIN_LICENSE$ 00010 ** This program is free software: you can redistribute it and/or modify 00011 ** it under the terms of the GNU General Public License as published by 00012 ** the Free Software Foundation, either version 3 of the License, or 00013 ** (at your option) any later version. 00014 ** 00015 ** This program is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 ** See the GNU General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU General Public License 00021 ** along with this program. If not, see http://www.gnu.org/licenses/. 00022 ** $QUTIM_END_LICENSE$ 00023 ** 00024 ****************************************************************************/ 00025 00026 #ifndef MODULEMANAGER_H 00027 #define MODULEMANAGER_H 00028 00029 #include "libqutim_global.h" 00030 #include "plugin.h" 00031 #include <QStringList> 00032 #include <QMultiMap> 00033 #include "event.h" 00034 00035 namespace qutim_sdk_0_3 00036 { 00037 class ModuleManagerPrivate; 00038 00043 class LIBQUTIM_EXPORT ModuleManager : public QObject 00044 { 00045 Q_OBJECT 00046 protected: 00047 // Constructor 00048 ModuleManager(QObject *parent = 0); 00049 // Destructor 00050 virtual ~ModuleManager(); 00051 00052 ExtensionInfoList extensions(const char *interfaceId) const; 00053 ExtensionInfoList extensions(const QMetaObject *meta) const; 00054 00055 // Methods 00056 void loadPlugins(const QStringList &additional_paths = QStringList()); 00057 QObject *initExtension(const QMetaObject *service_meta); 00058 00059 // Virtual Methods 00060 virtual ExtensionInfoList coreExtensions() const = 0; 00061 virtual void initExtensions(); 00062 00063 // Inline Methods 00064 template<typename T> 00065 inline QMultiMap<Plugin *, ExtensionInfo> getExtensions() 00066 { 00067 return getExtensions(&T::staticMetaObject); 00068 } 00069 00070 template<typename T> 00071 inline T *initExtension() 00072 { 00073 return static_cast<T *>(initExtension(&T::staticMetaObject)); 00074 } 00075 protected slots: 00076 void onQuit(); 00077 protected: 00078 virtual void virtual_hook(int id, void *data); 00079 private: 00080 friend LIBQUTIM_EXPORT GeneratorList moduleGenerators(const QMetaObject *); 00081 friend LIBQUTIM_EXPORT GeneratorList moduleGenerators(const char *); 00082 }; 00083 00084 // LIBQUTIM_EXPORT void registerModule(const char *name, const char *description, const char *face, const QMetaObject *meta, int min = 0, int max = -1); 00085 // inline void registerModule(const char *name, const char *description, const char *face, int min = 0, int max = -1) 00086 // { registerModule(name, description, face, NULL, min, max); } 00087 // inline void registerModule(const char *name, const char *description, const QMetaObject *meta, int min = 0, int max = -1) 00088 // { registerModule(name, description, NULL, meta, min, max); } 00089 // 00090 // template<typename T, int Min, int Max> 00091 // class ModuleHelper 00092 // { 00093 // public: 00094 // inline ModuleHelper(const char *name, const char *description) 00095 // { 00096 // registerModule(name, description, qobject_interface_iid<T *>(), meta_helper<T>(reinterpret_cast<T *>(0)), Min, Max); 00097 // } 00098 // private: 00099 // template <typename F> 00100 // inline const QMetaObject *meta_helper(const QObject *obj) 00101 // { return &F::staticMetaObject; } 00102 // template <typename F> 00103 // inline const QMetaObject *meta_helper(const void *obj) 00104 // { return NULL; } 00105 // }; 00106 // 00107 // template <typename T> 00108 // class SingleModuleHelper : public ModuleHelper<T, 1, 1> 00109 // { 00110 // public: 00111 // inline SingleModuleHelper(const char *name, const char *description) : ModuleHelper<T, 1, 1>(name, description) {} 00112 // }; 00113 // 00114 // template <typename T> 00115 // class MultiModuleHelper : public ModuleHelper<T, 0, -1> 00116 // { 00117 // public: 00118 // inline MultiModuleHelper(const char *name, const char *description) : ModuleHelper<T, 0, -1>(name, description) {} 00119 // }; 00120 } 00121 00122 #endif // MODULEMANAGER_H 00123