cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
flux.h
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2022 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_ */
bool p_ValidFluxUnit(fu_bits) const
Definition: flux.cpp:99
fu_bits p_userunits
Definition: flux.h:19
bool ValidFluxUnit(const string &unit)
Definition: flux.h:71
Energy p_energy
Definition: flux.h:17
fu_bits p_InternalFluxUnitNoCheck(const string &unit, size_t &len) const
Definition: flux.cpp:8
Flux()
Definition: flux.h:28
Flux(Energy e, double flux, const string &unit)
Definition: flux.h:37
fu_bits p_InternalFluxUnit(const string &unit) const
Definition: flux.cpp:85
Definition: flux.h:9
double p_get(fu_bits bits) const
Definition: flux.cpp:142
fu_flag
Definition: flux.h:11
string uu() const
Definition: flux.cpp:255
Energy E() const
Definition: flux.h:59
void p_set(Energy e, double value, fu_bits bits)
Definition: flux.cpp:173
bitset< FU_TOP > fu_bits
Definition: flux.h:15
void set(Energy e, double flux, const string &unit)
Definition: flux.h:46
string StandardFluxUnit(const char *chCard)
Definition: flux.cpp:205
double p_flux
Definition: flux.h:18
Definition: energy.h:9
Flux(Energy e, double flux)
Definition: flux.h:33
void set(Energy e, double flux)
Definition: flux.h:42
friend bool ValidFluxUnit(const string &unit)
Definition: flux.h:71