]> www.ginac.de Git - ginac.git/blob - ginac/structure.cpp
- switched to automake build environment
[ginac.git] / ginac / structure.cpp
1 /** @file structure.cpp
2  *
3  *  Implementation of 'abstract' class structure. */
4
5 #include <string>
6
7 #include "ginac.h"
8
9 //////////
10 // default constructor, destructor, copy constructor assignment operator and helpers
11 //////////
12
13 // public
14
15 structure::structure()
16 {
17     debugmsg("structure default constructor",LOGLEVEL_CONSTRUCT);
18     tinfo_key = TINFO_STRUCTURE;
19 }
20
21 structure::~structure()
22 {
23     debugmsg("structure destructor",LOGLEVEL_DESTRUCT);
24     destroy(0);
25 }
26
27 structure::structure(structure const & other)
28 {
29     debugmsg("structure copy constructor",LOGLEVEL_CONSTRUCT);
30     copy(other);
31 }
32
33 structure const & structure::operator=(structure const & other)
34 {
35     debugmsg("structure operator=",LOGLEVEL_ASSIGNMENT);
36     if (this != &other) {
37         destroy(1);
38         copy(other);
39     }
40     return *this;
41 }
42
43 // protected
44
45 void structure::copy(structure const & other)
46 {
47     basic::copy(other);
48 }
49
50 void structure::destroy(bool call_parent)
51 {
52     if (call_parent) basic::destroy(call_parent);
53 }
54
55 //////////
56 // other constructors
57 //////////
58
59 // none
60
61 //////////
62 // structures overriding virtual structures from bases classes
63 //////////
64
65 // public
66
67 basic * structure::duplicate() const
68 {
69     debugmsg("structure duplicate",LOGLEVEL_DUPLICATE);
70     return new structure(*this);
71 }
72
73 void structure::printraw(ostream & os) const
74 {
75     debugmsg("structure printraw",LOGLEVEL_PRINT);
76
77     os << "structure(hash=" << hashvalue << ",flags=" << flags << ")";
78 }
79
80 void structure::print(ostream & os, unsigned upper_precedence) const
81 {
82     debugmsg("structure print",LOGLEVEL_PRINT);
83
84     os << "structure()";
85 }
86
87 void structure::printtree(ostream & os, unsigned indent) const
88 {
89     debugmsg("structure printtree",LOGLEVEL_PRINT);
90
91     os << string(indent,' ') << "structure "
92        << "hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
93        << ", flags=" << flags << endl;
94 }
95
96 void structure::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
97 {
98     debugmsg("structure print csrc",LOGLEVEL_PRINT);
99
100     os << "structure()";
101 }
102
103 // protected
104
105 int structure::compare_same_type(basic const & other) const
106 {
107     ASSERT(is_of_type(other, structure));
108     return 0; // all structures are the same
109 }
110
111 bool structure::is_equal_same_type(basic const & other) const
112 {
113     ASSERT(is_of_type(other, structure));
114     return true; // all structures are the same
115 }
116
117 //////////
118 // new virtual structures which can be overridden by derived classes
119 //////////
120
121 // none
122
123 //////////
124 // non-virtual structures in this class
125 //////////
126
127 // protected
128
129 vector<registered_structure_info> & structure::registered_structures(void)
130 {
131     static vector<registered_structure_info> * rs=new vector<registered_structure_info>;
132     return *rs;
133 }
134
135 // public
136
137 unsigned structure::register_new(char const * nm)
138 {
139     registered_structure_info rsi={nm};
140     registered_structures().push_back(rsi);
141     return registered_structures().size()-1;
142 }
143
144 //////////
145 // static member variables
146 //////////
147
148 // none
149
150 //////////
151 // global constants
152 //////////
153
154 const structure some_structure;
155 type_info const & typeid_structure=typeid(some_structure);
156