Added copy constructors and assignment operators where they were

missing. Working towards getting the duplicate member functions
to work.
This commit is contained in:
Harry Moffat 2007-06-01 19:12:18 +00:00
parent 9773c9b23b
commit a42ef08f9c
11 changed files with 241 additions and 8 deletions

View file

@ -23,6 +23,35 @@
namespace Cantera {
ConstDensityThermo::ConstDensityThermo() : m_tlast(0.0) {
}
ConstDensityThermo::ConstDensityThermo(const ConstDensityThermo &right)
: m_tlast(0.0) {
*this = operator=(right);
}
ConstDensityThermo& ConstDensityThermo::operator=(const ConstDensityThermo &right) {
if (&right == this) return *this;
m_mm = right.m_mm;
m_tmin = right.m_tmin;
m_tmax = right.m_tmax;
m_p0 = right.m_p0;
m_tlast = right.m_tlast;
m_h0_RT = right.m_h0_RT;
m_cp0_R = right.m_cp0_R;
m_g0_RT = right.m_g0_RT;
m_s0_R = right.m_s0_R;
m_expg0_RT = right.m_expg0_RT;
m_pe = right.m_pe;
m_pp = right.m_pp;
return *this;
}
int ConstDensityThermo::
eosType() const { return cIncompressible; }

View file

@ -54,11 +54,23 @@ namespace Cantera {
/*!
*
*/
ConstDensityThermo() : m_tlast(0.0) {}
ConstDensityThermo();
//! Destructor
virtual ~ConstDensityThermo() {}
//! Copy Constructor
/*!
* @param right Object to be copied
*/
ConstDensityThermo(const ConstDensityThermo &right);
//! Assignment Operator
/*!
* @param right Object to be copied
*/
ConstDensityThermo& operator=(const ConstDensityThermo &right);
// overloaded methods of class ThermoPhase
virtual int eosType() const;

View file

@ -44,7 +44,7 @@ namespace Cantera {
m_sp = b.m_sp;
}
const GeneralSpeciesThermo&
GeneralSpeciesThermo&
GeneralSpeciesThermo::operator=(const GeneralSpeciesThermo &b) {
if (&b != this) {
m_tlow_max = b.m_tlow_max;

View file

@ -46,7 +46,7 @@ namespace Cantera {
GeneralSpeciesThermo(const GeneralSpeciesThermo &);
//! Assignment operator
const GeneralSpeciesThermo & operator=(const GeneralSpeciesThermo &);
GeneralSpeciesThermo & operator=(const GeneralSpeciesThermo &);
//! destructor
virtual ~GeneralSpeciesThermo();

View file

@ -66,8 +66,6 @@ namespace Cantera {
m_Mnaught(b.m_Mnaught),
m_molalities(b.m_molalities)
{
throw CanteraError("MolalityVPSSTP::operator=()",
"Not Implemented Fully");
*this = operator=(b);
}
@ -87,8 +85,6 @@ namespace Cantera {
m_Mnaught = b.m_Mnaught;
m_molalities = b.m_molalities;
}
throw CanteraError("MolalityVPSSTP::operator=()",
"Not Implemented Fully");
return *this;
}

View file

@ -73,6 +73,48 @@ namespace Cantera {
m_t.resize(6);
}
//! Copy constructor
/*!
* @param right NasaThermo object to be copied.
*/
NasaThermo(const NasaThermo &right) :
ID(NASA),
m_tlow_max(0.0),
m_thigh_min(1.e30),
m_p0(-1.0),
m_ngroups(0)
{
*this = operator=(right);
}
//! Assignment operator
/*!
* @param right NasaThermo object to be copied.
*/
NasaThermo& operator=(const NasaThermo &right) {
/*
* Check for self assignment.
*/
if (this == &right) return *this;
m_high = right.m_high;
m_low = right.m_low;
m_index = right.m_index;
m_tmid = right.m_tmid;
m_tlow_max = right.m_tlow_max;
m_thigh_min = right.m_thigh_min;
m_tlow = right.m_tlow;
m_thigh = right.m_thigh;
m_p0 = right.m_p0;
m_ngroups = right.m_ngroups;
m_t = right.m_t;
m_group_map = right.m_group_map;
m_posInGroup_map = right.m_posInGroup_map;
m_name = right.m_name;
return *this;
}
//! destructor
virtual ~NasaThermo() {}

View file

@ -83,6 +83,44 @@ namespace Cantera {
//! destructor
virtual ~ShomateThermo() {}
//! Copy Constructor
/*!
* @param right Object to be copied
*/
ShomateThermo(const ShomateThermo &right) :
ID(SHOMATE),
m_tlow_max(0.0),
m_thigh_min(1.e30),
m_p0(-1.0),
m_ngroups(0)
{
*this = operator=(right);
}
//! Assignment Operator
/*!
* @param right Object to be copied
*/
ShomateThermo& operator=(const ShomateThermo &right) {
if (&right == this) return *this;
m_high = right.m_high;
m_low = right.m_low;
m_index = right.m_index;
m_tmid = right.m_tmid;
m_tlow_max = right.m_tlow_max;
m_thigh_min = right.m_thigh_min;
m_tlow = right.m_tlow;
m_thigh = right.m_thigh;
m_p0 = right.m_p0;
m_ngroups = right.m_ngroups;
m_t = right.m_t;
m_group_map = right.m_group_map;
m_posInGroup_map = right.m_posInGroup_map;
return *this;
}
//! Install a new species thermodynamic property
//! parameterization for one species using Shomate polynomials
//!

View file

@ -69,6 +69,43 @@ namespace Cantera {
//! Destructor
virtual ~SimpleThermo() {}
//! Copy constructor
SimpleThermo(const SimpleThermo &right) :
ID(SIMPLE),
m_tlow_max(0.0),
m_thigh_min(1.e30),
m_p0(-1.0),
m_nspData(0) {
/*
* Call the assignment operator
*/
*this = operator=(right);
}
//! Assignment operator
SimpleThermo& SimpleThermo::operator=(const SimpleThermo &right) {
/*
* Check for self assignment.
*/
if (this == &right) return *this;
m_loc = right.m_loc;
m_index = right.m_index;
m_tlow_max = right.m_tlow_max;
m_thigh_min = right.m_thigh_min;
m_tlow = right.m_tlow;
m_thigh = right.m_thigh;
m_t0 = right.m_t0;
m_logt0 = right.m_logt0;
m_h0_R = right.m_h0_R;
m_s0_R = right.m_s0_R;
m_cp0_R = right.m_cp0_R;
m_p0 = right.m_p0;
m_nspData = right.m_nspData;
return *this;
}
//! Install a new species thermodynamic property
//! parameterization for one species.
/*!

View file

@ -148,6 +148,36 @@ namespace Cantera {
//! Destructor
virtual ~SpeciesThermo() {}
//! Copy Constructor for the %SpeciesThermo object.
/*!
* @param right Reference to %SpeciesThermo object to be copied into the
* current one.
*/
SpeciesThermo(const SpeciesThermo &right) {}
//! Assignment operator for the %SpeciesThermo object
/*!
* This is NOT a virtual function.
*
* @param right Reference to %SpeciesThermo object to be copied into the
* current one.
*/
SpeciesThermo& operator=(const SpeciesThermo &right) {
return *this;
}
//! Duplication routine for objects which inherit from
//! %SpeciesThermo
/*!
* This virtual routine can be used to duplicate %SpeciesThermo objects
* inherited from %SpeciesThermo even if the application only has
* a pointer to %SpeciesThermo to work with.
* ->commented out because we first need to add copy constructors
* and assignment operators to all of the derived classes.
*/
// virtual SpeciesThermo *duplMyselfAsSpeciesThermo() const = 0;
//! Install a new species thermodynamic property
//! parameterization for one species.

View file

@ -156,6 +156,31 @@ namespace Cantera {
//! Destructor
virtual ~SpeciesThermoDuo(){}
//! copy constructor
SpeciesThermoDuo(const SpeciesThermoDuo &right) {
*this = operator=(right);
}
//! Assignment operator
/*!
* @param right Object to be copied
*/
SpeciesThermoDuo& operator=(const SpeciesThermoDuo &right) {
if (right == *this) return *this;
m_thermo1 = right.m_thermo1;
m_thermo2 = right.m_thermo2;
m_p0 = m_p0;
speciesToType = right.speciesToType;
return *this;
}
//virtual SpeciesThermo *duplMyselfAsSpeciesThermo() const {
// SpeciesThermoDuo *std = new SpeciesThermoDuo(*this);
// return (SpeciesThermo *) std;
//}
/**
* install a new species thermodynamic property
* parameterization for one species.
@ -370,6 +395,27 @@ namespace Cantera {
SpeciesThermo1() : m_pref(0.0) {}
//! destructor
virtual ~SpeciesThermo1(){}
//! Copy Constructor
SpeciesThermo1(const SpeciesThermo1 &right) :
m_pref(0.0)
{
*this = operator=(right);
}
//! Asignment Operator
/*!
* @param right Object to be copied
*/
SpeciesThermo1 & operator=(const SpeciesThermo1 &right) {
if (right == *this) return *this;
m_thermo = right.m_thermo;
m_pref = right.m_pref;
return *this;
}
//! Install one species into this Species Thermo Manager
/*!

View file

@ -87,12 +87,14 @@ namespace Cantera {
delete m_spthermo;
}
//m_spthermo = (right.m_spthermo)->duplMyselfAsSpeciesThermo();
throw CanteraError("ThermoPhase assignment", "not implemented");
throw CanteraError("ThermoPhase::operator=()", "SpeciesThermo dupl not impl");
/// Pointer to the XML tree containing the species
/// data for this phase. This is used to access data needed to
/// construct the transport manager and other properties
/// later in the initialization process.
// We don't do a deep copy here, because we don't own this
m_speciesData = right.m_speciesData;
@ -100,6 +102,7 @@ namespace Cantera {
m_phi = right.m_phi;
m_lambdaRRT = right.m_lambdaRRT;
m_hasElementPotentials = right.m_hasElementPotentials;
m_chargeNeutralityNecessary = right.m_chargeNeutralityNecessary;
return *this;
}