Line data Source code
1 : #include "CLI/CLI.hpp"
2 : #include <dlfcn.h>
3 : #include <fmt/core.h>
4 : #include <fmt/ranges.h>
5 :
6 : #include "conffwk/Configuration.hpp"
7 : #include "conffwk/DalFactory.hpp"
8 : #include "conffwk/Schema.hpp"
9 :
10 : int
11 0 : main(int argc, char const* argv[])
12 : {
13 :
14 0 : using namespace dunedaq;
15 :
16 0 : CLI::App app{ "App description" };
17 :
18 0 : std::string file;
19 0 : app.add_option("-f,--file", file, "Schema file")->required()->check(CLI::ExistingFile);
20 :
21 0 : CLI11_PARSE(app, argc, argv);
22 :
23 0 : fmt::print("Configuration database file: {}\n", file);
24 :
25 0 : conffwk::Configuration db("oksconflibs:" + file);
26 :
27 0 : for (const auto& class_name : db.get_class_list()) {
28 :
29 0 : auto& c = db.get_class_info(class_name);
30 0 : fmt::print("- {} '{}'\n", class_name, c.p_schema_path);
31 :
32 0 : std::string file = c.p_schema_path;
33 0 : std::string search{ "/schema/" };
34 0 : auto start = file.rfind(search) + search.size();
35 0 : auto end = file.find("/", start);
36 :
37 0 : std::string package = file.substr(start, end - start);
38 0 : std::string library = "lib" + package + "_dal.so";
39 0 : fmt::print("Loading library {} from {}\n", library, package);
40 :
41 0 : auto handle = dlopen(library.c_str(), RTLD_LAZY | RTLD_GLOBAL);
42 0 : if (handle == nullptr) {
43 0 : fmt::print("Failed to load {}\n", library);
44 :
45 : // throw (LoadDalFailed(ERS_HERE, library));
46 : }
47 0 : }
48 0 : }
|