Deprecate copy constructors for eventually-noncopyable objects

The following classes (and their children) will be non-copyable and
non-assignable after Cantera 2.3:
  - ThermoPhase
  - Kinetics
  - Transport
  - Species
  - SpeciesThermoInterpType
  - MultiSpeciesThermo
  - VPSSMgr
  - PDSS
  - ResidJacEval
  - RootFind
This commit is contained in:
Ray Speth 2016-07-29 16:07:27 -04:00
parent 64983aaf16
commit ac7a9bd238
22 changed files with 120 additions and 14 deletions

View file

@ -119,7 +119,12 @@ public:
Kinetics();
virtual ~Kinetics();
//! @deprecated Copy constructor to be removed after Cantera 2.3 for all
//! classes derived from Kinetics.
Kinetics(const Kinetics&);
//! @deprecated Assignment operator to be removed after Cantera 2.3 for all
//! classes derived from Kinetics.
Kinetics& operator=(const Kinetics& right);
//! Duplication routine for objects which inherit from Kinetics
@ -132,6 +137,8 @@ public:
*
* @param tpVector Vector of pointers to ThermoPhase objects. this is the
* #m_thermo vector within this object
* @deprecated To be removed after Cantera 2.3 for all classes derived from
* Kinetics.
*/
virtual Kinetics* duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const;
@ -151,6 +158,8 @@ public:
*
* @param tpVector Vector of pointers to ThermoPhase objects. this is the
* #m_thermo vector within this object
* @deprecated To be removed after Cantera 2.3 for all classes derived from
* Kinetics.
*/
virtual void assignShallowPointers(const std::vector<thermo_t*> & tpVector);

View file

@ -57,7 +57,9 @@ public:
*/
ResidJacEval(doublereal atol = 1.0e-13);
//! @deprecated To be removed after Cantera 2.3.
ResidJacEval(const ResidJacEval& right);
//! @deprecated To be removed after Cantera 2.3.
ResidJacEval& operator=(const ResidJacEval& right);
//! Duplication routine for objects derived from residJacEval
@ -68,6 +70,7 @@ public:
*
* These routines are basically wrappers around the derived copy
* constructor.
* @deprecated To be removed after Cantera 2.3.
*/
virtual ResidJacEval* duplMyselfAsResidJacEval() const;

View file

@ -140,8 +140,10 @@ public:
*/
RootFind(ResidEval* resid);
//! @deprecated To be removed after Cantera 2.3.
RootFind(const RootFind& r);
~RootFind() {}
//! @deprecated To be removed after Cantera 2.3.
RootFind& operator=(const RootFind& right);
private:

View file

@ -45,7 +45,9 @@ public:
//! Constructor
MultiSpeciesThermo();
//! @deprecated To be removed after Cantera 2.3.
MultiSpeciesThermo(const MultiSpeciesThermo& b);
//! @deprecated To be removed after Cantera 2.3.
MultiSpeciesThermo& operator=(const MultiSpeciesThermo& b);
virtual ~MultiSpeciesThermo() {}

View file

@ -193,7 +193,11 @@ public:
*/
PDSS(VPStandardStateTP* tp, size_t spindex);
//! @deprecated Copy constructor to be removed after Cantera 2.3 for all
//! classes derived from PDSS.
PDSS(const PDSS& b);
//! @deprecated Assignment operator to be removed after Cantera 2.3 for all
//! classes derived from PDSS.
PDSS& operator=(const PDSS& b);
virtual ~PDSS() {}
@ -203,6 +207,8 @@ public:
* if the application only has a pointer to PDSS to work with.
*
* @return A pointer to the base PDSS object type
* @deprecated To be removed after Cantera 2.3 for all classes derived from
* PDSS.
*/
virtual PDSS* duplMyselfAsPDSS() const;
@ -520,6 +526,8 @@ public:
* @param spthermo_ptr Pointer to the optional MultiSpeciesThermo object
* that will handle the calculation of the reference
* state thermodynamic coefficients.
* @deprecated To be removed after Cantera 2.3 for all classes derived from
* PDSS.
*/
virtual void initAllPtrs(VPStandardStateTP* vptp_ptr, VPSSMgr* vpssmgr_ptr,
MultiSpeciesThermo* spthermo_ptr);

View file

@ -26,7 +26,9 @@ public:
Species(const std::string& name, const compositionMap& comp,
double charge=0.0, double size=1.0);
//! @deprecated To be removed after Cantera 2.3.
Species(const Species& other);
//! @deprecated To be removed after Cantera 2.3.
Species& operator=(const Species& other);
~Species();

View file

