X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fcoloridx.cpp;h=368aef08ba6d74707c505f59264ba735fd5d9bdf;hp=e7c35c551afc8508a318b64f6ce6b0f25bdab567;hb=2692a55867331a570ec7f0d957de00a996fd9d7c;hpb=a331d1fd814315cd934c4f0ebf0cf485dc52fe96 diff --git a/ginac/coloridx.cpp b/ginac/coloridx.cpp index e7c35c55..368aef08 100644 --- a/ginac/coloridx.cpp +++ b/ginac/coloridx.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's color indices. */ /* - * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,9 +27,9 @@ #include "utils.h" #include "debugmsg.h" -#ifndef NO_GINAC_NAMESPACE +#ifndef NO_NAMESPACE_GINAC namespace GiNaC { -#endif // ndef NO_GINAC_NAMESPACE +#endif // ndef NO_NAMESPACE_GINAC GINAC_IMPLEMENT_REGISTERED_CLASS(coloridx, idx) @@ -41,44 +41,44 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(coloridx, idx) coloridx::coloridx() { - debugmsg("coloridx default constructor",LOGLEVEL_CONSTRUCT); - // serial is incremented in idx::idx() - name="color"+ToString(serial); - tinfo_key=TINFO_coloridx; + debugmsg("coloridx default constructor",LOGLEVEL_CONSTRUCT); + // serial is incremented in idx::idx() + name="color"+ToString(serial); + tinfo_key=TINFO_coloridx; } coloridx::~coloridx() { - debugmsg("coloridx destructor",LOGLEVEL_DESTRUCT); - destroy(0); + debugmsg("coloridx destructor",LOGLEVEL_DESTRUCT); + destroy(false); } coloridx::coloridx(const coloridx & other) { - debugmsg("coloridx copy constructor",LOGLEVEL_CONSTRUCT); - copy(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(1); - copy(other); - } - return *this; + debugmsg("coloridx operator=",LOGLEVEL_ASSIGNMENT); + if (this != &other) { + destroy(true); + copy(other); + } + return *this; } // protected void coloridx::copy(const coloridx & other) { - inherited::copy(other); + inherited::copy(other); } void coloridx::destroy(bool call_parent) { - if (call_parent) inherited::destroy(call_parent); + if (call_parent) inherited::destroy(call_parent); } ////////// @@ -87,30 +87,49 @@ void coloridx::destroy(bool call_parent) // public +/** Construct symbolic color index, using an automatically generated unique name. + * + * @param cov Index is covariant (contravariant otherwise) + * @return newly constructed index */ coloridx::coloridx(bool cov) : idx(cov) { - debugmsg("coloridx constructor from bool",LOGLEVEL_CONSTRUCT); - // serial is incremented in idx::idx(bool) - name="color"+ToString(serial); - tinfo_key=TINFO_coloridx; + debugmsg("coloridx constructor from bool",LOGLEVEL_CONSTRUCT); + // serial is incremented in idx::idx(bool) + name="color"+ToString(serial); + tinfo_key=TINFO_coloridx; } -coloridx::coloridx(const string & n, bool cov) : idx(n,cov) +/** Construct symbolic color index with specified name. + * + * @param n Symbolic index name + * @param cov Index is covariant (contravariant otherwise) + * @return newly constructed index */ +coloridx::coloridx(const std::string & n, bool cov) : idx(n,cov) { - debugmsg("coloridx constructor from string,bool",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_coloridx; + debugmsg("coloridx constructor from string,bool",LOGLEVEL_CONSTRUCT); + tinfo_key=TINFO_coloridx; } +/** Construct symbolic color index with specified name. + * + * @param n Symbolic index name + * @param cov Index is covariant (contravariant otherwise) + * @return newly constructed index */ coloridx::coloridx(const char * n, bool cov) : idx(n,cov) { - debugmsg("coloridx constructor from char*,bool",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_coloridx; + debugmsg("coloridx constructor from char*,bool",LOGLEVEL_CONSTRUCT); + tinfo_key=TINFO_coloridx; } +/** Construct numeric color index with specified value. + * + * @param v Numeric index value + * @param cov Index is covariant (contravariant otherwise) + * @return newly constructed index */ coloridx::coloridx(unsigned v, bool cov) : idx(v,cov) { - debugmsg("coloridx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT); - tinfo_key=TINFO_coloridx; + debugmsg("coloridx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT); + tinfo_key=TINFO_coloridx; } ////////// @@ -120,19 +139,19 @@ coloridx::coloridx(unsigned v, bool cov) : idx(v,cov) /** Construct object from archive_node. */ coloridx::coloridx(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) { - debugmsg("coloridx constructor from archive_node", LOGLEVEL_CONSTRUCT); + debugmsg("coloridx constructor from archive_node", LOGLEVEL_CONSTRUCT); } /** Unarchive the object. */ ex coloridx::unarchive(const archive_node &n, const lst &sym_lst) { - return (new coloridx(n, sym_lst))->setflag(status_flags::dynallocated); + return (new coloridx(n, sym_lst))->setflag(status_flags::dynallocated); } /** Archive the object. */ void coloridx::archive(archive_node &n) const { - inherited::archive(n); + inherited::archive(n); } ////////// @@ -143,76 +162,77 @@ void coloridx::archive(archive_node &n) const basic * coloridx::duplicate() const { - debugmsg("coloridx duplicate",LOGLEVEL_DUPLICATE); - return new coloridx(*this); + debugmsg("coloridx duplicate",LOGLEVEL_DUPLICATE); + return new coloridx(*this); } -void coloridx::printraw(ostream & os) const +void coloridx::printraw(std::ostream & os) const { - debugmsg("coloridx printraw",LOGLEVEL_PRINT); + debugmsg("coloridx printraw",LOGLEVEL_PRINT); - os << "coloridx("; + os << "coloridx("; - if (symbolic) { - os << "symbolic,name=" << name; - } else { - os << "non symbolic,value=" << value; - } + if (symbolic) { + os << "symbolic,name=" << name; + } else { + os << "non symbolic,value=" << value; + } - if (covariant) { - os << ",covariant"; - } else { - os << ",contravariant"; - } + if (covariant) { + os << ",covariant"; + } else { + os << ",contravariant"; + } - os << ",serial=" << serial; - os << ",hash=" << hashvalue << ",flags=" << flags; - os << ")"; + os << ",serial=" << serial; + os << ",hash=" << hashvalue << ",flags=" << flags; + os << ")"; } -void coloridx::printtree(ostream & os, unsigned indent) const +void coloridx::printtree(std::ostream & os, unsigned indent) const { - debugmsg("coloridx printtree",LOGLEVEL_PRINT); - - os << string(indent,' ') << "coloridx: "; - - if (symbolic) { - os << "symbolic,name=" << name; - } else { - os << "non symbolic,value=" << value; - } - - if (covariant) { - os << ",covariant"; - } else { - os << ",contravariant"; - } - - os << ", serial=" << serial - << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + debugmsg("coloridx printtree",LOGLEVEL_PRINT); + + os << std::string(indent,' ') << "coloridx: "; + + if (symbolic) { + os << "symbolic,name=" << name; + } else { + os << "non symbolic,value=" << value; + } + + if (covariant) { + os << ",covariant"; + } else { + os << ",contravariant"; + } + + os << ", serial=" << serial + << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void coloridx::print(ostream & os, unsigned upper_precedence) const +void coloridx::print(std::ostream & os, unsigned upper_precedence) const { - debugmsg("coloridx print",LOGLEVEL_PRINT); - - if (covariant) { - os << "_"; - } else { - os << "~"; - } - if (symbolic) { - os << name; - } else { - os << value; - } + debugmsg("coloridx print",LOGLEVEL_PRINT); + + if (covariant) { + os << "_"; + } else { + os << "~"; + } + if (symbolic) { + os << name; + } else { + os << value; + } } bool coloridx::info(unsigned inf) const { - if (inf==info_flags::coloridx) return true; - return idx::info(inf); + if (inf==info_flags::coloridx) return true; + return idx::info(inf); } ////////// @@ -238,8 +258,8 @@ bool coloridx::info(unsigned inf) const ////////// const coloridx some_coloridx; -const type_info & typeid_coloridx=typeid(some_coloridx); +const std::type_info & typeid_coloridx = typeid(some_coloridx); -#ifndef NO_GINAC_NAMESPACE +#ifndef NO_NAMESPACE_GINAC } // namespace GiNaC -#endif // ndef NO_GINAC_NAMESPACE +#endif // ndef NO_NAMESPACE_GINAC