#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <list>
#include <memory>
#include <cstdlib>
#include <getopt.h>
#include <dlfcn.h>
#include <Gaudi/PluginService.h>
Go to the source code of this file.
|
void | help (std::string argv0) |
|
void | usage (std::string argv0) |
|
int | main (int argc, char *argv[]) |
|
void help |
( |
std::string |
argv0 | ) |
|
- Author
- Marco Clemencic marco.nosp@m..cle.nosp@m.menci.nosp@m.c@ce.nosp@m.rn.ch
Definition at line 27 of file listcomponents.cpp.
28 std::cout <<
"Usage: " << argv0 <<
" [option] library1 [library2 ...]\n"
29 "\n list the component factories present in the given libraries\n\n"
31 " -h, --help show this help message and exit\n"
32 " -o OUTPUT, --output OUTPUT\n"
33 " write the list of factories on the file OUTPUT, use - for\n"
34 " standard output (default)\n"
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 44 of file listcomponents.cpp.
50 std::map<key_type, std::string> loaded;
52 for (
const auto & elem : reg.
loadedFactories()) loaded.emplace(elem,
"<preloaded>");
55 std::list<char*> libs;
56 std::string output_opt(
"-");
58 std::string argv0(
argv[0]);
60 auto i = argv0.rfind(
'/');
61 if (
i != std::string::npos)
62 argv0 = argv0.substr(
i+1);
67 const std::string arg(
argv[i]);
68 if (arg ==
"-o" || arg ==
"--output") {
72 std::cerr <<
"ERROR: missing argument for option " << arg << std::endl;
73 std::cerr <<
"See `" << argv0 <<
" -h' for more details." << std::endl;
76 }
else if (arg ==
"-h" || arg ==
"--help") {
80 libs.push_back(
argv[i]);
91 std::unique_ptr<std::ostream> output_file;
92 if (output_opt !=
"-") {
93 output_file.reset(
new std::ofstream{output_opt} );
95 std::ostream &output = (output_file ? *output_file : std::cout);
98 for (
char* lib: libs) {
99 if (dlopen(lib, RTLD_LAZY | RTLD_LOCAL)) {
101 auto f = loaded.find(factory);
102 if ( f == loaded.end()) {
103 output << lib <<
":" << factory << std::endl;
104 loaded.emplace(factory,lib);
106 std::cerr <<
"WARNING: factory '" << factory
107 <<
"' already found in " << f->second
111 std::cerr <<
"ERROR: failed to load " << lib << std::endl;
void usage(std::string argv0)
std::set< KeyType > loadedFactories() const
Return a list of all the known and loaded factories.
void help(std::string argv0)
static Registry & instance()
Retrieve the singleton instance of Registry.
In-memory database of the loaded factories.
void usage |
( |
std::string |
argv0 | ) |
|
Definition at line 38 of file listcomponents.cpp.
39 std::cout <<
"Usage: " << argv0 <<
" [option] library1 [library2 ...]\n"
40 "Try `" << argv0 <<
" -h' for more information.\n"