Cantera
2.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
converters
Element.h
Go to the documentation of this file.
1
/**
2
* @file Element.h
3
*
4
*/
5
6
// Copyright 2001 California Institute of Technology
7
8
9
#ifndef CKR_ELEMENT_H
10
#define CKR_ELEMENT_H
11
12
#include <string>
13
#include <vector>
14
#include <ostream>
15
16
17
namespace
ckr
18
{
19
20
/**
21
* A class for elements.
22
* Example usage:
23
* @code
24
* Element e;
25
* e.name = "He";
26
* e.atomicWeight = 4.0026;
27
* e.comment = "helium";
28
* @endcode
29
*/
30
class
Element
31
{
32
public
:
33
34
/// Construct a new empty Element object
35
Element
() :
36
name
(
"<empty>"
),
37
atomicWeight
(0.0),
38
valid
(0),
39
index
(-1),
40
weightFromDB
(false),
41
comment
(
""
)
42
{}
43
44
45
/// Construct a new empty Element object
46
Element
(
const
std::string& nm,
double
wt) :
47
name
(nm),
48
atomicWeight
(wt),
49
valid
(0),
50
index
(-1),
51
weightFromDB
(false),
52
comment
(
""
)
53
{}
54
55
56
/// Destructor
57
~Element
() {}
58
59
std::string
name
;
//!< Element name
60
double
atomicWeight
;
//!< Atomic weight in amu
61
int
valid
;
//!< flag returned by validation routines
62
int
index
;
//!< index number
63
bool
weightFromDB
;
//!< true if atomic weight is not specified
64
std::string
comment
;
//!< comment in input file
65
66
67
/**
68
* Compare two Element instances for equality based on name.
69
* Primarily for internal use.
70
*/
71
bool
operator==
(
const
Element
& e)
const
{
72
return
(
name
== e.
name
);
73
}
74
bool
operator!=(
const
Element
& e)
const
{
75
return
!(*
this
== e);
76
}
77
friend
std::ostream& operator<<(std::ostream& s,
const
Element
& e) {
78
s << e.name;
79
if
(!e.weightFromDB) {
80
s <<
"/"
<< e.atomicWeight <<
"/"
;
81
}
82
if
(e.comment !=
""
) {
83
s <<
" !"
<< e.comment << std::endl;
84
}
else
{
85
s <<
" "
;
86
}
87
return
s;
88
}
89
};
90
91
/// a list (vector) of Elements
92
typedef
std::vector<Element>
elementList
;
93
94
}
95
96
97
#endif
98
Generated by
1.8.2