Cantera  2.0
IdealGasMix.h
1 #ifndef CXX_IDEALGASMIX
2 #define CXX_IDEALGASMIX
3 
4 #include <string>
5 
6 #include "thermo/IdealGasPhase.h"
7 #include "kinetics/GasKinetics.h"
9 #include "base/stringUtils.h"
10 
11 namespace Cantera
12 {
13 
14 class IdealGasMix :
15  public IdealGasPhase,
16  public GasKinetics
17 {
18 public:
19 
20  IdealGasMix() : m_ok(false), m_r(0) {}
21 
22  IdealGasMix(std::string infile, std::string id="") :
23  m_ok(false), m_r(0) {
24 
25  m_r = get_XML_File(infile);
26  m_id = id;
27  if (id == "-") {
28  id = "";
29  }
30  m_ok = buildSolutionFromXML(*m_r,
31  m_id, "phase", this, this);
32  if (!m_ok) throw CanteraError("IdealGasMix",
33  "Cantera::buildSolutionFromXML returned false");
34  }
35 
36 
37  IdealGasMix(XML_Node& root,
38  std::string id) : m_ok(false), m_r(&root), m_id(id) {
39  m_ok = buildSolutionFromXML(root, id, "phase", this, this);
40  }
41 
42  IdealGasMix(const IdealGasMix& other) : m_ok(false),
43  m_r(other.m_r),
44  m_id(other.m_id) {
45  m_ok = buildSolutionFromXML(*m_r, m_id, "phase", this, this);
46  }
47 
48  virtual ~IdealGasMix() {}
49 
50  bool operator!() {
51  return !m_ok;
52  }
53  bool ready() const {
54  return m_ok;
55  }
56  friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) {
57  std::string r = mix.report(true);
58  s << r;
59  return s;
60  }
61 
62 
63 protected:
64  bool m_ok;
65  XML_Node* m_r;
66  std::string m_id;
67 
68 private:
69 };
70 }
71 
72 
73 #endif