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
14class QSqlDatabase;
15class MythContext;
16class QPainter;
17
18enum MythPluginType : std::uint8_t {
20};
21
22class 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() const { return m_enabled; }
47 void setEnabled(bool enable) { m_enabled = enable; }
48
49 int getPosition() const { 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:20
QMap< QString, MythPlugin * > m_moduleMap
Definition: mythplugin.h:81
~MythPluginManager()=default
QHash< QString, MythPlugin * > m_dict
Definition: mythplugin.h:79
~MythPlugin() override=default
MythPlugin(const QString &libname, QString plugname)
Definition: mythplugin.h:25
int init(const char *libversion)
Definition: mythplugin.cpp:21
int getPosition() const
Definition: mythplugin.h:49
void destroy(void)
Definition: mythplugin.cpp:82
bool isEnabled() const
Definition: mythplugin.h:46
void setPosition(int pos)
Definition: mythplugin.h:50
QStringList m_features
Definition: mythplugin.h:58
int m_position
Definition: mythplugin.h:56
QString getName(void)
Definition: mythplugin.h:52
bool m_enabled
Definition: mythplugin.h:55
MythPluginType type(void)
Definition: mythplugin.cpp:71
QString m_plugName
Definition: mythplugin.h:57
int config(void)
Definition: mythplugin.cpp:55
int run(void)
Definition: mythplugin.cpp:42
void setEnabled(bool enable)
Definition: mythplugin.h:47
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
MythPluginType
Definition: mythplugin.h:18
@ kPluginType_Module
Definition: mythplugin.h:19
STL namespace.