@ -123,10 +123,17 @@ public:
SpeciesThermoInterpType(double tlow, double thigh, double pref);
//! @deprecated Copy constructor to be removed after Cantera 2.3 for all
//! classes derived from SpeciesThermoInterpType.
SpeciesThermoInterpType(const SpeciesThermoInterpType& b);
//! @deprecated Assignment operator to be removed after Cantera 2.3 for all
//! classes derived from SpeciesThermoInterpType.
SpeciesThermoInterpType& operator=(const SpeciesThermoInterpType& b);
virtual ~SpeciesThermoInterpType() {}
//! @deprecated To be removed after Cantera 2.3 for all classes derived
//! from SpeciesThermoInterpType.
virtual SpeciesThermoInterpType*
duplMyselfAsSpeciesThermoInterpType() const = 0;

View file

@ -97,7 +97,12 @@ public:
ThermoPhase();
virtual ~ThermoPhase();
//! @deprecated Copy constructor to be removed after Cantera 2.3 for all
//! classes derived from ThermoPhase.
ThermoPhase(const ThermoPhase& right);
//! @deprecated Assignment operator to be removed after Cantera 2.3 for all
//! classes derived from ThermoPhase.
ThermoPhase& operator=(const ThermoPhase& right);
//! Duplication routine for objects which inherit from ThermoPhase.
@ -108,6 +113,8 @@ public:
*
* These routines are basically wrappers around the derived copy
* constructor.
* @deprecated To be removed after Cantera 2.3 for all classes derived from
* ThermoPhase.
*/
virtual ThermoPhase* duplMyselfAsThermoPhase() const;

View file

@ -240,13 +240,20 @@ public:
VPSSMgr(VPStandardStateTP* vptp_ptr, MultiSpeciesThermo* spth = 0);
virtual ~VPSSMgr() {}
//! @deprecated Copy constructor to be removed after Cantera 2.3 for all
//! classes derived from VPSSMgr.
VPSSMgr(const VPSSMgr& right);
//! @deprecated Assignment operator to be removed after Cantera 2.3 for all
//! classes derived from VPSSMgr.
VPSSMgr& operator=(const VPSSMgr& right);
//! Duplication routine for objects which derive from VPSSMgr
/*!
* This function can be used to duplicate objects derived from VPSSMgr
* even if the application only has a pointer to VPSSMgr to work with.
* @deprecated To be removed after Cantera 2.3 for all classes derived from
* VPSSMgr.
*/
virtual VPSSMgr* duplMyselfAsVPSSMgr() const;
@ -687,6 +694,8 @@ public:
*
* @param vp_ptr Pointer to the VPStandardStateTP standard state
* @param sp_ptr Pointer to the MultiSpeciesThermo standard state
* @deprecated To be removed after Cantera 2.3 for all classes derived from
* VPSSMgr.
*/
virtual void initAllPtrs(VPStandardStateTP* vp_ptr, MultiSpeciesThermo* sp_ptr);

View file

@ -162,7 +162,11 @@ public:
Transport(thermo_t* thermo=0, size_t ndim = 1);
virtual ~Transport() {}
//! @deprecated Copy constructor to be removed after Cantera 2.3 for all
//! classes derived from Transport.
Transport(const Transport& right);
//! @deprecated Assignment operator to be removed after Cantera 2.3 for all
//! classes derived from Transport.
Transport& operator=(const Transport& right);
//! Duplication routine for objects which inherit from Transport
@ -173,6 +177,8 @@ public:
*
* These routines are basically wrappers around the derived copy
* constructor.
* @deprecated To be removed after Cantera 2.3 for all classes derived from
* Transport.
*/
// Note ->need working copy constructors and operator=() functions for all first
virtual Transport* duplMyselfAsTransport() const;

View file

