1 /** @file structure.cpp
3 * Implementation of 'abstract' class structure. */
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
25 #include "structure.h"
28 #ifndef NO_GINAC_NAMESPACE
30 #endif // ndef NO_GINAC_NAMESPACE
33 // default constructor, destructor, copy constructor assignment operator and helpers
38 structure::structure()
40 debugmsg("structure default constructor",LOGLEVEL_CONSTRUCT);
41 tinfo_key = TINFO_structure;
44 structure::~structure()
46 debugmsg("structure destructor",LOGLEVEL_DESTRUCT);
50 structure::structure(structure const & other)
52 debugmsg("structure copy constructor",LOGLEVEL_CONSTRUCT);
56 structure const & structure::operator=(structure const & other)
58 debugmsg("structure operator=",LOGLEVEL_ASSIGNMENT);
68 void structure::copy(structure const & other)
73 void structure::destroy(bool call_parent)
75 if (call_parent) basic::destroy(call_parent);
85 // structures overriding virtual structures from bases classes
90 basic * structure::duplicate() const
92 debugmsg("structure duplicate",LOGLEVEL_DUPLICATE);
93 return new structure(*this);
96 void structure::printraw(ostream & os) const
98 debugmsg("structure printraw",LOGLEVEL_PRINT);
100 os << "structure(hash=" << hashvalue << ",flags=" << flags << ")";
103 void structure::print(ostream & os, unsigned upper_precedence) const
105 debugmsg("structure print",LOGLEVEL_PRINT);
110 void structure::printtree(ostream & os, unsigned indent) const
112 debugmsg("structure printtree",LOGLEVEL_PRINT);
114 os << string(indent,' ') << "structure "
115 << "hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
116 << ", flags=" << flags << endl;
119 void structure::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
121 debugmsg("structure print csrc",LOGLEVEL_PRINT);
128 int structure::compare_same_type(basic const & other) const
130 GINAC_ASSERT(is_of_type(other, structure));
131 return 0; // all structures are the same
134 bool structure::is_equal_same_type(basic const & other) const
136 GINAC_ASSERT(is_of_type(other, structure));
137 return true; // all structures are the same
141 // new virtual structures which can be overridden by derived classes
147 // non-virtual structures in this class
152 vector<registered_structure_info> & structure::registered_structures(void)
154 static vector<registered_structure_info> * rs=new vector<registered_structure_info>;
160 unsigned structure::register_new(char const * nm)
162 registered_structure_info rsi={nm};
163 registered_structures().push_back(rsi);
164 return registered_structures().size()-1;
168 // static member variables
177 const structure some_structure;
178 type_info const & typeid_structure=typeid(some_structure);
180 #ifndef NO_GINAC_NAMESPACE
182 #endif // ndef NO_GINAC_NAMESPACE