30main(
int argc,
char* argv[])
34 setenv(
"LC_ALL",
"C", 1);
36 std::string oksfn, rdbrl, roksrl, outfn, sepfnbase, stats, logfile, msglevel(
"ERROR");
38 size_t min_component_size = 0;
39 size_t max_component_size = std::numeric_limits<size_t>::max();
41 bop::options_description options_description(
"Allowed options ( warning : almost no sanity checks performed )", 128);
43 options_description.add_options()
45 (
"help,h",
"Provide help message")
47 (
"file,f", bop::value<std::string>(&oksfn),
"OKS database file name")
49 (
"rdb,r", bop::value<std::string>(&rdbrl),
"RDB String (e.g. partition::rdbServerName)")
52 bop::value<std::string>(&roksrl),
53 "ROKS String (e.g. oracle://atlas_oksprod/r:atlas_oks_tdaq:24:77)")
55 (
"result,u", bop::value<std::string>(&outfn),
"Output file which can be used as input to graphviz")
57 (
"separate,s", bop::value<std::string>(&sepfnbase),
"Output pathnames to prepend to subgraph files")
60 bop::value<std::string>(&stats)->default_value(stats),
61 "The statistic to compute can be a comma sperated list \" e.g. min_dist,num_of_component \"...")
64 bop::value<size_t>(&min_component_size)->default_value(min_component_size),
65 "The minimum component size to output")
68 bop::value<size_t>(&max_component_size)->default_value(max_component_size),
69 "The maximum component size to output")
72 bop::value<std::string>(&msglevel)->default_value(msglevel),
73 "The minimum level of error messages to report (INFO,WARN,ERROR,FAIL)")
76 bop::value<std::string>(&logfile),
77 "Redirect error messages to logfile instead of cerr");
79 bop::variables_map args;
81 std::unique_ptr<dbe::tool::graph::gtool> proc;
83 auto display_help_message = [&options_description]() {
84 std::cout <<
"DBE gtool : Generate dot graphs from database files" << std::endl
86 <<
"Usage: dbe_gtool [options] , only the first option is taken into account "
87 <<
"and the output file. If no output file is specified the result is sent to stdout" << std::endl
89 << options_description << std::endl;
93 bop::store(bop::command_line_parser(argc, argv).options(options_description).run(), args);
97 t_msghandler::ref().setlevel(msglevel, t_messenger::all_levels);
100 if (args.count(
"log")) {
101 t_msghandler::ref().set(logfile);
108 if (args.count(
"help") or argc == 1) {
109 display_help_message();
111 }
else if (args.count(
"file")) {
113 }
else if (args.count(
"rdb")) {
115 }
else if (args.count(
"roks")) {
118 display_help_message();
123 if (not args.count(
"result") and not args.count(
"separate")) {
124 WARN(
"Output file not specified ",
"User input warning",
"Output will be sent to standard output");
125 display_help_message();
128 }
catch (std::string
const& e) {
129 ERROR(
"Program execution failure", e);
131 }
catch (std::exception
const& e) {
132 ERROR(
"Incorrect command line argument", e.what());
133 display_help_message();
138 if (args.count(
"separate")) {
139 INFO(
"Graph will be separated to its components",
"Program execution control");
141 return proc->load_and_run(sgw);
143 INFO(
"One large output file to be created",
"Program execution control");
145 return proc->load_and_run(w);
147 }
catch (std::exception
const& e) {
148 std::cerr <<
"Exception: " << e.what() << std::endl;
150 std::cerr <<
"Unknown Exception" << std::endl;