00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "worldline.h"
00014
00015 local void print_interactions(ostream& str,
00016 worldbundleptr wh[], int nh,
00017 char *id)
00018 {
00019 unique_id_t curr_id = -1;
00020 unique_id_t prev_id = -1;
00021 unique_id_t prev_prev_id = -1;
00022
00023 real trep = 0;
00024 int nrep = 0;
00025 int order = 0;
00026
00027 for (int ih = 0; ih < nh; ih++) {
00028 worldbundle *wb = wh[ih];
00029 worldline *w = wb->find_worldline(id);
00030
00031 if (w) {
00032 int is = 0;
00033 segment *s = w->get_first_segment();
00034
00035
00036 while (s) {
00037 tdyn *b = s->get_first_event();
00038
00039
00040 if (b) {
00041
00042
00043
00044 tdyn *p = b;
00045 while (p && p->get_parent()
00046 && strcmp(p->get_parent()->format_label(),
00047 "root")) {
00048
00049 p = p->get_parent();
00050 }
00051
00052
00053
00054 unique_id_t this_id = unique_id(p);
00055
00056
00057
00058
00059 bool print = (ih == nh-1 && s->get_next() == NULL);
00060
00061 if (this_id == curr_id) {
00062 order = 1;
00063 nrep++;
00064 trep = p->get_time();
00065 } else {
00066 if (this_id == prev_id && curr_id == prev_prev_id) {
00067 order = 2;
00068 nrep++;
00069 trep = p->get_time();
00070 } else
00071 print = true;
00072 }
00073
00074 if (print) {
00075 int prec = str.precision(10);
00076 if (nrep > 0 && order > 1)
00077 str << trep << ": [" << order
00078 << "-cycle, rep = " << nrep << "]"
00079 << endl;
00080 str << p->get_time() << ": "
00081 << p->format_label()
00082 << endl;
00083 nrep = 0;
00084 str.precision(prec);
00085 }
00086
00087 prev_prev_id = prev_id;
00088 prev_id = curr_id;
00089 curr_id = this_id;
00090 }
00091 s = s->get_next();
00092 is++;
00093 }
00094 }
00095 }
00096 }
00097
00098 main(int argc, char** argv)
00099 {
00100 check_help();
00101
00102 char infile[128];
00103 strcpy(infile, "run.out");
00104
00105 extern char *poptarg;
00106 char* params = "F:";
00107 int c;
00108
00109 while ((c = pgetopt(argc, argv, params)) != -1)
00110 switch(c) {
00111
00112 case 'F': strcpy(infile, poptarg);
00113 break;
00114 case '?': params_to_usage(cerr, argv[0], params);
00115 get_help();
00116 exit(0);
00117 }
00118
00119 ifstream s(infile);
00120 if (!s) {
00121 cerr << "Data file " << infile << " not found." << endl;
00122 exit(1);
00123 }
00124
00125 worldbundleptr wb, wh[1024];
00126
00127 int nh = 0;
00128 while (nh < 1024 && (wb = read_bundle(s, false))) wh[nh++] = wb;
00129
00130 preload_pdyn(wh, nh, false);
00131
00132 while (1) {
00133 char id[64];
00134 cout << "name: " << flush; cin >> id;
00135 if (strlen(id) <= 0
00136 || strstr(id, "exit")
00137 || strstr(id, "quit")) {
00138 if (strlen(id) <= 0) cout << endl;
00139 break;
00140 }
00141 print_interactions(cout, wh, nh, id);
00142 }
00143 }