MythTV  master
mythplugin.h
Go to the documentation of this file.
1 #ifndef MYTHPLUGIN_H_
2 #define MYTHPLUGIN_H_
3 
4 #include <QLibrary>
5 #include <QMap>
6 #include <QHash>
7 
8 #include "mythbaseexp.h"
9 
10 class QSqlDatabase;
11 class MythContext;
12 class QPainter;
13 
14 typedef enum {
17 
18 class MythPlugin : public QLibrary
19 {
20  public:
21  MythPlugin(const QString &libname, const QString &plugname)
22  : QLibrary(libname), m_plugName(plugname) {}
23  virtual ~MythPlugin() = default;
24 
25  // This method will call the mythplugin_init() function of the library.
26  int init(const char *libversion);
27 
28  // This method will call the mythplugin_run() function of the library.
29  int run(void);
30 
31  // This method will call the mythplugin_config() function of the library.
32  int config(void);
33 
34  // This method will call the mythplugin_type() function of the library.
35  // If such a function doesn't exist, it's a main module plugin.
36  MythPluginType type(void);
37 
38  // This method will call the mythplugin_destroy() function of the library,
39  // if such a function exists.
40  void destroy(void);
41 
42  bool isEnabled() { return m_enabled; }
43  void setEnabled(bool enable) { m_enabled = enable; }
44 
45  int getPosition() { return m_position; }
46  void setPosition(int pos) { m_position = pos; }
47 
48  QString getName(void) { return m_plugName; }
49 
50  private:
51  bool m_enabled {true};
52  int m_position {0};
53  QString m_plugName;
54  QStringList m_features;
55 };
56 
57 // this should only be instantiated through MythContext.
59 {
60  public:
62  ~MythPluginManager() = default;
63 
64  bool init_plugin(const QString &plugname);
65  bool run_plugin(const QString &plugname);
66  bool config_plugin(const QString &plugname);
67  bool destroy_plugin(const QString &plugname);
68 
69  MythPlugin *GetPlugin(const QString &plugname);
70 
71  QStringList EnumeratePlugins(void);
72  void DestroyAllPlugins();
73 
74  private:
75  QHash<QString,MythPlugin*> m_dict;
76 
77  QMap<QString, MythPlugin *> m_moduleMap;
78 };
79 
80 #endif
Startup context for MythTV.
Definition: mythcontext.h:42
MythPlugin(const QString &libname, const QString &plugname)
Definition: mythplugin.h:21
void setPosition(int pos)
Definition: mythplugin.h:46
void destroy(void)
Definition: mythplugin.cpp:86
QHash< QString, MythPlugin * > m_dict
Definition: mythplugin.h:75
MythPluginType
Definition: mythplugin.h:14
bool isEnabled()
Definition: mythplugin.h:42
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
MythPluginType type(void)
Definition: mythplugin.cpp:75
int m_position
Definition: mythplugin.h:52
QString m_plugName
Definition: mythplugin.h:53
QMap< QString, MythPlugin * > m_moduleMap
Definition: mythplugin.h:77
void setEnabled(bool enable)
Definition: mythplugin.h:43
virtual ~MythPlugin()=default
bool m_enabled
Definition: mythplugin.h:51
QString getName(void)
Definition: mythplugin.h:48
int config(void)
Definition: mythplugin.cpp:58
int run(void)
Definition: mythplugin.cpp:45
int getPosition()
Definition: mythplugin.h:45
QStringList m_features
Definition: mythplugin.h:54
int init(const char *libversion)
Definition: mythplugin.cpp:23