]> www.ginac.de Git - ginac.git/blob - ginac/structure.cpp
0bd1d4fb6e869e178a760470df0af0967d721e3a
[ginac.git] / ginac / structure.cpp
1 /** @file structure.cpp
2  *
3  *  Implementation of 'abstract' class structure. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
7  *
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.
12  *
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.
17  *
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
21  */
22
23 #include <string>
24
25 #include "structure.h"
26 #include "archive.h"
27 #include "debugmsg.h"
28 #include "utils.h"
29
30 namespace GiNaC {
31
32 GINAC_IMPLEMENT_REGISTERED_CLASS(structure, basic)
33
34 //////////
35 // default ctor, dtor, copy ctor assignment operator and helpers
36 //////////
37
38 DEFAULT_CTORS(structure)
39
40 //////////
41 // archiving
42 //////////
43
44 DEFAULT_ARCHIVING(structure)
45
46 //////////
47 // functions overriding virtual functions from bases classes
48 //////////
49
50 void structure::printraw(std::ostream & os) const
51 {
52         debugmsg("structure printraw",LOGLEVEL_PRINT);
53
54         os << class_name() << "(hash=" << hashvalue << ",flags=" << flags << ")";
55 }
56
57 void structure::print(std::ostream & os, unsigned upper_precedence) const
58 {
59         debugmsg("structure print",LOGLEVEL_PRINT);
60
61         os << class_name() << "()";
62 }
63
64 void structure::printtree(std::ostream & os, unsigned indent) const
65 {
66         debugmsg("structure printtree",LOGLEVEL_PRINT);
67
68         os << std::string(indent,' ') << "structure "
69            << "hash=" << hashvalue
70            << " (0x" << std::hex << hashvalue << std::dec << ")"
71            << ", flags=" << flags << std::endl;
72 }
73
74 void structure::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const
75 {
76         debugmsg("structure print csrc",LOGLEVEL_PRINT);
77
78         os << "structure()";
79 }
80
81 // protected
82
83 DEFAULT_COMPARE(structure)
84
85 bool structure::is_equal_same_type(const basic & other) const
86 {
87         GINAC_ASSERT(is_of_type(other, structure));
88         return true; // all structures are the same
89 }
90
91 //////////
92 // non-virtual functions in this class
93 //////////
94
95 // protected
96
97 std::vector<registered_structure_info> & structure::registered_structures(void)
98 {
99         static std::vector<registered_structure_info> * rs = new std::vector<registered_structure_info>;
100         return *rs;
101 }
102
103 // public
104
105 unsigned structure::register_new(const char * nm)
106 {
107         registered_structure_info rsi={nm};
108         registered_structures().push_back(rsi);
109         return registered_structures().size()-1;
110 }
111
112 } // namespace GiNaC