00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef STARLAB_PDYN_H
00024 # define STARLAB_PDYN_H
00025
00026 #include "dyn.h"
00027
00031
00032 class _pdyn_ : public dyn
00033 {
00034 protected:
00035
00036 int worldline_index;
00037
00038
00039
00040 int stellar_type;
00041 real temperature;
00042 real luminosity;
00043
00044 public:
00045
00046 inline void _pdyn_init() {
00047 worldline_index = -1;
00048 stellar_type = -42;
00049 temperature = luminosity = 0;
00050 }
00051
00052 _pdyn_(hbpfp the_hbpfp = new_hydrobase, sbpfp the_sbpfp = new_starbase,
00053 bool use_stories = true)
00054 : dyn(the_hbpfp, the_sbpfp, use_stories) {_pdyn_init();}
00055
00056 virtual ~_pdyn_() {}
00057
00058 inline void set_worldline_index(int w) {worldline_index = w;}
00059 inline int get_worldline_index() {return worldline_index;}
00060
00061 inline void set_temperature(real t) {temperature = t;}
00062 inline real get_temperature() {return temperature;}
00063
00064 inline void set_luminosity(real t) {luminosity = t;}
00065 inline real get_luminosity() {return luminosity;}
00066
00067 inline void set_stellar_type(int s) {stellar_type = s;}
00068 inline int get_stellar_type() {return stellar_type;}
00069
00070 inline _pdyn_ * get_parent()
00071 {return (_pdyn_*) node::get_parent();}
00072 inline _pdyn_ * get_oldest_daughter()
00073 {return (_pdyn_*)node::get_oldest_daughter();}
00074 inline _pdyn_ * get_younger_sister()
00075 {return (_pdyn_*) node::get_younger_sister();}
00076 inline _pdyn_ * get_elder_sister()
00077 {return (_pdyn_*) node::get_elder_sister();}
00078
00080
00081 inline _pdyn_ * get_root()
00082 {return (_pdyn_*) node::get_root();}
00083
00085
00086 inline _pdyn_ * get_top_level_node()
00087 {return (_pdyn_*) node::get_top_level_node();}
00088
00090
00091 inline _pdyn_ * get_binary_sister()
00092 {return (_pdyn_*) node::get_binary_sister();}
00093
00094 virtual real get_radius();
00095 virtual ostream& print_dyn_story(ostream &s,
00096 bool print_xreal = true,
00097 int short_output = 0);
00098 };
00099
00100 typedef _pdyn_ *_pdyn_ptr;
00101
00102 inline node * new_pdyn_(hbpfp the_hbpfp, sbpfp the_sbpfp,
00103 bool use_stories = true)
00104 {return (node *) new _pdyn_(the_hbpfp, the_sbpfp, use_stories);}
00105
00106 inline _pdyn_ * get_pdyn_(istream & s = cin,
00107 hbpfp the_hbpfp = new_hydrobase,
00108 sbpfp the_sbpfp = new_starbase,
00109 bool use_stories = true)
00110 {return (_pdyn_ *) get_node(s, new_pdyn_, the_hbpfp, the_sbpfp,
00111 use_stories);}
00112
00113 #define put_pdyn_ put_node
00114
00115 class tdyn;
00116
00118
00119 class pdyn : public _pdyn_
00120 {
00121 protected:
00122
00123 tdyn *kepevent;
00124 kepler *kep2;
00125 tdyn *kepevent2;
00126
00127 public:
00128
00129 pdyn(hbpfp the_hbpfp = new_hydrobase, sbpfp the_sbpfp = new_starbase,
00130 bool use_stories = true)
00131 : _pdyn_(the_hbpfp, the_sbpfp, use_stories) {
00132 kepevent = kepevent2 = NULL;
00133 kep2 = NULL;
00134 }
00135
00136 inline void rmkepler2() {
00137 if (kep2) {
00138 pdyn* s = (pdyn*)get_binary_sister();
00139
00140 if (s && s->kep2 == kep2)
00141 s->kep2 = NULL;
00142
00143 delete kep2;
00144 kep2 = NULL;
00145 }
00146 }
00147
00148 virtual ~pdyn()
00149 {
00150 if (kep2)
00151 rmkepler2();
00152 }
00153
00154 inline kepler * get_kepler2() {return kep2;}
00155 void set_kepler2(kepler * new_kep) {kep2 = new_kep;}
00156
00157 inline tdyn *get_kepevent() {return kepevent;}
00158 inline void set_kepevent(tdyn *t) {kepevent = t;}
00159
00160 inline tdyn *get_kepevent2() {return kepevent2;}
00161 inline void set_kepevent2(tdyn *t) {kepevent2 = t;}
00162
00163
00164
00165 inline pdyn * get_parent()
00166 {return (pdyn*) node::get_parent();}
00167 inline pdyn * get_oldest_daughter()
00168 {return (pdyn*)node::get_oldest_daughter();}
00169 inline pdyn * get_younger_sister()
00170 {return (pdyn*) node::get_younger_sister();}
00171 inline pdyn * get_elder_sister()
00172 {return (pdyn*) node::get_elder_sister();}
00173
00174 inline pdyn * get_root()
00175 {return (pdyn*) node::get_root();}
00176 inline pdyn * get_top_level_node()
00177 {return (pdyn*) node::get_top_level_node();}
00178 inline pdyn * get_binary_sister()
00179 {return (pdyn*) node::get_binary_sister();}
00180
00181
00182
00183 virtual istream& scan_star_story(istream&, int level = 0);
00184 virtual istream& scan_dyn_story(istream&);
00185
00186 #if 0
00187 virtual ostream& pdyn::print_star_story(ostream& s,
00188 int short_output = 0)
00189 #endif
00190
00191 };
00192
00193 typedef pdyn *pdynptr;
00194
00195 inline node * newpdyn(hbpfp the_hbpfp, sbpfp the_sbpfp,
00196 bool use_stories = true)
00197 {return (node *) new pdyn(the_hbpfp, the_sbpfp, use_stories);}
00198
00199 inline pdyn * getpdyn(istream & s = cin,
00200 hbpfp the_hbpfp = new_hydrobase,
00201 sbpfp the_sbpfp = new_starbase,
00202 bool use_stories = true)
00203 {return (pdyn *) get_node(s, newpdyn, the_hbpfp, the_sbpfp,
00204 use_stories);}
00205
00206 #define put_pdyn put_node
00207
00208 #endif