Skip to content
Snippets Groups Projects

Change strategy for modules registration to the ModuleRepository

Merged Stéphane Del Pino requested to merge feature/pluggins into develop
1 file
+ 13
5
Compare changes
  • Side-by-side
  • Inline
#include <utils/PluginsLoader.hpp>
#include <utils/PluginsLoader.hpp>
 
#include <utils/ConsoleManager.hpp>
 
#include <dlfcn.h>
#include <dlfcn.h>
#include <rang.hpp>
#include <rang.hpp>
@@ -32,9 +34,11 @@ PluginsLoader::_open(const std::string& plugin)
@@ -32,9 +34,11 @@ PluginsLoader::_open(const std::string& plugin)
auto handle = dlopen(plugin.c_str(), RTLD_NOW);
auto handle = dlopen(plugin.c_str(), RTLD_NOW);
if (handle != nullptr) {
if (handle != nullptr) {
m_dl_handler_stack.push(handle);
m_dl_handler_stack.push(handle);
std::cout << " * \"" << rang::fgB::green << plugin << rang::fg::reset << "\"\n";
if (ConsoleManager::showPreamble()) {
 
std::cout << " * \"" << rang::fgB::green << plugin << rang::fg::reset << "\"\n";
 
}
} else {
} else {
std::cout << " " << rang::fgB::red << "cannot load " << rang::fg::reset << '\"' << rang::fgB::yellow << plugin
std::cerr << " " << rang::fgB::red << "cannot load " << rang::fg::reset << '\"' << rang::fgB::yellow << plugin
<< rang::fg::reset << "\"\n";
<< rang::fg::reset << "\"\n";
}
}
}
}
@@ -58,7 +62,7 @@ PluginsLoader::PluginsLoader()
@@ -58,7 +62,7 @@ PluginsLoader::PluginsLoader()
std::vector<std::string> path_vector = split(paths);
std::vector<std::string> path_vector = split(paths);
for (auto&& path : path_vector) {
for (auto&& path : path_vector) {
if (access(path.c_str(), R_OK) == -1) {
if (access(path.c_str(), R_OK) == -1) {
std::cout << ' ' << rang::fgB::red << 'X' << rang::fg::reset << " cannot access plugin dir \""
std::cerr << ' ' << rang::fgB::red << 'X' << rang::fg::reset << " cannot access plugin dir \""
<< rang::fgB::yellow << path << rang::fg::reset << "\"\n";
<< rang::fgB::yellow << path << rang::fg::reset << "\"\n";
} else {
} else {
for (auto&& entry :
for (auto&& entry :
@@ -79,11 +83,15 @@ PluginsLoader::PluginsLoader()
@@ -79,11 +83,15 @@ PluginsLoader::PluginsLoader()
plugin_vector.resize(std::distance(plugin_vector.begin(), std::unique(plugin_vector.begin(), plugin_vector.end())));
plugin_vector.resize(std::distance(plugin_vector.begin(), std::unique(plugin_vector.begin(), plugin_vector.end())));
if (plugin_vector.size() > 0) {
if (plugin_vector.size() > 0) {
std::cout << rang::style::bold << "Loading plugins" << rang::style::reset << '\n';
if (ConsoleManager::showPreamble()) {
 
std::cout << rang::style::bold << "Loading plugins" << rang::style::reset << '\n';
 
}
for (auto&& plugin : plugin_vector) {
for (auto&& plugin : plugin_vector) {
this->_open(plugin);
this->_open(plugin);
}
}
std::cout << "-------------------------------------------------------\n";
if (ConsoleManager::showPreamble()) {
 
std::cout << "-------------------------------------------------------\n";
 
}
}
}
}
}
Loading