00001
00002
00003
00004 #ifndef QUANTUMSTATE_H_
00005 #define QUANTUMSTATE_H_
00006 #include "energy.h"
00007 #include "proxy_iterator.h"
00008
00009 class quantumStateLabels
00010 {
00011 char m_chLabel[5];
00012 char m_chConfig[11];
00013 public:
00014 char *chLabel()
00015 {
00016 return m_chLabel;
00017 }
00018 const char *chLabel() const
00019 {
00020 return m_chLabel;
00021 }
00022 char *chConfig()
00023 {
00024 return m_chConfig;
00025 }
00026 const char *chConfig() const
00027 {
00028 return m_chConfig;
00029 }
00030 };
00031
00032
00033
00034
00035 class qStateProxy;
00036 class qStateConstProxy;
00037 void Junk(qStateProxy);
00038 void Zero(qStateProxy);
00039
00040 class qList
00041 {
00042 vector<quantumStateLabels> m_labels;
00043 vector<double> m_ConBoltz;
00044 vector<double> m_Boltzmann;
00045 vector<Energy> m_energy;
00046 vector<realnum> m_g;
00047 vector<long> m_j;
00048 vector<long> m_J;
00049 vector<int> m_IonStg;
00050 vector<int> m_nelem;
00051 vector<long> m_l;
00052 vector<double> m_lifetime;
00053 vector<long> m_n;
00054 vector<double> m_ColDen;
00055 vector<double> m_Pop;
00056 vector<double> m_DestCollBB;
00057 vector<double> m_DestPhotoBB;
00058 vector<double> m_CreatCollBB;
00059 vector<long> m_S;
00060 vector<long> m_v;
00061 friend class qStateProxy;
00062 friend class qStateConstProxy;
00063 public:
00064 typedef ProxyIterator<qStateProxy,qStateConstProxy> iterator;
00065 typedef ProxyIterator<qStateConstProxy,qStateConstProxy> const_iterator;
00066 typedef qStateProxy reference;
00067 typedef qStateConstProxy const_reference;
00068 explicit qList()
00069 {
00070 resize(0);
00071 }
00072 explicit qList(size_t i)
00073 {
00074 resize(i);
00075 }
00076 iterator begin();
00077 const_iterator begin() const;
00078 iterator end();
00079 const_iterator end() const;
00080 reference operator[](int i);
00081 const_reference operator[](int i) const;
00082
00083 void resize(size_t i)
00084 {
00085 size_t old_size = size();
00086 m_labels.resize(i);
00087 m_ConBoltz.resize(i);
00088 m_Boltzmann.resize(i);
00089 m_energy.resize(i);
00090 m_g.resize(i);
00091 m_IonStg.resize(i);
00092 m_j.resize(i);
00093 m_J.resize(i);
00094 m_lifetime.resize(i);
00095 m_l.resize(i);
00096 m_n.resize(i);
00097 m_nelem.resize(i);
00098 m_ColDen.resize(i);
00099 m_Pop.resize(i);
00100 # ifdef USE_NLTE7
00101 m_DestCollBB.resize(i);
00102 m_DestPhotoBB.resize(i);
00103 m_CreatCollBB.resize(i);
00104 # endif
00105 m_S.resize(i);
00106 m_v.resize(i);
00107 for (size_t n=old_size; n<i; ++n)
00108 {
00109 reset(n);
00110 }
00111 }
00112 void reset(int n);
00113
00114
00115
00116 size_t size() const
00117 {
00118 return m_labels.size();
00119 }
00120 };
00121
00122
00123
00124
00125
00126
00127
00128
00129 class qStateConstProxy;
00130 class qStateProxy
00131 {
00132 public:
00133 typedef qList list_type;
00134 typedef ProxyIterator<qStateProxy,qStateConstProxy> iterator;
00135 private:
00136 friend class ProxyIterator<qStateProxy,qStateConstProxy>;
00137 list_type *m_list;
00138 int m_index;
00139 public:
00140 explicit qStateProxy(list_type* list, int index) :
00141 m_list(list), m_index(index) {}
00142 explicit qStateProxy(void) : m_list(NULL), m_index(0) {}
00143
00144 char *chLabel() const
00145 {
00146 return m_list->m_labels[m_index].chLabel();
00147 }
00148 char *chConfig() const
00149 {
00150 return m_list->m_labels[m_index].chConfig();
00151 }
00153 Energy &energy() const
00154 {
00155 return m_list->m_energy[m_index];
00156 }
00158 realnum &g() const
00159 {
00160 return m_list->m_g[m_index];
00161 }
00163 double &Pop() const
00164 {
00165 return m_list->m_Pop[m_index];
00166 }
00168 double &ColDen() const
00169 {
00170 return m_list->m_ColDen[m_index];
00171 }
00172 # ifdef USE_NLTE7
00173
00174 double &DestCollBB() const
00175 {
00176 return m_list->m_DestCollBB[m_index];
00177 }
00179 double &DestPhotoBB() const
00180 {
00181 return m_list->m_DestPhotoBB[m_index];
00182 }
00184 double &CreatCollBB() const
00185 {
00186 return m_list->m_CreatCollBB[m_index];
00187 }
00188 # endif
00189
00190 int &IonStg() const
00191 {
00192 return m_list->m_IonStg[m_index];
00193 }
00195 int &nelem() const
00196 {
00197 return m_list->m_nelem[m_index];
00198 }
00200 double &ConBoltz() const
00201 {
00202 return m_list->m_ConBoltz[m_index];
00203 }
00205 double &Boltzmann() const
00206 {
00207 return m_list->m_Boltzmann[m_index];
00208 }
00210 double &lifetime() const
00211 {
00212 return m_list->m_lifetime[m_index];
00213 }
00214 long &n() const
00215 {
00216 return m_list->m_n[m_index];
00217 }
00218 long &l() const
00219 {
00220 return m_list->m_l[m_index];
00221 }
00222 long &S() const
00223 {
00224 return m_list->m_S[m_index];
00225 }
00226 long &v() const
00227 {
00228 return m_list->m_v[m_index];
00229 }
00230 long &j() const
00231 {
00232 return m_list->m_j[m_index];
00233 }
00234 long &J() const
00235 {
00236 return m_list->m_J[m_index];
00237 }
00238 };
00239 class qStateConstProxy
00240 {
00241 public:
00242 typedef const qList list_type;
00243 typedef ProxyIterator<qStateConstProxy,qStateConstProxy> iterator;
00244 private:
00245 friend class ProxyIterator<qStateConstProxy,qStateConstProxy>;
00246 const list_type *m_list;
00247 int m_index;
00248 public:
00249 explicit qStateConstProxy(const list_type* list, int index) :
00250 m_list(list), m_index(index) {}
00251 explicit qStateConstProxy(void) : m_list(NULL), m_index(0) {}
00252
00253 const char *chLabel() const
00254 {
00255 return m_list->m_labels[m_index].chLabel();
00256 }
00257 const char *chConfig() const
00258 {
00259 return m_list->m_labels[m_index].chConfig();
00260 }
00261 Energy energy() const
00262 {
00263 return m_list->m_energy[m_index];
00264 }
00265 realnum g() const
00266 {
00267 return m_list->m_g[m_index];
00268 }
00269 double ColDen() const
00270 {
00271 return m_list->m_ColDen[m_index];
00272 }
00273 double Pop() const
00274 {
00275 return m_list->m_Pop[m_index];
00276 }
00277 # ifdef USE_NLTE7
00278 double DestCollBB() const
00279 {
00280 return m_list->m_DestCollBB[m_index];
00281 }
00282 double DestPhotoBB() const
00283 {
00284 return m_list->m_DestPhotoBB[m_index];
00285 }
00286 double CreatCollBB() const
00287 {
00288 return m_list->m_CreatCollBB[m_index];
00289 }
00290 # endif
00291 int IonStg() const
00292 {
00293 return m_list->m_IonStg[m_index];
00294 }
00295 int nelem() const
00296 {
00297 return m_list->m_nelem[m_index];
00298 }
00299 double ConBoltz() const
00300 {
00301 return m_list->m_ConBoltz[m_index];
00302 }
00303 double Boltzmann() const
00304 {
00305 return m_list->m_Boltzmann[m_index];
00306 }
00307 double lifetime() const
00308 {
00309 return m_list->m_lifetime[m_index];
00310 }
00311 long n() const
00312 {
00313 return m_list->m_n[m_index];
00314 }
00315 long l() const
00316 {
00317 return m_list->m_l[m_index];
00318 }
00319 long S() const
00320 {
00321 return m_list->m_S[m_index];
00322 }
00323 long v() const
00324 {
00325 return m_list->m_v[m_index];
00326 }
00327 long j() const
00328 {
00329 return m_list->m_j[m_index];
00330 }
00331 long J() const
00332 {
00333 return m_list->m_J[m_index];
00334 }
00335 };
00336
00337 inline qList::iterator qList::begin()
00338 {
00339 return iterator(this,0);
00340 }
00341 inline qList::const_iterator qList::begin() const
00342 {
00343 return const_iterator(this,0);
00344 }
00345 inline qList::iterator qList::end()
00346 {
00347 return iterator(this,m_labels.size());
00348 }
00349 inline qList::const_iterator qList::end() const
00350 {
00351 return const_iterator(this,m_labels.size());
00352 }
00353 inline qList::reference qList::operator[](int i)
00354 {
00355 return begin()[i];
00356 }
00357 inline qList::const_reference qList::operator[](int i) const
00358 {
00359 return begin()[i];
00360 }
00361 inline void qList::reset(int n)
00362 {
00363 Junk((*this)[n]);
00364 Zero((*this)[n]);
00365 }
00366
00367
00368 #endif