24int main (
int argc,
char * argv[] )
28 setenv (
"LC_ALL",
"C", 1 );
30 std::string oksfn, rdbrl, roksrl, outfn, sepfnbase, stats, logfile, msglevel (
"ERROR" );
32 size_t min_component_size = 0;
33 size_t max_component_size = std::numeric_limits<size_t>::max();
35 bop::options_description options_description (
36 "Allowed options ( warning : almost no sanity checks performed )", 128 );
38 options_description.add_options()
40 (
"help,h",
"Provide help message" )
42 (
"file,f", bop::value<std::string> ( &oksfn ),
"OKS database file name" )
44 (
"rdb,r", bop::value<std::string> ( &rdbrl ),
45 "RDB String (e.g. partition::rdbServerName)" )
47 (
"roks,o", bop::value<std::string> ( &roksrl ),
48 "ROKS String (e.g. oracle://atlas_oksprod/r:atlas_oks_tdaq:24:77)" )
50 (
"result,u", bop::value<std::string> ( &outfn ),
51 "Output file which can be used as input to graphviz" )
53 (
"separate,s", bop::value<std::string> ( &sepfnbase ),
54 "Output pathnames to prepend to subgraph files" )
57 bop::value<std::string> ( &stats )->default_value ( stats ),
58 "The statistic to compute can be a comma sperated list \" e.g. min_dist,num_of_component \"..." )
60 (
"minc,m", bop::value<size_t> ( &min_component_size )->default_value (
62 "The minimum component size to output" )
64 (
"maxc,M", bop::value<size_t> ( &max_component_size )->default_value (
66 "The maximum component size to output" )
68 (
"msglevel,L", bop::value<std::string> ( &msglevel )->default_value ( msglevel ),
69 "The minimum level of error messages to report (INFO,WARN,ERROR,FAIL)" )
71 (
"log,l", bop::value<std::string> ( &logfile ),
72 "Redirect error messages to logfile instead of cerr" );
74 bop::variables_map args;
76 std::unique_ptr<dbe::tool::graph::gtool> proc;
78 auto display_help_message = [&options_description]()
81 <<
"DBE gtool : Generate dot graphs from database files"
84 <<
"Usage: dbe_gtool [options] , only the first option is taken into account "
85 <<
"and the output file. If no output file is specified the result is sent to stdout"
88 << options_description
94 bop::store ( bop::command_line_parser ( argc, argv ).options ( options_description ).
run(),
99 t_msghandler::ref().setlevel ( msglevel, t_messenger::all_levels );
102 if ( args.count (
"log" ) )
104 t_msghandler::ref().set ( logfile );
111 if ( args.count (
"help" ) or argc == 1 )
113 display_help_message();
116 else if ( args.count (
"file" ) )
118 proc = std::unique_ptr<dbe::tool::graph::gtool> (
121 else if ( args.count (
"rdb" ) )
123 proc = std::unique_ptr<dbe::tool::graph::gtool> (
126 else if ( args.count (
"roks" ) )
128 proc = std::unique_ptr<dbe::tool::graph::gtool> (
133 display_help_message();
138 if ( not args.count (
"result" ) and not args.count (
"separate" ) )
140 WARN (
"Output file not specified ",
"User input warning",
141 "Output will be sent to standard output" );
142 display_help_message();
146 catch ( std::string
const & e )
148 ERROR (
"Program execution failure", e );
151 catch ( std::exception
const & e )
153 ERROR (
"Incorrect command line argument", e.what() );
154 display_help_message();
160 if ( args.count (
"separate" ) )
162 INFO (
"Graph will be separated to its components",
"Program execution control" );
164 max_component_size );
165 return proc->load_and_run ( sgw );
169 INFO (
"One large output file to be created",
"Program execution control" );
171 return proc->load_and_run ( w );
174 catch ( std::exception
const & e )
176 std::cerr <<
"Exception: " << e.what() << std::endl;
180 std::cerr <<
"Unknown Exception" << std::endl;