Setting language variable to english(otherwise , is interpreted as . in numbers)
25{
26
28 setenv ( "LC_ALL", "C", 1 );
29
30 std::string oksfn, rdbrl, roksrl, outfn, sepfnbase, stats, logfile, msglevel ( "ERROR" );
31
32 size_t min_component_size = 0;
33 size_t max_component_size = std::numeric_limits<size_t>::max();
34
35 bop::options_description options_description (
36 "Allowed options ( warning : almost no sanity checks performed )", 128 );
37
38 options_description.add_options()
39
40 ( "help,h", "Provide help message" )
41
42 ( "file,f", bop::value<std::string> ( &oksfn ), "OKS database file name" )
43
44 ( "rdb,r", bop::value<std::string> ( &rdbrl ),
45 "RDB String (e.g. partition::rdbServerName)" )
46
47 ( "roks,o", bop::value<std::string> ( &roksrl ),
48 "ROKS String (e.g. oracle://atlas_oksprod/r:atlas_oks_tdaq:24:77)" )
49
50 ( "result,u", bop::value<std::string> ( &outfn ),
51 "Output file which can be used as input to graphviz" )
52
53 ( "separate,s", bop::value<std::string> ( &sepfnbase ),
54 "Output pathnames to prepend to subgraph files" )
55
56 ( "stats,S",
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 \"..." )
59
60 ( "minc,m", bop::value<size_t> ( &min_component_size )->default_value (
61 min_component_size ),
62 "The minimum component size to output" )
63
64 ( "maxc,M", bop::value<size_t> ( &max_component_size )->default_value (
65 max_component_size ),
66 "The maximum component size to output" )
67
68 ( "msglevel,L", bop::value<std::string> ( &msglevel )->default_value ( msglevel ),
69 "The minimum level of error messages to report (INFO,WARN,ERROR,FAIL)" )
70
71 ( "log,l", bop::value<std::string> ( &logfile ),
72 "Redirect error messages to logfile instead of cerr" );
73
74 bop::variables_map
args;
75
76 std::unique_ptr<dbe::tool::graph::gtool> proc;
77
78 auto display_help_message = [&options_description]()
79 {
80 std::cout
81 << "DBE gtool : Generate dot graphs from database files"
82 << std::endl
83 << std::endl
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"
86 << std::endl
87 << std::endl
88 << options_description
89 << std::endl;
90 };
91
92 try
93 {
94 bop::store ( bop::command_line_parser ( argc, argv ).options ( options_description ).
run(),
95 args );
96 bop::notify ( args );
97
98
99 t_msghandler::ref().setlevel ( msglevel, t_messenger::all_levels );
100
101
102 if (
args.count (
"log" ) )
103 {
104 t_msghandler::ref().set ( logfile );
105 }
106
107
109
110
111 if (
args.count (
"help" ) or argc == 1 )
112 {
113 display_help_message();
114 return EXIT_FAILURE;
115 }
116 else if (
args.count (
"file" ) )
117 {
118 proc = std::unique_ptr<dbe::tool::graph::gtool> (
120 }
121 else if (
args.count (
"rdb" ) )
122 {
123 proc = std::unique_ptr<dbe::tool::graph::gtool> (
125 }
126 else if (
args.count (
"roks" ) )
127 {
128 proc = std::unique_ptr<dbe::tool::graph::gtool> (
130 }
131 else
132 {
133 display_help_message();
134 return EXIT_FAILURE;
135 }
136
137
138 if ( not
args.count (
"result" ) and not
args.count (
"separate" ) )
139 {
140 WARN (
"Output file not specified ",
"User input warning",
141 "Output will be sent to standard output" );
142 display_help_message();
143 }
144
145 }
146 catch ( std::string const & e )
147 {
148 ERROR (
"Program execution failure", e );
149 return EXIT_FAILURE;
150 }
151 catch ( std::exception const & e )
152 {
153 ERROR (
"Incorrect command line argument", e.what() );
154 display_help_message();
155 return EXIT_FAILURE;
156 }
157
158 try
159 {
160 if (
args.count (
"separate" ) )
161 {
162 INFO (
"Graph will be separated to its components",
"Program execution control" );
164 max_component_size );
165 return proc->load_and_run ( sgw );
166 }
167 else
168 {
169 INFO (
"One large output file to be created",
"Program execution control" );
171 return proc->load_and_run ( w );
172 }
173 }
174 catch ( std::exception const & e )
175 {
176 std::cerr << "Exception: " << e.what() << std::endl;
177 }
178 catch ( ... )
179 {
180 std::cerr << "Unknown Exception" << std::endl;
181 }
182
183 return EXIT_FAILURE;
184
185}
static volatile sig_atomic_t run