1 /** @file structure.cpp
3 * Implementation of 'abstract' class structure. */
6 * GiNaC Copyright (C) 1999-2001 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"
29 #ifndef NO_NAMESPACE_GINAC
31 #endif // ndef NO_NAMESPACE_GINAC
33 GINAC_IMPLEMENT_REGISTERED_CLASS(structure, basic)
36 // default constructor, destructor, copy constructor assignment operator and helpers
41 structure::structure()
43 debugmsg("structure default constructor",LOGLEVEL_CONSTRUCT);
44 tinfo_key = TINFO_structure;
49 void structure::copy(const structure & other)
54 void structure::destroy(bool call_parent)
56 if (call_parent) basic::destroy(call_parent);
69 /** Construct object from archive_node. */
70 structure::structure(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
72 debugmsg("structure constructor from archive_node", LOGLEVEL_CONSTRUCT);
75 /** Unarchive the object. */
76 ex structure::unarchive(const archive_node &n, const lst &sym_lst)
78 return (new structure(n, sym_lst))->setflag(status_flags::dynallocated);
81 /** Archive the object. */
82 void structure::archive(archive_node &n) const
84 inherited::archive(n);
88 // structures overriding virtual structures from bases classes
93 basic * structure::duplicate() const
95 debugmsg("structure duplicate",LOGLEVEL_DUPLICATE);
96 return new structure(*this);
99 void structure::printraw(std::ostream & os) const
101 debugmsg("structure printraw",LOGLEVEL_PRINT);
103 os << "structure(hash=" << hashvalue << ",flags=" << flags << ")";
106 void structure::print(std::ostream & os, unsigned upper_precedence) const
108 debugmsg("structure print",LOGLEVEL_PRINT);
113 void structure::printtree(std::ostream & os, unsigned indent) const
115 debugmsg("structure printtree",LOGLEVEL_PRINT);
117 os << std::string(indent,' ') << "structure "
118 << "hash=" << hashvalue
119 << " (0x" << std::hex << hashvalue << std::dec << ")"
120 << ", flags=" << flags << std::endl;
123 void structure::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const
125 debugmsg("structure print csrc",LOGLEVEL_PRINT);
132 int structure::compare_same_type(const basic & other) const
134 GINAC_ASSERT(is_of_type(other, structure));
135 return 0; // all structures are the same
138 bool structure::is_equal_same_type(const basic & other) const
140 GINAC_ASSERT(is_of_type(other, structure));
141 return true; // all structures are the same
145 // new virtual structures which can be overridden by derived classes
151 // non-virtual structures in this class
156 std::vector<registered_structure_info> & structure::registered_structures(void)
158 static std::vector<registered_structure_info> * rs = new std::vector<registered_structure_info>;
164 unsigned structure::register_new(const char * nm)
166 registered_structure_info rsi={nm};
167 registered_structures().push_back(rsi);
168 return registered_structures().size()-1;
171 #ifndef NO_NAMESPACE_GINAC
173 #endif // ndef NO_NAMESPACE_GINAC