29int main (
int argc,
char * argv[] )
33 setenv (
"LC_ALL",
"C", 1 );
35 std::string oksfn, rdbrl, roksrl, outfn, sepfnbase, stats, logfile, msglevel (
"ERROR" );
37 size_t min_component_size = 0;
38 size_t max_component_size = std::numeric_limits<size_t>::max();
40 bop::options_description options_description (
41 "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 ),
50 "RDB String (e.g. partition::rdbServerName)" )
52 (
"roks,o", 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 ),
56 "Output file which can be used as input to graphviz" )
58 (
"separate,s", bop::value<std::string> ( &sepfnbase ),
59 "Output pathnames to prepend to subgraph files" )
62 bop::value<std::string> ( &stats )->default_value ( stats ),
63 "The statistic to compute can be a comma sperated list \" e.g. min_dist,num_of_component \"..." )
65 (
"minc,m", bop::value<size_t> ( &min_component_size )->default_value (
67 "The minimum component size to output" )
69 (
"maxc,M", bop::value<size_t> ( &max_component_size )->default_value (
71 "The maximum component size to output" )
73 (
"msglevel,L", bop::value<std::string> ( &msglevel )->default_value ( msglevel ),
74 "The minimum level of error messages to report (INFO,WARN,ERROR,FAIL)" )
76 (
"log,l", 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]()
86 <<
"DBE gtool : Generate dot graphs from database files"
89 <<
"Usage: dbe_gtool [options] , only the first option is taken into account "
90 <<
"and the output file. If no output file is specified the result is sent to stdout"
93 << options_description
99 bop::store ( bop::command_line_parser ( argc, argv ).options ( options_description ).
run(),
101 bop::notify ( args );
104 t_msghandler::ref().setlevel ( msglevel, t_messenger::all_levels );
107 if ( args.count (
"log" ) )
109 t_msghandler::ref().set ( logfile );
116 if ( args.count (
"help" ) or argc == 1 )
118 display_help_message();
121 else if ( args.count (
"file" ) )
123 proc = std::unique_ptr<dbe::tool::graph::gtool> (
126 else if ( args.count (
"rdb" ) )
128 proc = std::unique_ptr<dbe::tool::graph::gtool> (
131 else if ( args.count (
"roks" ) )
133 proc = std::unique_ptr<dbe::tool::graph::gtool> (
138 display_help_message();
143 if ( not args.count (
"result" ) and not args.count (
"separate" ) )
145 WARN (
"Output file not specified ",
"User input warning",
146 "Output will be sent to standard output" );
147 display_help_message();
151 catch ( std::string
const & e )
153 ERROR (
"Program execution failure", e );
156 catch ( std::exception
const & e )
158 ERROR (
"Incorrect command line argument", e.what() );
159 display_help_message();
165 if ( args.count (
"separate" ) )
167 INFO (
"Graph will be separated to its components",
"Program execution control" );
169 max_component_size );
170 return proc->load_and_run ( sgw );
174 INFO (
"One large output file to be created",
"Program execution control" );
176 return proc->load_and_run ( w );
179 catch ( std::exception
const & e )
181 std::cerr <<
"Exception: " << e.what() << std::endl;
185 std::cerr <<
"Unknown Exception" << std::endl;