From d7512158475455f647f6fc5f8a9d33f674652783 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Mon, 24 Jan 2000 21:28:22 +0000 Subject: [PATCH] - archiving implemented in lorentzidx --- ginac/lorentzidx.cpp | 47 +++++++++++++++++++++++++++++++++++++++++--- ginac/lorentzidx.h | 2 ++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/ginac/lorentzidx.cpp b/ginac/lorentzidx.cpp index e8dacf73..52487dde 100644 --- a/ginac/lorentzidx.cpp +++ b/ginac/lorentzidx.cpp @@ -23,6 +23,8 @@ #include #include "lorentzidx.h" +#include "lst.h" +#include "archive.h" #include "utils.h" #include "debugmsg.h" @@ -30,6 +32,8 @@ namespace GiNaC { #endif // ndef NO_GINAC_NAMESPACE +GINAC_IMPLEMENT_REGISTERED_CLASS(lorentzidx, idx) + ////////// // default constructor, destructor, copy constructor assignment operator and helpers ////////// @@ -70,14 +74,14 @@ const lorentzidx & lorentzidx::operator=(const lorentzidx & other) void lorentzidx::copy(const lorentzidx & other) { - idx::copy(other); + inherited::copy(other); orthogonal_only=other.orthogonal_only; dim_parallel_space=other.dim_parallel_space; } void lorentzidx::destroy(bool call_parent) { - if (call_parent) idx::destroy(call_parent); + if (call_parent) inherited::destroy(call_parent); } ////////// @@ -122,6 +126,43 @@ lorentzidx::lorentzidx(unsigned v, bool cov) : idx(v,cov), tinfo_key=TINFO_lorentzidx; } +////////// +// archiving +////////// + +/** Construct object from archive_node. */ +lorentzidx::lorentzidx(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) +{ + debugmsg("lorentzidx constructor from archive_node", LOGLEVEL_CONSTRUCT); + n.find_bool("orthogonal_only", orthogonal_only); + if (orthogonal_only) + n.find_unsigned("pdim", dim_parallel_space); +} + +/** Unarchive the object. */ +ex lorentzidx::unarchive(const archive_node &n, const lst &sym_lst) +{ + ex s = (new lorentzidx(n, sym_lst))->setflag(status_flags::dynallocated); + + if (ex_to_lorentzidx(s).symbolic) { + // If lorentzidx is in sym_lst, return the existing lorentzidx + for (int i=0; i