the destructor, copy constructor, and assignment operator (which were the
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 15 Feb 2001 22:54:52 +0000 (22:54 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Thu, 15 Feb 2001 22:54:52 +0000 (22:54 +0000)
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

49 files changed:
ginac/add.cpp
ginac/add.h
ginac/basic.cpp
ginac/basic.h
ginac/clifford.cpp
ginac/clifford.h
ginac/color.cpp
ginac/color.h
ginac/coloridx.cpp
ginac/coloridx.h
ginac/constant.cpp
ginac/constant.h
ginac/container.pl
ginac/expairseq.cpp
ginac/expairseq.h
ginac/fail.cpp
ginac/fail.h
ginac/function.pl
ginac/idx.cpp
ginac/idx.h
ginac/indexed.cpp
ginac/indexed.h
ginac/isospin.cpp
ginac/isospin.h
ginac/lorentzidx.cpp
ginac/lorentzidx.h
ginac/lortensor.cpp
ginac/lortensor.h
ginac/matrix.cpp
ginac/matrix.h
ginac/mul.cpp
ginac/mul.h
ginac/ncmul.cpp
ginac/ncmul.h
ginac/numeric.cpp
ginac/numeric.h
ginac/power.cpp
ginac/power.h
ginac/pseries.cpp
ginac/pseries.h
ginac/registrar.h
ginac/relational.cpp
ginac/relational.h
ginac/simp_lor.cpp
ginac/simp_lor.h
ginac/structure.cpp
ginac/structure.h
ginac/symbol.cpp
ginac/symbol.h

index 74a3732..574a8e8 100644 (file)
@@ -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)
index c30034d..924eb40 100644 (file)
@@ -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);
index daefabb..9f0bbf5 100644 (file)
@@ -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
index 05ee4f2..e7238e5 100644 (file)
@@ -61,7 +61,7 @@ typedef std::vector<ex> 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;
 
index 37e1d8d..c3c0d9f 100644 (file)
@@ -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)
index e7b05f5..2d02ebc 100644 (file)
@@ -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);
index 9f3b300..4b59877 100644 (file)
@@ -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)
index 2b607e3..2d44aa8 100644 (file)
@@ -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);
index b9568a8..221e86b 100644 (file)
@@ -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)
index 4b40a3a..780aac4 100644 (file)
@@ -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);
index 3e6c667..ae71579 100644 (file)
@@ -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)
index 70b2816..0c9394f 100644 (file)
@@ -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);
index bbeb3b4..232d299 100755 (executable)
@@ -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)
index 3daa4da..56fcba6 100644 (file)
@@ -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
index d9cc0b3..bba0902 100644 (file)
@@ -57,7 +57,7 @@ typedef std::vector<epplist> epplistvector;
  *  the same way.) */
 class expairseq : public basic
 {
-       GINAC_DECLARE_REGISTERED_CLASS(expairseq, basic)
+       GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(expairseq, basic)
 
 // member functions
 
index 8a281e8..c111804 100644 (file)
@@ -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)
index d6bf22d..248c593 100644 (file)
@@ -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
index d97e58f..8a96a32 100755 (executable)
@@ -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)
index 34d5c85..af463a8 100644 (file)
@@ -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)
index 8b991ac..981fee6 100644 (file)
@@ -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);
index 8e05dbf..7127e9a 100644 (file)
@@ -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)
index c43d4ad..b1d8844 100644 (file)
@@ -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);
index 911c86f..a74e05f 100644 (file)
@@ -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)
index 313c130..3facb90 100644 (file)
@@ -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);
index 67e5576..6a367be 100644 (file)
@@ -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)
index 3d5355b..099f36b 100644 (file)
@@ -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);
index 0238adc..7a97887 100644 (file)
@@ -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();
index 977be98..d25211f 100644 (file)
@@ -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);
index ec7ee2c..0b87ed5 100644 (file)
@@ -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)
index 279ddfc..7c2b9c0 100644 (file)
@@ -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);
index 2392772..80901d7 100644 (file)
@@ -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)
index 7895496..c6d607d 100644 (file)
@@ -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);
index 8964d6b..86b76e7 100644 (file)
@@ -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)
index a604eea..a4a77eb 100644 (file)
@@ -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);
index 32bb7fb..3398f60 100644 (file)
@@ -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)
index 247951a..1eda94d 100644 (file)
@@ -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);
index 9d224d1..3069733 100644 (file)
@@ -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)
index 6bdafa0..65c86b7 100644 (file)
@@ -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);
index 9adc8fc..d447aaa 100644 (file)
@@ -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);
index 0b0d92f..14b011a 100644 (file)
@@ -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_);
index e800001..f665ccd 100644 (file)
@@ -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);
index 7ed651c..c8b5043 100644 (file)
@@ -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)
index 85d9db1..5a9fe44 100644 (file)
@@ -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);
index 06e79da..23bd24a 100644 (file)
@@ -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
 //////////
index 8a62621..d76f6c5 100644 (file)
@@ -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);
index ddd953d..4aa4f10 100644 (file)
 #include <string>
 
 #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
 //////////
index 28abe6a..6c54003 100644 (file)
@@ -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
index 7ff75ec..2657900 100644 (file)
@@ -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
index 20c5468..21b7e41 100644 (file)
@@ -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