]> www.ginac.de Git - ginac.git/blob - ginac/fail.cpp
- implemented global class registry (for class basic and derived classes)
[ginac.git] / ginac / fail.cpp
1 /** @file fail.cpp
2  *
3  *  Implementation of class signaling failure of operation. Considered
4  *  obsolete all this stuff ought to be replaced by exceptions. */
5
6 /*
7  *  GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 #include "fail.h"
25 #include "archive.h"
26 #include "debugmsg.h"
27
28 #ifndef NO_GINAC_NAMESPACE
29 namespace GiNaC {
30 #endif // ndef NO_GINAC_NAMESPACE
31
32 GINAC_IMPLEMENT_REGISTERED_CLASS(fail, basic)
33
34 //////////
35 // default constructor, destructor, copy constructor assignment operator and helpers
36 //////////
37
38 // public
39
40 fail::fail() : inherited(TINFO_fail)
41 {
42     debugmsg("fail default constructor",LOGLEVEL_CONSTRUCT);
43 }
44
45 fail::~fail()
46 {
47     debugmsg("fail destructor",LOGLEVEL_DESTRUCT);
48     destroy(0);
49 }
50
51 fail::fail(fail const & other)
52 {
53     debugmsg("fail copy constructor",LOGLEVEL_CONSTRUCT);
54     copy(other);
55 }
56
57 fail const & fail::operator=(fail const & other)
58 {
59     debugmsg("fail operator=",LOGLEVEL_ASSIGNMENT);
60     if (this != &other) {
61         destroy(1);
62         copy(other);
63     }
64     return *this;
65 }
66
67 // protected
68
69 void fail::copy(fail const & other)
70 {
71     inherited::copy(other);
72 }
73
74 void fail::destroy(bool call_parent)
75 {
76     if (call_parent) inherited::destroy(call_parent);
77 }
78
79
80 //////////
81 // other constructors
82 //////////
83
84 // none
85
86 //////////
87 // archiving
88 //////////
89
90 /** Construct object from archive_node. */
91 fail::fail(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
92 {
93     debugmsg("fail constructor from archive_node", LOGLEVEL_CONSTRUCT);
94 }
95
96 /** Unarchive the object. */
97 ex fail::unarchive(const archive_node &n, const lst &sym_lst)
98 {
99     return (new fail(n, sym_lst))->setflag(status_flags::dynallocated);
100 }
101
102 /** Archive the object. */
103 void fail::archive(archive_node &n) const
104 {
105     inherited::archive(n);
106 }
107
108 //////////
109 // functions overriding virtual functions from bases classes
110 //////////
111
112 // public
113
114 basic * fail::duplicate() const
115 {
116     debugmsg("fail duplicate",LOGLEVEL_DUPLICATE);
117     return new fail(*this);
118 }
119
120 void fail::print(ostream & os, unsigned upper_precedence) const
121 {
122     debugmsg("fail print",LOGLEVEL_PRINT);
123     os << "FAIL";
124 }
125
126 void fail::printraw(ostream & os) const
127 {
128     debugmsg("fail printraw",LOGLEVEL_PRINT);
129     os << "FAIL";
130 }
131
132 // protected
133
134 int fail::compare_same_type(basic const & other) const
135 {
136         // two fails are always identical
137     return 0;
138 }
139
140 //////////
141 // new virtual functions which can be overridden by derived classes
142 //////////
143
144 // none
145
146 //////////
147 // non-virtual functions in this class
148 //////////
149
150 // none
151
152 //////////
153 // static member variables
154 //////////
155
156 // none
157
158 //////////
159 // global constants
160 //////////
161
162 const fail some_fail;
163 type_info const & typeid_fail=typeid(some_fail);
164
165 #ifndef NO_GINAC_NAMESPACE
166 } // namespace GiNaC
167 #endif // ndef NO_GINAC_NAMESPACE