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