From: Christian Bauer Date: Thu, 15 Feb 2001 22:54:52 +0000 (+0000) Subject: the destructor, copy constructor, and assignment operator (which were the X-Git-Tag: release_0-7-2~5 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=e5362a33f72613b324b3714524a8c2e5f7b7f46f the destructor, copy constructor, and assignment operator (which were the same for all subclasses of basic, with very few exceptions) are now included in the GINAC_IMPLEMENT_REGISTERED_CLASS macro; the GINAC_DECLARE_REGISTERED_CLASS macro also defines these (and other common) member functions --- diff --git a/ginac/add.cpp b/ginac/add.cpp index 74a37328..574a8e8e 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -47,28 +47,6 @@ add::add() tinfo_key = TINFO_add; } -add::~add() -{ - debugmsg("add destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -add::add(const add & other) -{ - debugmsg("add copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const add & add::operator=(const add & other) -{ - debugmsg("add operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void add::copy(const add & other) diff --git a/ginac/add.h b/ginac/add.h index c30034df..924eb407 100644 --- a/ginac/add.h +++ b/ginac/add.h @@ -38,18 +38,6 @@ class add : public expairseq friend class ncmul; friend class power; -// member functions - - // default constructor, destructor, copy constructor assignment operator and helpers -public: - add(); - ~add(); - add(const add & other); - const add & operator=(const add & other); -protected: - void copy(const add & other); - void destroy(bool call_parent); - // other constructors public: add(const ex & lh, const ex & rh); diff --git a/ginac/basic.cpp b/ginac/basic.cpp index daefabb8..9f0bbf53 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -39,7 +39,7 @@ namespace GiNaC { #endif // ndef NO_NAMESPACE_GINAC -GINAC_IMPLEMENT_REGISTERED_CLASS(basic, void) +GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(basic, void) ////////// // default constructor, destructor, copy constructor assignment operator and helpers diff --git a/ginac/basic.h b/ginac/basic.h index 05ee4f23..e7238e57 100644 --- a/ginac/basic.h +++ b/ginac/basic.h @@ -61,7 +61,7 @@ typedef std::vector exvector; * It is responsible for the reference counting. */ class basic { - GINAC_DECLARE_REGISTERED_CLASS(basic, void) + GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(basic, void) friend class ex; diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 37e1d8df..c3c0d9f3 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -48,28 +48,6 @@ clifford::clifford() tinfo_key = TINFO_clifford; } -clifford::~clifford() -{ - debugmsg("clifford destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -clifford::clifford(const clifford & other) -{ - debugmsg("clifford copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const clifford & clifford::operator=(const clifford & other) -{ - debugmsg("clifford operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void clifford::copy(const clifford & other) diff --git a/ginac/clifford.h b/ginac/clifford.h index e7b05f53..2d02ebcb 100644 --- a/ginac/clifford.h +++ b/ginac/clifford.h @@ -42,18 +42,6 @@ class clifford : public lortensor friend clifford clifford_gamma(const ex & mu); -// member functions - - // default constructor, destructor, copy constructor assignment operator and helpers -public: - clifford(); - ~clifford(); - clifford(const clifford & other); - const clifford & operator=(const clifford & other); -protected: - void copy(const clifford & other); - void destroy(bool call_parent); - // other constructors public: clifford(const std::string & n, const ex & mu); diff --git a/ginac/color.cpp b/ginac/color.cpp index 9f3b3000..4b59877a 100644 --- a/ginac/color.cpp +++ b/ginac/color.cpp @@ -54,28 +54,6 @@ color::color() : inherited(TINFO_color), type(invalid), representation_label(0) debugmsg("color default constructor",LOGLEVEL_CONSTRUCT); } -color::~color() -{ - debugmsg("color destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -color::color(const color & other) -{ - debugmsg("color copy constructor",LOGLEVEL_CONSTRUCT); - copy (other); -} - -const color & color::operator=(const color & other) -{ - debugmsg("color operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void color::copy(const color & other) diff --git a/ginac/color.h b/ginac/color.h index 2b607e3c..2d44aa8f 100644 --- a/ginac/color.h +++ b/ginac/color.h @@ -94,16 +94,6 @@ public: // member functions - // default constructor, destructor, copy constructor assignment operator and helpers -public: - color(); - ~color(); - color(const color & other); - const color & operator=(const color & other); -protected: - void copy(const color & other); - void destroy(bool call_parent); - // other constructors protected: color(color_types const t, unsigned rl=0); diff --git a/ginac/coloridx.cpp b/ginac/coloridx.cpp index b9568a85..221e86b6 100644 --- a/ginac/coloridx.cpp +++ b/ginac/coloridx.cpp @@ -47,28 +47,6 @@ coloridx::coloridx() tinfo_key=TINFO_coloridx; } -coloridx::~coloridx() -{ - debugmsg("coloridx destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -coloridx::coloridx(const coloridx & other) -{ - debugmsg("coloridx copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const coloridx & coloridx::operator=(const coloridx & other) -{ - debugmsg("coloridx operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void coloridx::copy(const coloridx & other) diff --git a/ginac/coloridx.h b/ginac/coloridx.h index 4b40a3a7..780aac42 100644 --- a/ginac/coloridx.h +++ b/ginac/coloridx.h @@ -45,18 +45,6 @@ class coloridx : public idx friend class color; -// member functions - - // default constructor, destructor, copy constructor assignment operator and helpers -public: - coloridx(); - ~coloridx(); - coloridx (const coloridx & other); - const coloridx & operator=(const coloridx & other); -protected: - void copy(const coloridx & other); - void destroy(bool call_parent); - // other constructors public: explicit coloridx(bool cov); diff --git a/ginac/constant.cpp b/ginac/constant.cpp index 3e6c667d..ae71579c 100644 --- a/ginac/constant.cpp +++ b/ginac/constant.cpp @@ -46,18 +46,6 @@ constant::constant() : basic(TINFO_constant), name(""), ef(0), number(0), serial debugmsg("constant default constructor",LOGLEVEL_CONSTRUCT); } -constant::~constant() -{ - debugmsg("constant destructor",LOGLEVEL_DESTRUCT); - destroy(0); -} - -constant::constant(const constant & other) -{ - debugmsg("constant copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - // protected void constant::copy(const constant & other) diff --git a/ginac/constant.h b/ginac/constant.h index 70b2816e..0c9394f8 100644 --- a/ginac/constant.h +++ b/ginac/constant.h @@ -42,16 +42,6 @@ class constant : public basic // member functions - // default constructor, destructor, copy constructor assignment operator and helpers -public: - constant(); - ~constant(); - constant(const constant & other); - // const constant & operator=(const constant & other); /* it's pervert! */ -protected: - void copy(const constant & other); - void destroy(bool call_parent); - // other constructors public: constant(const std::string & initname, evalffunctype efun=0); diff --git a/ginac/container.pl b/ginac/container.pl index bbeb3b4a..232d299c 100755 --- a/ginac/container.pl +++ b/ginac/container.pl @@ -200,15 +200,6 @@ class ${CONTAINER} : public basic { GINAC_DECLARE_REGISTERED_CLASS(${CONTAINER}, basic) -public: - ${CONTAINER}(); - ~${CONTAINER}(); - ${CONTAINER}(${CONTAINER} const & other); - ${CONTAINER} const & operator=(${CONTAINER} const & other); -protected: - void copy(${CONTAINER} const & other); - void destroy(bool call_parent); - public: ${CONTAINER}(${STLT} const & s, bool discardable=0); ${CONTAINER}(${STLT} * vp); // vp will be deleted @@ -343,28 +334,6 @@ ${CONTAINER}::${CONTAINER}() : basic(TINFO_${CONTAINER}) debugmsg("${CONTAINER} default constructor",LOGLEVEL_CONSTRUCT); } -${CONTAINER}::~${CONTAINER}() -{ - debugmsg("${CONTAINER} destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -${CONTAINER}::${CONTAINER}(${CONTAINER} const & other) -{ - debugmsg("${CONTAINER} copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -${CONTAINER} const & ${CONTAINER}::operator=(${CONTAINER} const & other) -{ - debugmsg("${CONTAINER} operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void ${CONTAINER}::copy(${CONTAINER} const & other) diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp index 3daa4da5..56fcba68 100644 --- a/ginac/expairseq.cpp +++ b/ginac/expairseq.cpp @@ -38,7 +38,7 @@ namespace GiNaC { #error "FIXME: expair_needs_further_processing not yet implemented for hashtabs, sorry. A.F." #endif // def EXPAIRSEQ_USE_HASHTAB -GINAC_IMPLEMENT_REGISTERED_CLASS(expairseq, basic) +GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(expairseq, basic) ////////// // helper classes diff --git a/ginac/expairseq.h b/ginac/expairseq.h index d9cc0b31..bba0902d 100644 --- a/ginac/expairseq.h +++ b/ginac/expairseq.h @@ -57,7 +57,7 @@ typedef std::vector epplistvector; * the same way.) */ class expairseq : public basic { - GINAC_DECLARE_REGISTERED_CLASS(expairseq, basic) + GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(expairseq, basic) // member functions diff --git a/ginac/fail.cpp b/ginac/fail.cpp index 8a281e8a..c1118040 100644 --- a/ginac/fail.cpp +++ b/ginac/fail.cpp @@ -42,28 +42,6 @@ fail::fail() : inherited(TINFO_fail) debugmsg("fail default constructor",LOGLEVEL_CONSTRUCT); } -fail::~fail() -{ - debugmsg("fail destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -fail::fail(const fail & other) -{ - debugmsg("fail copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const fail & fail::operator=(const fail & other) -{ - debugmsg("fail operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void fail::copy(const fail & other) diff --git a/ginac/fail.h b/ginac/fail.h index d6bf22d0..248c593c 100644 --- a/ginac/fail.h +++ b/ginac/fail.h @@ -34,16 +34,6 @@ class fail : public basic { GINAC_DECLARE_REGISTERED_CLASS(fail, basic) - // default constructor, destructor, copy constructor assignment operator and helpers -public: - fail(); - ~fail(); - fail(const fail & other); - const fail & operator=(const fail & other); -protected: - void copy(const fail & other); - void destroy(bool call_parent); - // other constructors // none @@ -62,8 +52,8 @@ protected: // non-virtual functions in this class // none -// member variables -// none + // member variables + // none }; #ifndef NO_NAMESPACE_GINAC diff --git a/ginac/function.pl b/ginac/function.pl index d97e58f6..8a96a329 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -386,16 +386,6 @@ class function : public exprseq // member functions - // default constructor, destructor, copy constructor assignment operator and helpers -public: - function(); - ~function(); - function(const function & other); - const function & operator=(const function & other); -protected: - void copy(const function & other); - void destroy(bool call_parent); - // other constructors public: function(unsigned ser); @@ -630,28 +620,6 @@ function::function() : serial(0) tinfo_key = TINFO_function; } -function::~function() -{ - debugmsg("function destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -function::function(const function & other) -{ - debugmsg("function copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const function & function::operator=(const function & other) -{ - debugmsg("function operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void function::copy(const function & other) diff --git a/ginac/idx.cpp b/ginac/idx.cpp index 34d5c854..af463a80 100644 --- a/ginac/idx.cpp +++ b/ginac/idx.cpp @@ -49,28 +49,6 @@ idx::idx() : inherited(TINFO_idx), symbolic(true), covariant(false) name=autoname_prefix()+ToString(serial); } -idx::~idx() -{ - debugmsg("idx destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -idx::idx(const idx & other) -{ - debugmsg("idx copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const idx & idx::operator=(const idx & other) -{ - debugmsg("idx operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void idx::copy(const idx & other) diff --git a/ginac/idx.h b/ginac/idx.h index 8b991ac1..981fee68 100644 --- a/ginac/idx.h +++ b/ginac/idx.h @@ -40,16 +40,6 @@ class idx : public basic { GINAC_DECLARE_REGISTERED_CLASS(idx, basic) - // default constructor, destructor, copy constructor assignment operator and helpers -public: - idx(); - ~idx(); - idx (const idx & other); - const idx & operator=(const idx & other); -protected: - void copy(const idx & other); - void destroy(bool call_parent); - // other constructors public: explicit idx(bool cov); diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index 8e05dbf2..7127e9a4 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -45,28 +45,6 @@ indexed::indexed() tinfo_key=TINFO_indexed; } -indexed::~indexed() -{ - debugmsg("indexed destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -indexed::indexed(const indexed & other) -{ - debugmsg("indexed copy constructor",LOGLEVEL_CONSTRUCT); - copy (other); -} - -const indexed & indexed::operator=(const indexed & other) -{ - debugmsg("indexed operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void indexed::copy(const indexed & other) diff --git a/ginac/indexed.h b/ginac/indexed.h index c43d4ade..b1d8844a 100644 --- a/ginac/indexed.h +++ b/ginac/indexed.h @@ -36,18 +36,6 @@ class indexed : public exprseq { GINAC_DECLARE_REGISTERED_CLASS(indexed, exprseq) -// member functions - - // default constructor, destructor, copy constructor assignment operator and helpers -public: - indexed(); - ~indexed(); - indexed(const indexed & other); - const indexed & operator=(const indexed & other); -protected: - void copy(const indexed & other); - void destroy(bool call_parent); - // other constructors public: indexed(const ex & i1); diff --git a/ginac/isospin.cpp b/ginac/isospin.cpp index 911c86f4..a74e05f7 100644 --- a/ginac/isospin.cpp +++ b/ginac/isospin.cpp @@ -51,28 +51,6 @@ isospin::isospin() tinfo_key=TINFO_isospin; } -isospin::~isospin() -{ - debugmsg("isospin destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -isospin::isospin(const isospin & other) -{ - debugmsg("isospin copy constructor",LOGLEVEL_CONSTRUCT); - copy (other); -} - -const isospin & isospin::operator=(const isospin & other) -{ - debugmsg("isospin operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void isospin::copy(const isospin & other) diff --git a/ginac/isospin.h b/ginac/isospin.h index 313c1309..3facb90b 100644 --- a/ginac/isospin.h +++ b/ginac/isospin.h @@ -35,18 +35,6 @@ class isospin : public indexed { GINAC_DECLARE_REGISTERED_CLASS(isospin, indexed) -// member functions - - // default constructor, destructor, copy constructor assignment operator and helpers -public: - isospin(); - ~isospin(); - isospin(const isospin & other); - const isospin & operator=(const isospin & other); -protected: - void copy(const isospin & other); - void destroy(bool call_parent); - // other constructors public: explicit isospin(const std::string & initname); diff --git a/ginac/lorentzidx.cpp b/ginac/lorentzidx.cpp index 67e5576b..6a367be6 100644 --- a/ginac/lorentzidx.cpp +++ b/ginac/lorentzidx.cpp @@ -49,28 +49,6 @@ lorentzidx::lorentzidx() : orthogonal_only(false), dim_parallel_space(0) tinfo_key = TINFO_lorentzidx; } -lorentzidx::~lorentzidx() -{ - debugmsg("lorentzidx destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -lorentzidx::lorentzidx(const lorentzidx & other) -{ - debugmsg("lorentzidx copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const lorentzidx & lorentzidx::operator=(const lorentzidx & other) -{ - debugmsg("lorentzidx operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void lorentzidx::copy(const lorentzidx & other) diff --git a/ginac/lorentzidx.h b/ginac/lorentzidx.h index 3d5355b7..099f36b5 100644 --- a/ginac/lorentzidx.h +++ b/ginac/lorentzidx.h @@ -48,16 +48,6 @@ class lorentzidx : public idx // member functions - // default constructor, destructor, copy constructor assignment operator and helpers -public: - lorentzidx(); - ~lorentzidx(); - lorentzidx (const lorentzidx & other); - const lorentzidx & operator=(const lorentzidx & other); -protected: - void copy(const lorentzidx & other); - void destroy(bool call_parent); - // other constructors public: explicit lorentzidx(bool cov, bool oonly=false, unsigned dimp=0); diff --git a/ginac/lortensor.cpp b/ginac/lortensor.cpp index 0238adcb..7a97887a 100644 --- a/ginac/lortensor.cpp +++ b/ginac/lortensor.cpp @@ -60,28 +60,6 @@ lortensor::lortensor() : inherited(TINFO_lortensor), type(invalid) name=autoname_prefix()+ToString(serial); } -lortensor::~lortensor() -{ - debugmsg("lortensor destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -lortensor::lortensor(const lortensor & other) -{ - debugmsg("lortensor copy constructor",LOGLEVEL_CONSTRUCT); - copy (other); -} - -const lortensor & lortensor::operator=(const lortensor & other) -{ - debugmsg("lortensor operator=",LOGLEVEL_ASSIGNMENT); - if (this != & other) { - destroy(true); - copy(other); - } - return *this; -} - //protected void lortensor::copy(const lortensor & other) @@ -350,7 +328,7 @@ ex lortensor::eval(int level) const return _ex0(); } } else if (idx1.is_symbolic() && idx1.is_co_contra_pair(idx2)) { - return Dim() - 2; + return Dim(); } } return this -> hold(); diff --git a/ginac/lortensor.h b/ginac/lortensor.h index 977be984..d25211fe 100644 --- a/ginac/lortensor.h +++ b/ginac/lortensor.h @@ -67,16 +67,6 @@ public: // member functions - // default constructor, destructor, copy constructor assignment operator and helpers -public: - lortensor(); - ~lortensor(); - lortensor(const lortensor & other); - const lortensor & operator=(const lortensor & other); -protected: - void copy(const lortensor & other); - void destroy(bool call_parent); - // other constructors protected: lortensor(lortensor_types const lt, const std::string & n); diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index ec7ee2c8..0b87ed5d 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -54,28 +54,6 @@ matrix::matrix() : inherited(TINFO_matrix), row(1), col(1) m.push_back(_ex0()); } -matrix::~matrix() -{ - debugmsg("matrix destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -matrix::matrix(const matrix & other) -{ - debugmsg("matrix copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const matrix & matrix::operator=(const matrix & other) -{ - debugmsg("matrix operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void matrix::copy(const matrix & other) diff --git a/ginac/matrix.h b/ginac/matrix.h index 279ddfc1..7c2b9c01 100644 --- a/ginac/matrix.h +++ b/ginac/matrix.h @@ -36,21 +36,6 @@ class matrix : public basic { GINAC_DECLARE_REGISTERED_CLASS(matrix, basic) -// friends -// (none) -// member functions - - // default constructor, destructor, copy constructor, assignment operator - // and helpers: -public: - matrix(); - ~matrix(); - matrix(const matrix & other); - const matrix & operator=(const matrix & other); -protected: - void copy(const matrix & other); - void destroy(bool call_parent); - // other constructors public: matrix(unsigned r, unsigned c); diff --git a/ginac/mul.cpp b/ginac/mul.cpp index 23927729..80901d77 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -48,28 +48,6 @@ mul::mul() tinfo_key = TINFO_mul; } -mul::~mul() -{ - debugmsg("mul destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -mul::mul(const mul & other) -{ - debugmsg("mul copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const mul & mul::operator=(const mul & other) -{ - debugmsg("mul operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void mul::copy(const mul & other) diff --git a/ginac/mul.h b/ginac/mul.h index 78954963..c6d607db 100644 --- a/ginac/mul.h +++ b/ginac/mul.h @@ -38,18 +38,6 @@ class mul : public expairseq friend class ncmul; friend class power; -// member functions - - // default constructor, destructor, copy constructor assignment operator and helpers -public: - mul(); - ~mul(); - mul(const mul & other); - const mul & operator=(const mul & other); -protected: - void copy(const mul & other); - void destroy(bool call_parent); - // other constructors public: mul(const ex & lh, const ex & rh); diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp index 8964d6b7..86b76e71 100644 --- a/ginac/ncmul.cpp +++ b/ginac/ncmul.cpp @@ -50,28 +50,6 @@ ncmul::ncmul() tinfo_key = TINFO_ncmul; } -ncmul::~ncmul() -{ - debugmsg("ncmul destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -ncmul::ncmul(const ncmul & other) -{ - debugmsg("ncmul copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const ncmul & ncmul::operator=(const ncmul & other) -{ - debugmsg("ncmul operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void ncmul::copy(const ncmul & other) diff --git a/ginac/ncmul.h b/ginac/ncmul.h index a604eead..a4a77eb0 100644 --- a/ginac/ncmul.h +++ b/ginac/ncmul.h @@ -40,16 +40,6 @@ class ncmul : public exprseq // member functions - // default constructor, destructor, copy constructor assignment operator and helpers -public: - ncmul(); - ~ncmul(); - ncmul(const ncmul & other); - const ncmul & operator=(const ncmul & other); -protected: - void copy(const ncmul & other); - void destroy(bool call_parent); - // other constructors public: ncmul(const ex & lh, const ex & rh); diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index 32bb7fb2..3398f60d 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -87,28 +87,6 @@ numeric::numeric() : basic(TINFO_numeric) status_flags::hash_calculated); } -numeric::~numeric() -{ - debugmsg("numeric destructor" ,LOGLEVEL_DESTRUCT); - destroy(false); -} - -numeric::numeric(const numeric & other) -{ - debugmsg("numeric copy constructor", LOGLEVEL_CONSTRUCT); - copy(other); -} - -const numeric & numeric::operator=(const numeric & other) -{ - debugmsg("numeric operator=", LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void numeric::copy(const numeric & other) diff --git a/ginac/numeric.h b/ginac/numeric.h index 247951aa..1eda94d4 100644 --- a/ginac/numeric.h +++ b/ginac/numeric.h @@ -73,22 +73,8 @@ class numeric : public basic { GINAC_DECLARE_REGISTERED_CLASS(numeric, basic) -// friends -// (none) - // member functions - // default constructor, destructor, copy constructor assignment - // operator and helpers -public: - numeric(); - ~numeric(); - numeric(const numeric & other); - const numeric & operator=(const numeric & other); -protected: - void copy(const numeric & other); - void destroy(bool call_parent); - // other constructors public: explicit numeric(int i); diff --git a/ginac/power.cpp b/ginac/power.cpp index 9d224d1b..30697335 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -55,28 +55,6 @@ power::power() : basic(TINFO_power) debugmsg("power default constructor",LOGLEVEL_CONSTRUCT); } -power::~power() -{ - debugmsg("power destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -power::power(const power & other) -{ - debugmsg("power copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const power & power::operator=(const power & other) -{ - debugmsg("power operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void power::copy(const power & other) diff --git a/ginac/power.h b/ginac/power.h index 6bdafa00..65c86b7e 100644 --- a/ginac/power.h +++ b/ginac/power.h @@ -43,16 +43,6 @@ class power : public basic // member functions - // default constructor, destructor, copy constructor assignment operator and helpers -public: - power(); - ~power(); - power(const power & other); - const power & operator=(const power & other); -protected: - void copy(const power & other); - void destroy(bool call_parent); - // other constructors public: power(const ex & lh, const ex & rh); diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index 9adc8fc4..d447aaa6 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -50,28 +50,6 @@ pseries::pseries() : basic(TINFO_pseries) debugmsg("pseries default constructor", LOGLEVEL_CONSTRUCT); } -pseries::~pseries() -{ - debugmsg("pseries destructor", LOGLEVEL_DESTRUCT); - destroy(false); -} - -pseries::pseries(const pseries &other) -{ - debugmsg("pseries copy constructor", LOGLEVEL_CONSTRUCT); - copy(other); -} - -const pseries &pseries::operator=(const pseries & other) -{ - debugmsg("pseries operator=", LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - void pseries::copy(const pseries &other) { inherited::copy(other); diff --git a/ginac/pseries.h b/ginac/pseries.h index 0b0d92f1..14b011af 100644 --- a/ginac/pseries.h +++ b/ginac/pseries.h @@ -38,16 +38,6 @@ class pseries : public basic { GINAC_DECLARE_REGISTERED_CLASS(pseries, basic) - // default constructor, destructor, copy constructor, assignment operator and helpers -public: - pseries(); - ~pseries(); - pseries(const pseries &other); - const pseries &operator=(const pseries &other); -protected: - void copy(const pseries &other); - void destroy(bool call_parent); - // other constructors public: pseries(const ex &rel_, const epvector &ops_); diff --git a/ginac/registrar.h b/ginac/registrar.h index e8000019..f665ccd8 100644 --- a/ginac/registrar.h +++ b/ginac/registrar.h @@ -61,22 +61,54 @@ struct registered_class_info { }; -/** Macro for inclusion in the declaration of each registered class. */ -#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername) \ +#define GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(classname, supername) \ public: \ typedef supername inherited; \ static registered_class_info reg_info; \ virtual const char *class_name(void) const; \ classname(const archive_node &n, const lst &sym_lst); \ virtual void archive(archive_node &n) const; \ - static ex unarchive(const archive_node &n, const lst &sym_lst); \ + static ex unarchive(const archive_node &n, const lst &sym_lst); + +/** Macro for inclusion in the declaration of each registered class. */ +#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername) \ + GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(classname, supername) \ +public: \ + classname(); \ + ~classname(); \ + classname(const classname & other); \ + const classname & operator=(const classname & other); \ +protected: \ + void copy(const classname & other); \ + void destroy(bool call_parent); \ private: -/** Macro for inclusion in the implementation of each registered class. */ -#define GINAC_IMPLEMENT_REGISTERED_CLASS(classname, supername) \ +#define GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(classname, supername) \ registered_class_info classname::reg_info(#classname, #supername, TINFO_##classname, &classname::unarchive); \ const char *classname::class_name(void) const {return reg_info.name;} +/** Macro for inclusion in the implementation of each registered class. */ +#define GINAC_IMPLEMENT_REGISTERED_CLASS(classname, supername) \ + GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(classname, supername) \ +classname::~classname() \ +{ \ + debugmsg(#classname " destructor", LOGLEVEL_DESTRUCT); \ + destroy(false); \ +} \ +classname::classname(const classname & other) \ +{ \ + debugmsg(#classname " copy constructor", LOGLEVEL_CONSTRUCT); \ + copy(other); \ +} \ +const classname & classname::operator=(const classname & other) \ +{ \ + debugmsg(#classname " operator=", LOGLEVEL_ASSIGNMENT); \ + if (this != &other) { \ + destroy(true); \ + copy(other); \ + } \ + return *this; \ +} /** Find TINFO_* key by class name. */ extern unsigned int find_tinfo_key(const std::string &class_name); diff --git a/ginac/relational.cpp b/ginac/relational.cpp index 7ed651c9..c8b50431 100644 --- a/ginac/relational.cpp +++ b/ginac/relational.cpp @@ -45,28 +45,6 @@ relational::relational() : basic(TINFO_relational) debugmsg("relational default constructor",LOGLEVEL_CONSTRUCT); } -relational::~relational() -{ - debugmsg("relational destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -relational::relational(const relational & other) -{ - debugmsg("relational copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const relational & relational::operator=(const relational & other) -{ - debugmsg("relational operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void relational::copy(const relational & other) diff --git a/ginac/relational.h b/ginac/relational.h index 85d9db1d..5a9fe443 100644 --- a/ginac/relational.h +++ b/ginac/relational.h @@ -47,18 +47,6 @@ public: greater_or_equal }; -// member functions - - // default constructor, destructor, copy constructor assignment operator and helpers -public: - relational(); - ~relational(); - relational(const relational & other); - const relational & operator=(const relational & other); -protected: - void copy(const relational & other); - void destroy(bool call_parent); - // other constructors public: relational(const ex & lhs, const ex & rhs, operators oper=equal); diff --git a/ginac/simp_lor.cpp b/ginac/simp_lor.cpp index 06e79da1..23bd24a3 100644 --- a/ginac/simp_lor.cpp +++ b/ginac/simp_lor.cpp @@ -31,6 +31,7 @@ #include "simp_lor.h" #include "ex.h" #include "mul.h" +#include "archive.h" #include "debugmsg.h" #include "utils.h" @@ -38,6 +39,8 @@ namespace GiNaC { #endif // ndef NO_NAMESPACE_GINAC +GINAC_IMPLEMENT_REGISTERED_CLASS(simp_lor, indexed) + ////////// // default constructor, destructor, copy constructor assignment operator and helpers ////////// @@ -50,28 +53,6 @@ simp_lor::simp_lor() : type(invalid) tinfo_key=TINFO_simp_lor; } -simp_lor::~simp_lor() -{ - debugmsg("simp_lor destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -simp_lor::simp_lor(const simp_lor & other) -{ - debugmsg("simp_lor copy constructor",LOGLEVEL_CONSTRUCT); - copy (other); -} - -const simp_lor & simp_lor::operator=(const simp_lor & other) -{ - debugmsg("simp_lor operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void simp_lor::copy(const simp_lor & other) @@ -132,6 +113,36 @@ simp_lor::simp_lor(simp_lor_types const t, const std::string & n, exvector * ivp GINAC_ASSERT(all_of_type_lorentzidx()); } +////////// +// archiving +////////// + +/** Construct object from archive_node. */ +simp_lor::simp_lor(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) +{ + debugmsg("simp_lor constructor from archive_node", LOGLEVEL_CONSTRUCT); + unsigned int ty; + if (!(n.find_unsigned("type", ty))) + throw (std::runtime_error("unknown simp_lor type in archive")); + type = (simp_lor_types)ty; + n.find_string("name", name); +} + +/** Unarchive the object. */ +ex simp_lor::unarchive(const archive_node &n, const lst &sym_lst) +{ + return (new simp_lor(n, sym_lst))->setflag(status_flags::dynallocated); +} + +/** Archive the object. */ +void simp_lor::archive(archive_node &n) const +{ + inherited::archive(n); + n.add_unsigned("type", type); + n.add_string("name", name); +} + + ////////// // functions overriding virtual functions from bases classes ////////// diff --git a/ginac/simp_lor.h b/ginac/simp_lor.h index 8a626217..d76f6c56 100644 --- a/ginac/simp_lor.h +++ b/ginac/simp_lor.h @@ -70,6 +70,8 @@ protected: /** Base class for simp_lor object */ class simp_lor : public indexed { + GINAC_DECLARE_REGISTERED_CLASS(simp_lor, indexed) + // friends friend class scalar_products; @@ -87,18 +89,6 @@ public: simp_lor_vec } simp_lor_types; -// member functions - - // default constructor, destructor, copy constructor assignment operator and helpers -public: - simp_lor(); - ~simp_lor(); - simp_lor(const simp_lor & other); - const simp_lor & operator=(const simp_lor & other); -protected: - void copy(const simp_lor & other); - void destroy(bool call_parent); - // other constructors protected: simp_lor(simp_lor_types const t); diff --git a/ginac/structure.cpp b/ginac/structure.cpp index ddd953df..4aa4f10c 100644 --- a/ginac/structure.cpp +++ b/ginac/structure.cpp @@ -23,12 +23,15 @@ #include #include "structure.h" +#include "archive.h" #include "debugmsg.h" #ifndef NO_NAMESPACE_GINAC namespace GiNaC { #endif // ndef NO_NAMESPACE_GINAC +GINAC_IMPLEMENT_REGISTERED_CLASS(structure, basic) + ////////// // default constructor, destructor, copy constructor assignment operator and helpers ////////// @@ -41,28 +44,6 @@ structure::structure() tinfo_key = TINFO_structure; } -structure::~structure() -{ - debugmsg("structure destructor",LOGLEVEL_DESTRUCT); - destroy(false); -} - -structure::structure(const structure & other) -{ - debugmsg("structure copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); -} - -const structure & structure::operator=(const structure & other) -{ - debugmsg("structure operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(true); - copy(other); - } - return *this; -} - // protected void structure::copy(const structure & other) @@ -81,6 +62,28 @@ void structure::destroy(bool call_parent) // none +////////// +// archiving +////////// + +/** Construct object from archive_node. */ +structure::structure(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) +{ + debugmsg("structure constructor from archive_node", LOGLEVEL_CONSTRUCT); +} + +/** Unarchive the object. */ +ex structure::unarchive(const archive_node &n, const lst &sym_lst) +{ + return (new structure(n, sym_lst))->setflag(status_flags::dynallocated); +} + +/** Archive the object. */ +void structure::archive(archive_node &n) const +{ + inherited::archive(n); +} + ////////// // structures overriding virtual structures from bases classes ////////// diff --git a/ginac/structure.h b/ginac/structure.h index 28abe6ad..6c540033 100644 --- a/ginac/structure.h +++ b/ginac/structure.h @@ -41,17 +41,7 @@ struct registered_structure_info { class structure : public basic { -// member functions - - // default constructor, destructor, copy constructor assignment operator and helpers -public: - structure(); - ~structure(); - structure(const structure & other); - const structure & operator=(const structure & other); -protected: - void copy(const structure & other); - void destroy(bool call_parent); + GINAC_DECLARE_REGISTERED_CLASS(structure, basic) // other constructors // none diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index 7ff75ec7..2657900a 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -34,7 +34,7 @@ namespace GiNaC { #endif // ndef NO_NAMESPACE_GINAC -GINAC_IMPLEMENT_REGISTERED_CLASS(symbol, basic) +GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(symbol, basic) ////////// // default constructor, destructor, copy constructor assignment operator and helpers diff --git a/ginac/symbol.h b/ginac/symbol.h index 20c5468b..21b7e411 100644 --- a/ginac/symbol.h +++ b/ginac/symbol.h @@ -39,7 +39,7 @@ namespace GiNaC { * first place. */ class symbol : public basic { - GINAC_DECLARE_REGISTERED_CLASS(symbol, basic) + GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(symbol, basic) // types