Skip to content
Snippets Groups Projects
Commit 6b3fe415 authored by Joaquim Casals Buñuel's avatar Joaquim Casals Buñuel
Browse files

Added support for loading arbitrary .so files from yaml. Improved error reporting of Loader

parent 7a5ac010
No related branches found
No related tags found
No related merge requests found
Pipeline #4523 passed
......@@ -27,7 +27,7 @@ public:
void load(){
this->resource_ = dlopen(this->path_.c_str(), RTLD_LAZY);
if(not this->resource_)
throw std::runtime_error("Couldn't load resource with path " + this->path_);
throw std::runtime_error("Couldn't load resource with path " + this->path_ + "\n" + "Error info: " + dlerror());
}
void close(){
if(this->resource_) dlclose(this->resource_);
......
......@@ -182,6 +182,7 @@ class ParserYAML {
std::vector<ParamsInitProcessor> _paramsProc;
std::vector<std::string> _plugins;
std::vector<std::string> _subscribers;
std::vector<std::string> _raw_libs;
std::stack<std::string> _parsing_file;
std::string _file;
bool _relative_path;
......@@ -199,7 +200,8 @@ public:
_paramsProc = std::vector<ParamsInitProcessor>();
_file = "";
_plugins = std::vector<std::string>();
_subscribers= std::vector<std::string>();
_subscribers = std::vector<std::string>();
_raw_libs = std::vector<std::string>();
_parsing_file = std::stack<std::string>();
_path_root = "";
_relative_path = false;
......@@ -211,6 +213,7 @@ public:
_paramsSens = std::vector<ParamsInitSensor>();
_paramsProc = std::vector<ParamsInitProcessor>();
_plugins = std::vector<std::string>();
_raw_libs = std::vector<std::string>();
_subscribers = std::vector<std::string>();
_parsing_file = std::stack<std::string>();
_file = file;
......@@ -225,6 +228,7 @@ public:
_paramsProc = std::vector<ParamsInitProcessor>();
_plugins = std::vector<std::string>();
_subscribers = std::vector<std::string>();
_raw_libs = std::vector<std::string>();
_parsing_file = std::stack<std::string>();
_file = file;
if(path_root != ""){
......@@ -423,11 +427,16 @@ void ParserYAML::parseFirstLevel(std::string file){
_plugins.push_back(kv.Scalar());
}
insert_register("plugins", wolf::converter<std::string>::convert(_plugins));
YAML::Node n_subscribers= n["subscribers"];
YAML::Node n_subscribers = n["subscribers"];
for (const auto &kv : n_subscribers) {
_subscribers.push_back(kv.Scalar());
}
insert_register("subscribers", wolf::converter<std::string>::convert(_subscribers));
YAML::Node n_raw_libs = n["raw_libs"];
for (const auto &kv : n_raw_libs) {
_raw_libs.push_back(kv.Scalar());
}
insert_register("raw_libs", wolf::converter<std::string>::convert(_raw_libs));
// _params.insert(std::pair<std::string,std::string>);
}
std::vector<std::array<std::string, 2>> ParserYAML::sensorsSerialization(){
......
......@@ -121,6 +121,19 @@ ProblemPtr Problem::autoSetup(ParamsServer &_server)
l->load();
loaders.push_back(l);
}
std::vector<std::string> raw_libs;
try {
raw_libs = _server.getParam<std::vector<std::string>>("raw_libs");
} catch (MissingValueException& e) {
WOLF_TRACE("No raw libraries to load...");
raw_libs = std::vector<std::string>();
}
for (auto lib : raw_libs) {
WOLF_TRACE("Loading raw lib " + lib);
auto l = new LoaderRaw(lib);
l->load();
loaders.push_back(l);
}
// Install sensors and processors
auto sensorMap = std::map<std::string, SensorBasePtr>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment