forked from CalcProgrammer1/OpenRGB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPluginManager.h
59 lines (43 loc) · 1.58 KB
/
PluginManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include "OpenRGBPluginInterface.h"
#include "ResourceManager.h"
#include <QPluginLoader>
#include <QLabel>
#include <QtPlugin>
#include <QDir>
#include <string>
#include <iostream>
typedef struct
{
OpenRGBPluginInfo info;
OpenRGBPluginInterface* plugin;
QPluginLoader* loader;
bool loaded;
QWidget* widget;
QMenu* traymenu;
std::string path;
bool enabled;
} OpenRGBPluginEntry;
typedef void (*AddPluginCallback)(void *, OpenRGBPluginEntry* plugin);
typedef void (*RemovePluginCallback)(void *, OpenRGBPluginEntry* plugin);
class PluginManager
{
public:
PluginManager();
void RegisterAddPluginCallback(AddPluginCallback new_callback, void * new_callback_arg);
void RegisterRemovePluginCallback(RemovePluginCallback new_callback, void * new_callback_arg);
void ScanAndLoadPlugins();
void AddPlugin(const filesystem::path& path);
void RemovePlugin(const filesystem::path& path);
void LoadPlugin(const filesystem::path& path);
void UnloadPlugin(const filesystem::path& path);
void UnloadPlugins();
std::vector<OpenRGBPluginEntry> ActivePlugins;
private:
void ScanAndLoadPluginsFrom(const filesystem::path & plugins_dir);
AddPluginCallback AddPluginCallbackVal;
void * AddPluginCallbackArg;
RemovePluginCallback RemovePluginCallbackVal;
void * RemovePluginCallbackArg;
const char * plugins_path = "plugins/";
};