00001 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 #include "stdinc.h"
00014 #include "node.h"
00015 #include "double_star.h"
00016 #include "main_sequence.h"
00017 
00018 
00019 
00020 
00021 #ifndef    _SeBa_HIST
00022 #  define  _SeBa_HIST
00023 
00024 
00025 
00026 enum binary_parameter {identity=0, bin_type, current_time,
00027                        primary_mass, primary_radius,
00028                        secondary_mass, secondary_radius,
00029                        semi_major_axis, eccentricity, mass_ratio
00030                       };
00031 
00032 
00033 
00034 
00035 
00036 class SeBa_hist {
00037     protected:
00038 
00039     int  number;
00040     real time;
00041 
00042     binary_type bin_tpe;
00043     real semi;
00044     real ecc;
00045 
00046     char label_prim[255];
00047     stellar_type tpe_prim;
00048     real m_prim;
00049     real r_prim;
00050     
00051     char label_sec[255];
00052     stellar_type tpe_sec;
00053     real m_sec;
00054     real r_sec;
00055 
00056     SeBa_hist * past;
00057     SeBa_hist * future;
00058 
00059     public:
00060        SeBa_hist(SeBa_hist* s=NULL) {
00061            if (s) {
00062               past=s;
00063               past->future=this;
00064               future = NULL;
00065            }
00066            else {
00067               past=NULL;
00068               future=NULL;
00069           }
00070 
00071            number = 0;
00072            time   = 0;
00073            bin_tpe = Detached;
00074            strcpy(label_prim, "1a");
00075            strcpy(label_sec, "1b");
00076            tpe_prim = tpe_sec = Main_Sequence;
00077            m_prim=m_sec=r_prim=r_sec=0;
00078        }
00079        ~SeBa_hist(){
00080 
00081          if (future!=NULL) {
00082              SeBa_hist *tmp = future;
00083              future = NULL;
00084              delete tmp;
00085          }
00086 
00087          if (past)
00088             past->future = NULL;
00089        }
00090 
00091        SeBa_hist* get_past() {return past;}
00092        void set_past(SeBa_hist *sb) {past = sb;}
00093        SeBa_hist* get_future() {return future;}
00094        SeBa_hist* get_first() {
00095            if (past!=NULL)
00096               return past->get_first();
00097            else
00098               return this;
00099        }
00100        SeBa_hist* get_last() {
00101            if (future!=NULL)
00102               return future->get_last();
00103            else 
00104               return this;
00105        }
00106 
00107        void set_future(SeBa_hist* f) {future = f;}
00108        void set_last(SeBa_hist* f) {
00109             if(future!=NULL) 
00110               future->set_last(f);
00111             else 
00112               future=f;
00113        }
00114 
00115        real get_time()              {return time;}
00116        int get_number()             {return number;}
00117        int set_number(int n)        {number = n;}
00118 
00119        real set_stellar_radius(bool);
00120        void move_SeBa_hist_to(SeBa_hist*);
00121        bool read_SeBa_hist(istream&);
00122 
00123        void put_history(ostream&, bool);
00124        void put_single_reverse(ostream&);
00125        void put_first_formed_left(char*, real);
00126 
00127        bool binary_contains(char*, char *, binary_type);
00128        bool binary_limits(binary_parameter, real, real);
00129        real get_parameter(binary_parameter);
00130        binary_type get_binary_type() { return bin_tpe;}
00131        stellar_type get_primary_type() { return tpe_prim;}
00132        stellar_type get_secondary_type() { return tpe_sec;}
00133        char* get_label_prim() {return label_prim;}
00134        char* get_label_sec() {return label_sec;}
00135 
00136        SeBa_hist* get_SeBa_hist_at_time(real);
00137 
00138     void add_to_SeBa_hist(SeBa_hist *next_hi);
00139                                   
00140        void put_state(ostream&);
00141        friend ostream& operator<<(ostream& s, SeBa_hist&);
00142 
00143        bool operator == (SeBa_hist& ha) const;
00144        bool operator != (SeBa_hist& ha) const;
00145 
00146 
00147 
00148 };
00149 
00150 #define for_all_SeBa_hist(SeBa_hist, base, SeBa_hist_next)                    \
00151         for (SeBa_hist* SeBa_hist_next = base;                                \
00152              SeBa_hist_next != NULL;                            \
00153              SeBa_hist_next = SeBa_hist_next->get_future())
00154 
00155 
00156 SeBa_hist* get_history(SeBa_hist *hi, istream& is);
00157 
00158 bool scenarios_identical(SeBa_hist* hi, SeBa_hist* ha);
00159 void put_state(SeBa_hist * hi, ostream & s);
00160 
00161 #endif