00001 00005 //----------------------------------------------------------------------------- 00006 // version 1: Aug 2000 Simon Portegies Zwart spz@mit.edu 00007 // mit 00008 //............................................................................. 00009 // non-local functions: 00010 //----------------------------------------------------------------------------- 00011 00012 #include "stdinc.h" 00013 #include "sdyn.h" 00014 #include "scatter_exp.h" 00015 // 00016 // scatter_hist.h 00017 // 00018 00019 #ifndef _SCATTER_HIST 00020 # define _SCATTER_HIST 00021 00022 /*----------------------------------------------------------------------------- 00023 * scatter_hist -- a linked list of scatter histories. 00024 *----------------------------------------------------------------------------- 00025 */ 00026 class scatter_hist : public scatter_exp { 00027 protected: 00028 00029 // int *stellar_identities; // {1,2,3,4,5} 00030 // int n_relations; // 4 00031 // int *stellar_relations; // {1,2, 1,3, 2,3 4,5} 00032 00033 scatter_hist * past; 00034 scatter_hist * future; 00035 00036 public: 00037 scatter_hist(istream &s) : scatter_exp(s) { 00038 00039 past=NULL; 00040 future=NULL; 00041 } 00042 00043 scatter_hist(scatter_exp &hi) : scatter_exp(hi) { 00044 00045 past=NULL; 00046 future=NULL; 00047 } 00048 00049 scatter_hist() : scatter_exp() { 00050 00051 // for(int i=0; i<N_RHO_ZONE_MAX; i++) 00052 // n_hits[i] = 0; 00053 00054 // if (s) { 00055 // past=s; 00056 // past->future=this; 00057 // future = NULL; 00058 // } 00059 // else { 00060 past=NULL; 00061 future=NULL; 00062 // } 00063 } 00064 00065 ~scatter_hist(){ 00066 00067 if (future!=NULL) { 00068 scatter_hist *tmp = future; 00069 future = NULL; 00070 delete tmp; 00071 } 00072 00073 if (past) 00074 past->future = NULL; 00075 } 00076 00077 scatter_hist* get_past() {return past;} 00078 void set_past(scatter_hist *sb) {past = sb;} 00079 scatter_hist* get_future() {return future;} 00080 scatter_hist* get_first() { 00081 if (past!=NULL) 00082 return past->get_first(); 00083 else 00084 return this; 00085 } 00086 scatter_hist* get_last() { 00087 if (future!=NULL) 00088 return future->get_last(); 00089 else 00090 return this; 00091 } 00092 00093 void set_future(scatter_hist* f) {future = f;} 00094 void set_last(scatter_hist* f) { 00095 if(future!=NULL) 00096 future->set_last(f); 00097 else 00098 future=f; 00099 } 00100 00101 scatter_hist* get_scatter_hist(sdyn* b=NULL); 00102 void add_scatter_hist(istream &s); 00103 void add_scatter_hist(scatter_exp he, int zone); 00104 scatter_hist* scatter_hist::contains(scatter_hist*); 00105 00106 scatter_hist* get_identical_scatter_hist(); 00107 void inc_id_scenario(); 00108 00109 void put_scatter_hist(ostream&, bool verbose = false); 00110 00111 // bool read_scatter_hist(istream& s); 00112 00113 void put_state(ostream&); 00114 00115 }; 00116 00117 #define for_all_scatter_hist(scatter_hist, base, scatter_hist_next) \ 00118 for (scatter_hist* scatter_hist_next = base; \ 00119 scatter_hist_next != NULL; \ 00120 scatter_hist_next = scatter_hist_next->get_future()) 00121 00122 scatter_hist* get_history(scatter_hist *hi, istream& is); 00123 00124 //bool scenarios_identical(scatter_hist* hi, scatter_hist* ha); 00125 void put_state(scatter_hist * hi, ostream & s); 00126 scatter_hist* initialize_scatter_hist(sdyn* b); 00127 00128 #endif