cloudy  trunk
flux.h
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2013 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 
4 #ifndef FLUX_H_
5 #define FLUX_H_
6 
7 #include "energy.h"
8 
9 class Flux
10 {
11  typedef enum {
14  } fu_flag;
15  typedef bitset<FU_TOP> fu_bits;
16 
18  double p_flux;
20 
21  fu_bits p_InternalFluxUnitNoCheck(const string& unit, size_t& len) const;
22  fu_bits p_InternalFluxUnit(const string& unit) const;
23  bool p_ValidFluxUnit(fu_bits) const;
24  void p_set(Energy e, double value, fu_bits bits);
25  double p_get(fu_bits bits) const;
26 public:
27  // CONSTRUCTORS
28  Flux()
29  {
30  set(0., 0.);
31  p_userunits.reset();
32  }
33  Flux(Energy e, double flux)
34  {
35  set(e, flux);
36  }
37  Flux(Energy e, double flux, const string& unit)
38  {
39  set(e, flux, unit);
40  }
41  // MUTATORS
42  void set(Energy e, double flux)
43  {
44  set( e, flux, "erg/s/cm2" );
45  }
46  void set(Energy e, double flux, const string& unit)
47  {
48  p_set( e, flux, p_InternalFluxUnit(unit) );
49  }
50  // ACCESSORS
51  double get() const
52  {
53  return p_flux;
54  }
55  double get(const string& unit) const
56  {
57  return p_get( p_InternalFluxUnit(unit) );
58  }
59  Energy E() const
60  {
61  return p_energy;
62  }
63  string uu() const;
64  friend inline bool ValidFluxUnit(const string& unit);
65 };
66 
67 // parse standard flux unit from Cloudy input line
68 string StandardFluxUnit(const char*);
69 
70 // check if standard unit is valid
71 inline bool ValidFluxUnit(const string& unit)
72 {
73  Flux f;
74  size_t p;
76  return ( p == unit.length() && f.p_ValidFluxUnit(bits) );
77 }
78 
79 #endif /* FLUX_H_ */
Flux::get
double get() const
Definition: flux.h:51
Flux::p_InternalFluxUnit
fu_bits p_InternalFluxUnit(const string &unit) const
Definition: flux.cpp:87
Flux::ValidFluxUnit
friend bool ValidFluxUnit(const string &unit)
Definition: flux.h:71
Flux::FU_A
@ FU_A
Definition: flux.h:13
Flux::FU_M2
@ FU_M2
Definition: flux.h:13
Flux::Flux
Flux(Energy e, double flux, const string &unit)
Definition: flux.h:37
Flux::p_userunits
fu_bits p_userunits
Definition: flux.h:19
energy.h
Flux::FU_NONE
@ FU_NONE
Definition: flux.h:12
Flux::set
void set(Energy e, double flux)
Definition: flux.h:42
Flux::FU_CM2
@ FU_CM2
Definition: flux.h:12
Flux::FU_JY
@ FU_JY
Definition: flux.h:12
ValidFluxUnit
bool ValidFluxUnit(const string &unit)
Definition: flux.h:71
Flux::FU_ERG_S
@ FU_ERG_S
Definition: flux.h:12
Flux::FU_MJY
@ FU_MJY
Definition: flux.h:12
Flux::p_energy
Energy p_energy
Definition: flux.h:17
StandardFluxUnit
string StandardFluxUnit(const char *)
Definition: flux.cpp:207
Flux::Flux
Flux()
Definition: flux.h:28
Flux::fu_flag
fu_flag
Definition: flux.h:11
Flux::p_InternalFluxUnitNoCheck
fu_bits p_InternalFluxUnitNoCheck(const string &unit, size_t &len) const
Definition: flux.cpp:10
Flux::FU_NM
@ FU_NM
Definition: flux.h:13
Flux::p_set
void p_set(Energy e, double value, fu_bits bits)
Definition: flux.cpp:175
Flux::set
void set(Energy e, double flux, const string &unit)
Definition: flux.h:46
Flux::FU_TOP
@ FU_TOP
Definition: flux.h:13
Flux::FU_W
@ FU_W
Definition: flux.h:12
Flux::FU_MU
@ FU_MU
Definition: flux.h:13
Flux::FU_HZ
@ FU_HZ
Definition: flux.h:13
Flux::fu_bits
bitset< FU_TOP > fu_bits
Definition: flux.h:15
Flux
Definition: flux.h:9
Energy
Definition: energy.h:7
Flux::p_flux
double p_flux
Definition: flux.h:18
Flux::p_get
double p_get(fu_bits bits) const
Definition: flux.cpp:144
Flux::get
double get(const string &unit) const
Definition: flux.h:55
Flux::FU_SR
@ FU_SR
Definition: flux.h:13
Flux::E
Energy E() const
Definition: flux.h:59
Flux::Flux
Flux(Energy e, double flux)
Definition: flux.h:33
Flux::p_ValidFluxUnit
bool p_ValidFluxUnit(fu_bits) const
Definition: flux.cpp:101
Flux::uu
string uu() const
Definition: flux.cpp:257
Flux::FU_MJY_SR
@ FU_MJY_SR
Definition: flux.h:12
Flux::FU_SQAS
@ FU_SQAS
Definition: flux.h:13