libqutim  0.3.1.0
modulemanager.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** qutIM - instant messenger
4 **
5 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru>
6 **
7 *****************************************************************************
8 **
9 ** $QUTIM_BEGIN_LICENSE$
10 ** This program is free software: you can redistribute it and/or modify
11 ** it under the terms of the GNU General Public License as published by
12 ** the Free Software Foundation, either version 3 of the License, or
13 ** (at your option) any later version.
14 **
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 ** See the GNU General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program. If not, see http://www.gnu.org/licenses/.
22 ** $QUTIM_END_LICENSE$
23 **
24 ****************************************************************************/
25 
26 #ifndef MODULEMANAGER_H
27 #define MODULEMANAGER_H
28 
29 #include "libqutim_global.h"
30 #include "plugin.h"
31 #include <QStringList>
32 #include <QMultiMap>
33 #include "event.h"
34 
35 namespace qutim_sdk_0_3
36 {
37 class ModuleManagerPrivate;
38 
43 class LIBQUTIM_EXPORT ModuleManager : public QObject
44 {
45  Q_OBJECT
46 protected:
47  // Constructor
48  ModuleManager(QObject *parent = 0);
49  // Destructor
50  virtual ~ModuleManager();
51 
52  ExtensionInfoList extensions(const char *interfaceId) const;
53  ExtensionInfoList extensions(const QMetaObject *meta) const;
54 
55  // Methods
56  void loadPlugins(const QStringList &additional_paths = QStringList());
57  QObject *initExtension(const QMetaObject *service_meta);
58 
59  // Virtual Methods
60  virtual ExtensionInfoList coreExtensions() const = 0;
61  virtual void initExtensions();
62 
63  // Inline Methods
64  template<typename T>
65  inline QMultiMap<Plugin *, ExtensionInfo> getExtensions()
66  {
67  return getExtensions(&T::staticMetaObject);
68  }
69 
70  template<typename T>
71  inline T *initExtension()
72  {
73  return static_cast<T *>(initExtension(&T::staticMetaObject));
74  }
75 protected slots:
76  void onQuit();
77  void _q_protocolDestroyed(QObject *obj); //TODO remove me
78  void _q_messageReceived(const QString &);
79 protected:
80  virtual void virtual_hook(int id, void *data);
81 private:
82  friend LIBQUTIM_EXPORT GeneratorList moduleGenerators(const QMetaObject *);
83  friend LIBQUTIM_EXPORT GeneratorList moduleGenerators(const char *);
84 };
85 
86 // LIBQUTIM_EXPORT void registerModule(const char *name, const char *description, const char *face, const QMetaObject *meta, int min = 0, int max = -1);
87 // inline void registerModule(const char *name, const char *description, const char *face, int min = 0, int max = -1)
88 // { registerModule(name, description, face, NULL, min, max); }
89 // inline void registerModule(const char *name, const char *description, const QMetaObject *meta, int min = 0, int max = -1)
90 // { registerModule(name, description, NULL, meta, min, max); }
91 //
92 // template<typename T, int Min, int Max>
93 // class ModuleHelper
94 // {
95 // public:
96 // inline ModuleHelper(const char *name, const char *description)
97 // {
98 // registerModule(name, description, qobject_interface_iid<T *>(), meta_helper<T>(reinterpret_cast<T *>(0)), Min, Max);
99 // }
100 // private:
101 // template <typename F>
102 // inline const QMetaObject *meta_helper(const QObject *obj)
103 // { return &F::staticMetaObject; }
104 // template <typename F>
105 // inline const QMetaObject *meta_helper(const void *obj)
106 // { return NULL; }
107 // };
108 //
109 // template <typename T>
110 // class SingleModuleHelper : public ModuleHelper<T, 1, 1>
111 // {
112 // public:
113 // inline SingleModuleHelper(const char *name, const char *description) : ModuleHelper<T, 1, 1>(name, description) {}
114 // };
115 //
116 // template <typename T>
117 // class MultiModuleHelper : public ModuleHelper<T, 0, -1>
118 // {
119 // public:
120 // inline MultiModuleHelper(const char *name, const char *description) : ModuleHelper<T, 0, -1>(name, description) {}
121 // };
122 }
123 
124 #endif // MODULEMANAGER_H
125 

Generated by Doxygen