@ -30,12 +30,16 @@ Kinetics::~Kinetics() {}
Kinetics::Kinetics(const Kinetics& right)
{
warn_deprecated("Kinetics copy constructor", "To be removed after"
" Cantera 2.3 for all classes derived from Kinetics.");
// Call the assignment operator
*this = right;
}
Kinetics& Kinetics::operator=(const Kinetics& right)
{
warn_deprecated("Kinetics assignment operator", "To be removed after"
" Cantera 2.3 for all classes derived from Kinetics.");
// Check for self assignment.
if (this == &right) {
return *this;
@ -67,6 +71,8 @@ Kinetics& Kinetics::operator=(const Kinetics& right)
Kinetics* Kinetics::duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const
{
warn_deprecated("Kinetics::duplMyselfAsKinetics",
"To be removed after Cantera 2.3.");
Kinetics* ko = new Kinetics(*this);
ko->assignShallowPointers(tpVector);
return ko;

View file

@ -21,11 +21,15 @@ ResidJacEval::ResidJacEval(doublereal atol) :
ResidJacEval::ResidJacEval(const ResidJacEval& right)
{
warn_deprecated("ResidJacEval copy constructor",
"To be removed after Cantera 2.3.");
*this = right;
}
ResidJacEval& ResidJacEval::operator=(const ResidJacEval& right)
{
warn_deprecated("ResidJacEval assignment operator",
"To be removed after Cantera 2.3.");
if (this == &right) {
return *this;
}

View file

@ -80,11 +80,15 @@ RootFind::RootFind(const RootFind& r) :
x_minTried_(1.0E300),
fx_minTried_(0.0)
{
warn_deprecated("RootFind copy constructor",
"To be removed after Cantera 2.3.");
*this = r;
}
RootFind& RootFind::operator=(const RootFind& right)
{
warn_deprecated("RootFind assignment operator",
"To be removed after Cantera 2.3.");
if (this == &right) {
return *this;
}

View file

@ -28,6 +28,8 @@ MultiSpeciesThermo::MultiSpeciesThermo(const MultiSpeciesThermo& b) :
m_thigh_min(b.m_thigh_min),
m_p0(b.m_p0)
{
warn_deprecated("MultiSpeciesThermo copy constructor",
"To be removed after Cantera 2.3");
m_sp.clear();
// Copy SpeciesThermoInterpTypes from 'b'
for (const auto& sp : b.m_sp) {
@ -43,6 +45,8 @@ MultiSpeciesThermo::MultiSpeciesThermo(const MultiSpeciesThermo& b) :
MultiSpeciesThermo&
MultiSpeciesThermo::operator=(const MultiSpeciesThermo& b)
{
warn_deprecated("MultiSpeciesThermo assignment operator",
"To be removed after Cantera 2.3");
if (&b == this) {
return *this;
}

View file

@ -94,6 +94,8 @@ PDSS::PDSS(const PDSS& b) :
m_gss_RT_ptr(b.m_gss_RT_ptr),
m_Vss_ptr(b.m_Vss_ptr)
{
warn_deprecated("PDSS copy constructor", "To be removed after"
" Cantera 2.3 for all classes derived from PDSS.");
// Use the assignment operator to do the brunt of the work for the copy
// constructor.
*this = b;
@ -101,6 +103,8 @@ PDSS::PDSS(const PDSS& b) :
PDSS& PDSS::operator=(const PDSS& b)
{
warn_deprecated("PDSS assignment operator", "To be removed after"
" Cantera 2.3 for all classes derived from PDSS.");
if (&b == this) {
return *this;
}
@ -150,6 +154,8 @@ PDSS& PDSS::operator=(const PDSS& b)
PDSS* PDSS::duplMyselfAsPDSS() const
{
warn_deprecated("PDSS::duplMyselfAsPDSS",
"To be removed after Cantera 2.3.");
return new PDSS(*this);
}
@ -179,6 +185,8 @@ void PDSS::initThermo()
void PDSS::initAllPtrs(VPStandardStateTP* tp, VPSSMgr* vpssmgr_ptr,
MultiSpeciesThermo* spthermo)
{
warn_deprecated("PDSS::initAllPtrs", "To be removed after Cantera 2.3 "
"for all classes derived from PDSS.");
m_tp = tp;
m_vpssmgr_ptr = vpssmgr_ptr;
m_spthermo = spthermo;

View file

@ -36,6 +36,8 @@ Species::Species(const Species& other)
, size(other.size)
, transport(other.transport)
{
warn_deprecated("Species copy constructor",
"To be removed after Cantera 2.3.");
if (other.thermo) {
thermo.reset(other.thermo->duplMyselfAsSpeciesThermoInterpType());
}
@ -43,6 +45,8 @@ Species::Species(const Species& other)
Species& Species::operator=(const Species& other)
{
warn_deprecated("Species assignment operator",
"To be removed after Cantera 2.3.");
if (this == &other) {
return *this;
}

View file

@ -31,6 +31,20 @@ SpeciesThermoInterpType::SpeciesThermoInterpType(const SpeciesThermoInterpType &
m_highT(b.m_highT),
m_Pref(b.m_Pref)
{
warn_deprecated("SpeciesThermoInterpType copy constructor",
"To be removed after Cantera 2.3.");
}
SpeciesThermoInterpType& SpeciesThermoInterpType::operator=(const SpeciesThermoInterpType& b)
{
warn_deprecated("SpeciesThermoInterpType assignment operator",
"To be removed after Cantera 2.3.");
if (&b != this) {
m_lowT = b.m_lowT;
m_highT = b.m_highT;
m_Pref = b.m_Pref;
}
return *this;
}
void SpeciesThermoInterpType::updateProperties(const doublereal* tempPoly,

View file

@ -49,12 +49,16 @@ ThermoPhase::ThermoPhase(const ThermoPhase& right) :
m_chargeNeutralityNecessary(false),
m_ssConvention(cSS_CONVENTION_TEMPERATURE)
{
warn_deprecated("ThermoPhase copy constructor", "To be removed after"
" Cantera 2.3 for all classes derived from ThermoPhase.");
// Call the assignment operator
*this = right;
}
ThermoPhase& ThermoPhase::operator=(const ThermoPhase& right)
{
warn_deprecated("ThermoPhase assignment operator", "To be removed after"
" Cantera 2.3 for all classes derived from ThermoPhase.");
// Check for self assignment.
if (this == &right) {
return *this;
@ -90,6 +94,8 @@ ThermoPhase& ThermoPhase::operator=(const ThermoPhase& right)
ThermoPhase* ThermoPhase::duplMyselfAsThermoPhase() const
{
warn_deprecated("ThermoPhase::duplMyselfAsThermoPhase",
"To be removed after Cantera 2.3.");
return new ThermoPhase(*this);
}

View file

@ -54,11 +54,15 @@ VPSSMgr::VPSSMgr(const VPSSMgr& right) :
m_useTmpRefStateStorage(false),
m_useTmpStandardStateStorage(false)
{
warn_deprecated("VPSSMgr copy constructor", "To be removed after"
" Cantera 2.3 for all classes derived from VPSSMgr.");
*this = right;
}
VPSSMgr& VPSSMgr::operator=(const VPSSMgr& right)
{
warn_deprecated("VPSSMgr assignment operator", "To be removed after"
" Cantera 2.3 for all classes derived from VPSSMgr.");
if (&right == this) {
return *this;
}
@ -111,12 +115,16 @@ VPSSMgr& VPSSMgr::operator=(const VPSSMgr& right)
VPSSMgr* VPSSMgr::duplMyselfAsVPSSMgr() const
{
warn_deprecated("VPSSMgr::duplMyselfAsVPSSMgr", "To be removed after"
" Cantera 2.3 for all classes derived from VPSSMgr.");
return new VPSSMgr(*this);
}
void VPSSMgr::initAllPtrs(VPStandardStateTP* vp_ptr,
MultiSpeciesThermo* sp_ptr)
{
warn_deprecated("VPSSMgr::initAllPtrs", "To be removed after Cantera 2.3 "
"for all classes derived from VPSSMgr.");
m_vptp_ptr = vp_ptr;
m_spthermo = sp_ptr;

View file

@ -19,6 +19,8 @@ Transport::Transport(thermo_t* thermo, size_t ndim) :
Transport::Transport(const Transport& right)
{
warn_deprecated("Transport copy constructor", "To be removed after"
" Cantera 2.3 for all classes derived from Transport.");
m_thermo = right.m_thermo;
m_ready = right.m_ready;
m_nsp = right.m_nsp;
@ -28,6 +30,8 @@ Transport::Transport(const Transport& right)
Transport& Transport::operator=(const Transport& right)
{
warn_deprecated("Transport assignment operator", "To be removed after"
" Cantera 2.3 for all classes derived from Transport.");
if (&right != this) {
return *this;
}
@ -41,6 +45,8 @@ Transport& Transport::operator=(const Transport& right)
Transport* Transport::duplMyselfAsTransport() const
{
warn_deprecated("Transport::duplMyselfAsTransport",
"To be removed after Cantera 2.3.");
return new Transport(*this);
}

View file

@ -58,20 +58,6 @@ TEST_F(NasaPoly1Test, Initialization)
EXPECT_EQ(poly.refPressure(), 101325.0);
}
TEST_F(NasaPoly1Test, Copy)
{
NasaPoly1 q(poly);
testEquivalent(poly, q);
}
TEST_F(NasaPoly1Test, Assignment)
{
double c[] = {1, 2, 3, 4 ,5 ,6, 7};
NasaPoly1 q(0, 0, 0, c);
q = poly;
testEquivalent(poly, q);
}
TEST_F(NasaPoly1Test, updateProperties)
{
double cp_R, h_RT, s_R;

View file

@ -14,6 +14,7 @@ using namespace Cantera;
int main(int argc, char** argv)
{
suppress_deprecation_warnings();
int retn = 0;
size_t i;