-
Notifications
You must be signed in to change notification settings - Fork 383
/
Copy pathaddonmanager.cpp
60 lines (52 loc) · 1.85 KB
/
addonmanager.cpp
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
60
#include "addonmanager.h"
#include "usbhostmanager.h"
bool AddonManager::LoadAddon(GPAddon* addon) {
if (addon->available()) {
AddonBlock * block = new AddonBlock;
addon->setup();
block->ptr = addon;
addons.push_back(block);
return true;
} else {
delete addon; // Don't use the memory if we don't have to
}
return false;
}
bool AddonManager::LoadUSBAddon(GPAddon* addon) {
bool ret = LoadAddon(addon);
if ( ret == true )
USBHostManager::getInstance().pushListener(addon->getListener());
return ret;
}
void AddonManager::ReinitializeAddons() {
// Loop through all addons and process any that match our type
for (std::vector<AddonBlock*>::iterator it = addons.begin(); it != addons.end(); it++) {
(*it)->ptr->reinit();
}
}
void AddonManager::PreprocessAddons() {
// Loop through all addons and process any that match our type
for (std::vector<AddonBlock*>::iterator it = addons.begin(); it != addons.end(); it++) {
(*it)->ptr->preprocess();
}
}
void AddonManager::ProcessAddons() {
// Loop through all addons and process any that match our type
for (std::vector<AddonBlock*>::iterator it = addons.begin(); it != addons.end(); it++) {
(*it)->ptr->process();
}
}
void AddonManager::PostprocessAddons(bool reportSent) {
// Loop through all addons and process any that match our type
for (std::vector<AddonBlock*>::iterator it = addons.begin(); it != addons.end(); it++) {
(*it)->ptr->postprocess(reportSent);
}
}
// HACK : change this for NeoPicoLED
GPAddon * AddonManager::GetAddon(std::string name) { // hack for NeoPicoLED
for (std::vector<AddonBlock*>::iterator it = addons.begin(); it != addons.end(); it++) {
if ( (*it)->ptr->name() == name )
return (*it)->ptr;
}
return nullptr;
}