mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-07-09 18:45:22 +02:00
Added error dialog to module manager and fixed typo
This commit is contained in:
@ -79,57 +79,62 @@ ModuleManager::Module_t ModuleManager::loadModule(std::string path) {
|
||||
return mod;
|
||||
}
|
||||
|
||||
void ModuleManager::createInstance(std::string name, std::string module) {
|
||||
int ModuleManager::createInstance(std::string name, std::string module) {
|
||||
if (modules.find(module) == modules.end()) {
|
||||
spdlog::error("Module '{0}' doesn't exist", module);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
if (instances.find(name) != instances.end()) {
|
||||
spdlog::error("A module instance with the name '{0}' already exists", name);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
int maxCount = modules[module].info->maxInstances;
|
||||
if (countModuleInstances(module) >= maxCount && maxCount > 0) {
|
||||
spdlog::error("Maximum number of instances reached for '{0}'", module);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
Instance_t inst;
|
||||
inst.module = modules[module];
|
||||
inst.instance = inst.module.createInstance(name);
|
||||
instances[name] = inst;
|
||||
onInstanceCreated.emit(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ModuleManager::deleteInstance(std::string name) {
|
||||
int ModuleManager::deleteInstance(std::string name) {
|
||||
if (instances.find(name) == instances.end()) {
|
||||
spdlog::error("Tried to remove non-existent instance '{0}'", name);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
onInstanceDelete.emit(name);
|
||||
Instance_t inst = instances[name];
|
||||
inst.module.deleteInstance(inst.instance);
|
||||
instances.erase(name);
|
||||
onInstanceDeleted.emit(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ModuleManager::deleteInstance(ModuleManager::Instance* instance) {
|
||||
int ModuleManager::deleteInstance(ModuleManager::Instance* instance) {
|
||||
spdlog::error("Delete instance not implemented");
|
||||
return -1;
|
||||
}
|
||||
|
||||
void ModuleManager::enableInstance(std::string name) {
|
||||
int ModuleManager::enableInstance(std::string name) {
|
||||
if (instances.find(name) == instances.end()) {
|
||||
spdlog::error("Cannot enable '{0}', instance doesn't exist", name);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
instances[name].instance->enable();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ModuleManager::disableInstance(std::string name) {
|
||||
int ModuleManager::disableInstance(std::string name) {
|
||||
if (instances.find(name) == instances.end()) {
|
||||
spdlog::error("Cannot disable '{0}', instance doesn't exist", name);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
instances[name].instance->disable();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ModuleManager::instanceEnabled(std::string name) {
|
||||
|
Reference in New Issue
Block a user