3 * Implementation of GiNaC's color indices. */
6 * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #ifndef NO_NAMESPACE_GINAC
32 #endif // ndef NO_NAMESPACE_GINAC
34 GINAC_IMPLEMENT_REGISTERED_CLASS(coloridx, idx)
37 // default constructor, destructor, copy constructor assignment operator and helpers
44 debugmsg("coloridx default constructor",LOGLEVEL_CONSTRUCT);
45 // serial is incremented in idx::idx()
46 name="color"+ToString(serial);
47 tinfo_key=TINFO_coloridx;
52 debugmsg("coloridx destructor",LOGLEVEL_DESTRUCT);
56 coloridx::coloridx(const coloridx & other)
58 debugmsg("coloridx copy constructor",LOGLEVEL_CONSTRUCT);
62 const coloridx & coloridx::operator=(const coloridx & other)
64 debugmsg("coloridx operator=",LOGLEVEL_ASSIGNMENT);
74 void coloridx::copy(const coloridx & other)
76 inherited::copy(other);
79 void coloridx::destroy(bool call_parent)
81 if (call_parent) inherited::destroy(call_parent);
90 coloridx::coloridx(bool cov) : idx(cov)
92 debugmsg("coloridx constructor from bool",LOGLEVEL_CONSTRUCT);
93 // serial is incremented in idx::idx(bool)
94 name="color"+ToString(serial);
95 tinfo_key=TINFO_coloridx;
98 coloridx::coloridx(const string & n, bool cov) : idx(n,cov)
100 debugmsg("coloridx constructor from string,bool",LOGLEVEL_CONSTRUCT);
101 tinfo_key=TINFO_coloridx;
104 coloridx::coloridx(const char * n, bool cov) : idx(n,cov)
106 debugmsg("coloridx constructor from char*,bool",LOGLEVEL_CONSTRUCT);
107 tinfo_key=TINFO_coloridx;
110 coloridx::coloridx(unsigned v, bool cov) : idx(v,cov)
112 debugmsg("coloridx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
113 tinfo_key=TINFO_coloridx;
120 /** Construct object from archive_node. */
121 coloridx::coloridx(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
123 debugmsg("coloridx constructor from archive_node", LOGLEVEL_CONSTRUCT);
126 /** Unarchive the object. */
127 ex coloridx::unarchive(const archive_node &n, const lst &sym_lst)
129 return (new coloridx(n, sym_lst))->setflag(status_flags::dynallocated);
132 /** Archive the object. */
133 void coloridx::archive(archive_node &n) const
135 inherited::archive(n);
139 // functions overriding virtual functions from bases classes
144 basic * coloridx::duplicate() const
146 debugmsg("coloridx duplicate",LOGLEVEL_DUPLICATE);
147 return new coloridx(*this);
150 void coloridx::printraw(ostream & os) const
152 debugmsg("coloridx printraw",LOGLEVEL_PRINT);
157 os << "symbolic,name=" << name;
159 os << "non symbolic,value=" << value;
165 os << ",contravariant";
168 os << ",serial=" << serial;
169 os << ",hash=" << hashvalue << ",flags=" << flags;
173 void coloridx::printtree(ostream & os, unsigned indent) const
175 debugmsg("coloridx printtree",LOGLEVEL_PRINT);
177 os << string(indent,' ') << "coloridx: ";
180 os << "symbolic,name=" << name;
182 os << "non symbolic,value=" << value;
188 os << ",contravariant";
191 os << ", serial=" << serial
192 << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
193 << ", flags=" << flags << endl;
196 void coloridx::print(ostream & os, unsigned upper_precedence) const
198 debugmsg("coloridx print",LOGLEVEL_PRINT);
212 bool coloridx::info(unsigned inf) const
214 if (inf==info_flags::coloridx) return true;
215 return idx::info(inf);
219 // new virtual functions which can be overridden by derived classes
225 // non-virtual functions in this class
231 // static member variables
240 const coloridx some_coloridx;
241 const type_info & typeid_coloridx=typeid(some_coloridx);
243 #ifndef NO_NAMESPACE_GINAC
245 #endif // ndef NO_NAMESPACE_GINAC