projects
/
mtp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c49a920
)
Moved all the global variables into Global global;
author
Francois Fleuret
<francois@fleuret.org>
Mon, 24 Dec 2012 16:47:57 +0000
(17:47 +0100)
committer
Francois Fleuret
<francois@fleuret.org>
Mon, 24 Dec 2012 16:47:57 +0000
(17:47 +0100)
mtp.cc
patch
|
blob
|
history
diff --git
a/mtp.cc
b/mtp.cc
index
300e4a6
..
d77bd62
100644
(file)
--- a/
mtp.cc
+++ b/
mtp.cc
@@
-35,9
+35,11
@@
using namespace std;
#define FILENAME_SIZE 1024
#define FILENAME_SIZE 1024
-char trajectory_filename[FILENAME_SIZE];
-char graph_filename[FILENAME_SIZE];
-int verbose;
+struct Global {
+ char trajectory_filename[FILENAME_SIZE];
+ char graph_filename[FILENAME_SIZE];
+ int verbose;
+} global;
void usage(ostream *os) {
(*os) << "mtp [-h|--help] [--help-formats] [-v|--verbose] [-t|--trajectory-filename <trajectory filename>] [-g|--graph-filename <graph filename>] [<tracking parameter file>]" << endl;
void usage(ostream *os) {
(*os) << "mtp [-h|--help] [--help-formats] [-v|--verbose] [-t|--trajectory-filename <trajectory filename>] [-g|--graph-filename <graph filename>] [<tracking parameter file>]" << endl;
@@
-95,41
+97,41
@@
void do_tracking(istream *in_tracker) {
timeval start_time, end_time;
MTPTracker *tracker = new MTPTracker();
timeval start_time, end_time;
MTPTracker *tracker = new MTPTracker();
- if(verbose) { cout << "Reading the tracking parameters." << endl; }
+ if(
global.
verbose) { cout << "Reading the tracking parameters." << endl; }
tracker->read(in_tracker);
tracker->read(in_tracker);
- if(verbose) {
+ if(
global.
verbose) {
cout << "Building the graph ... "; cout.flush();
gettimeofday(&start_time, 0);
}
tracker->build_graph();
cout << "Building the graph ... "; cout.flush();
gettimeofday(&start_time, 0);
}
tracker->build_graph();
- if(verbose) {
+ if(
global.
verbose) {
gettimeofday(&end_time, 0);
cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
}
gettimeofday(&end_time, 0);
cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
}
- if(verbose) {
+ if(
global.
verbose) {
cout << "Tracking ... "; cout.flush();
gettimeofday(&start_time, 0);
}
tracker->track();
cout << "Tracking ... "; cout.flush();
gettimeofday(&start_time, 0);
}
tracker->track();
- if(verbose) {
+ if(
global.
verbose) {
gettimeofday(&end_time, 0);
cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
}
gettimeofday(&end_time, 0);
cout << "done (" << diff_in_second(&start_time, &end_time) << "s)." << endl;
}
- if(strcmp(trajectory_filename, "")) {
- ofstream out_traj(trajectory_filename);
+ if(strcmp(
global.
trajectory_filename, "")) {
+ ofstream out_traj(
global.
trajectory_filename);
tracker->write_trajectories(&out_traj);
tracker->write_trajectories(&out_traj);
- if(
verbose) { cout << "Wrote " <<
trajectory_filename << "." << endl; }
+ if(
global.verbose) { cout << "Wrote " << global.
trajectory_filename << "." << endl; }
} else {
tracker->write_trajectories(&cout);
}
} else {
tracker->write_trajectories(&cout);
}
- if(strcmp(graph_filename, "") != 0) {
- ofstream out_dot(graph_filename);
+ if(strcmp(g
lobal.g
raph_filename, "") != 0) {
+ ofstream out_dot(g
lobal.g
raph_filename);
tracker->print_graph_dot(&out_dot);
tracker->print_graph_dot(&out_dot);
- if(
verbose) { cout << "Wrote " <<
graph_filename << "." << endl; }
+ if(
global.verbose) { cout << "Wrote " << global.
graph_filename << "." << endl; }
}
delete tracker;
}
delete tracker;
@@
-153,21
+155,20
@@
int main(int argc, char **argv) {
int c;
int error = 0, show_help = 0;
int c;
int error = 0, show_help = 0;
- strncpy(trajectory_filename, "", FILENAME_SIZE);
- strncpy(graph_filename, "", FILENAME_SIZE);
- verbose = 0;
+ strncpy(
global.
trajectory_filename, "", FILENAME_SIZE);
+ strncpy(g
lobal.g
raph_filename, "", FILENAME_SIZE);
+
global.
verbose = 0;
- while ((c = getopt_long(argc, argv, "t:g:hv",
- long_options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "t:g:hv", long_options, NULL)) != -1) {
switch(c) {
case 't':
switch(c) {
case 't':
- strncpy(trajectory_filename, optarg, FILENAME_SIZE);
+ strncpy(
global.
trajectory_filename, optarg, FILENAME_SIZE);
break;
case 'g':
break;
case 'g':
- strncpy(graph_filename, optarg, FILENAME_SIZE);
+ strncpy(g
lobal.g
raph_filename, optarg, FILENAME_SIZE);
break;
case 'h':
break;
case 'h':
@@
-180,7
+181,7
@@
int main(int argc, char **argv) {
break;
case 'v':
break;
case 'v':
- verbose = 1;
+
global.
verbose = 1;
break;
default:
break;
default: