3 * Implementation of GiNaC's color indices.
5 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 // default constructor, destructor, copy constructor assignment operator and helpers
35 debugmsg("coloridx default constructor",LOGLEVEL_CONSTRUCT);
36 // serial is incremented in idx::idx()
37 name="color"+ToString(serial);
38 tinfo_key=TINFO_COLORIDX;
43 debugmsg("coloridx destructor",LOGLEVEL_DESTRUCT);
47 coloridx::coloridx(coloridx const & other)
49 debugmsg("coloridx copy constructor",LOGLEVEL_CONSTRUCT);
53 coloridx const & coloridx::operator=(coloridx const & other)
55 debugmsg("coloridx operator=",LOGLEVEL_ASSIGNMENT);
65 void coloridx::copy(coloridx const & other)
70 void coloridx::destroy(bool call_parent)
72 if (call_parent) idx::destroy(call_parent);
81 coloridx::coloridx(bool cov) : idx(cov)
83 debugmsg("coloridx constructor from bool",LOGLEVEL_CONSTRUCT);
84 // serial is incremented in idx::idx(bool)
85 name="color"+ToString(serial);
86 tinfo_key=TINFO_COLORIDX;
89 coloridx::coloridx(string const & n, bool cov) : idx(n,cov)
91 debugmsg("coloridx constructor from string,bool",LOGLEVEL_CONSTRUCT);
92 tinfo_key=TINFO_COLORIDX;
95 coloridx::coloridx(char const * n, bool cov) : idx(n,cov)
97 debugmsg("coloridx constructor from char*,bool",LOGLEVEL_CONSTRUCT);
98 tinfo_key=TINFO_COLORIDX;
101 coloridx::coloridx(unsigned const v, bool cov) : idx(v,cov)
103 debugmsg("coloridx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
104 tinfo_key=TINFO_COLORIDX;
108 // functions overriding virtual functions from bases classes
113 basic * coloridx::duplicate() const
115 debugmsg("coloridx duplicate",LOGLEVEL_DUPLICATE);
116 return new coloridx(*this);
119 void coloridx::printraw(ostream & os) const
121 debugmsg("coloridx printraw",LOGLEVEL_PRINT);
126 os << "symbolic,name=" << name;
128 os << "non symbolic,value=" << value;
134 os << ",contravariant";
137 os << ",serial=" << serial;
138 os << ",hash=" << hashvalue << ",flags=" << flags;
142 void coloridx::printtree(ostream & os, unsigned indent) const
144 debugmsg("coloridx printtree",LOGLEVEL_PRINT);
146 os << string(indent,' ') << "coloridx: ";
149 os << "symbolic,name=" << name;
151 os << "non symbolic,value=" << value;
157 os << ",contravariant";
160 os << ", serial=" << serial
161 << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
162 << ", flags=" << flags << endl;
165 void coloridx::print(ostream & os, unsigned upper_precedence) const
167 debugmsg("coloridx print",LOGLEVEL_PRINT);
181 bool coloridx::info(unsigned inf) const
183 if (inf==info_flags::coloridx) return true;
184 return idx::info(inf);
188 // new virtual functions which can be overridden by derived classes
194 // non-virtual functions in this class
200 // static member variables
209 const coloridx some_coloridx;
210 type_info const & typeid_coloridx=typeid(some_coloridx);