]> www.ginac.de Git - ginac.git/blob - ginac/structure.cpp
* As agreed upon at lunch, remove debugmsg since it is hardly of any use.
[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 "utils.h"
28 #include "print.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 base classes
48 //////////
49
50 void structure::print(const print_context & c, unsigned level) const
51 {
52         if (is_a<print_tree>(c)) {
53
54                 c.s << std::string(level, ' ') << class_name()
55                     << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
56                     << std::endl;
57
58         } else
59                 c.s << class_name() << "()";
60 }
61
62 // protected
63
64 DEFAULT_COMPARE(structure)
65
66 bool structure::is_equal_same_type(const basic & other) const
67 {
68         GINAC_ASSERT(is_a<structure>(other));
69         return true; // all structures are the same
70 }
71
72 //////////
73 // non-virtual functions in this class
74 //////////
75
76 // protected
77
78 std::vector<registered_structure_info> & structure::registered_structures(void)
79 {
80         static std::vector<registered_structure_info> * rs = new std::vector<registered_structure_info>;
81         return *rs;
82 }
83
84 // public
85
86 unsigned structure::register_new(const char * nm)
87 {
88         registered_structure_info rsi={nm};
89         registered_structures().push_back(rsi);
90         return registered_structures().size()-1;
91 }
92
93 } // namespace GiNaC