Added the copy constructor and assignment operator.

This commit is contained in:
Harry Moffat 2005-10-24 15:39:22 +00:00
parent 2fe5f76650
commit 046dc24775
2 changed files with 49 additions and 1 deletions

View file

@ -28,6 +28,41 @@ namespace Cantera {
State::~State() {}
State::State(const State& right) :
m_kk(0),
m_temp(0.0),
m_dens(0.001),
m_mmw(0.0) {
/*
* Call the assignment operator.
*/
*this = operator=(right);
}
/*
* Assignment operator for the State Class
*/
State& State::operator=(const State& right) {
/*
* Check for self assignment.
*/
if (this == &right) return *this;
/*
* We do a straight assignment operator on all of the
* data. The vectors are copied.
*/
m_temp = right.m_temp;
m_dens = right.m_dens;
m_mmw = right.m_mmw;
m_y = right.m_y;
m_molwts = right.m_molwts;
m_rmolwts = right.m_rmolwts;
/*
* Return the reference to the current object
*/
return *this;
}
doublereal State::moleFraction(int k) const {
if (k >= 0 && k < m_kk) {
return m_ym[k] * m_mmw;

View file

@ -24,7 +24,10 @@
namespace Cantera {
/**
* Manages the thermodynamic state. Class State stores just enough
* Manages the independent variables of temperature, mass
* density, and mass/mole species fraction that define the
* thermodynamic state.
* Class State stores just enough
* information about a multicomponent solution to specify its
* intensive thermodynamic state. It stores values for the
* temperature, mass density, and an array of species mass
@ -57,6 +60,16 @@ namespace Cantera {
*/
virtual ~State();
/**
* Copy Constructor for the State Class
*/
State(const State& right);
/**
* Assignment operator for the state class.
*/
State& operator=(const State& right);
/// @name Species Information
/// The only thing class State knows about the species is their