]> www.ginac.de Git - ginac.git/blob - ginac/fail.cpp
- moved the subsections that were marked as 'digression:' to an appendix
[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 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 "debugmsg.h"
26
27 namespace GiNaC {
28
29 //////////
30 // default constructor, destructor, copy constructor assignment operator and helpers
31 //////////
32
33 // public
34
35 fail::fail() : basic(TINFO_fail)
36 {
37     debugmsg("fail default constructor",LOGLEVEL_CONSTRUCT);
38 }
39
40 fail::~fail()
41 {
42     debugmsg("fail destructor",LOGLEVEL_DESTRUCT);
43     destroy(0);
44 }
45
46 fail::fail(fail const & other)
47 {
48     debugmsg("fail copy constructor",LOGLEVEL_CONSTRUCT);
49     copy(other);
50 }
51
52 fail const & fail::operator=(fail const & other)
53 {
54     debugmsg("fail operator=",LOGLEVEL_ASSIGNMENT);
55     if (this != &other) {
56         destroy(1);
57         copy(other);
58     }
59     return *this;
60 }
61
62 // protected
63
64 void fail::copy(fail const & other)
65 {
66     basic::copy(other);
67 }
68
69 void fail::destroy(bool call_parent)
70 {
71     if (call_parent) basic::destroy(call_parent);
72 }
73
74
75 //////////
76 // other constructors
77 //////////
78
79 // none
80
81 //////////
82 // functions overriding virtual functions from bases classes
83 //////////
84
85 // public
86
87 basic * fail::duplicate() const
88 {
89     debugmsg("fail duplicate",LOGLEVEL_DUPLICATE);
90     return new fail(*this);
91 }
92
93 // protected
94
95 int fail::compare_same_type(basic const & other) const
96 {
97         // two fails are always identical
98     return 0;
99 }
100
101 //////////
102 // new virtual functions which can be overridden by derived classes
103 //////////
104
105 // none
106
107 //////////
108 // non-virtual functions in this class
109 //////////
110
111 // none
112
113 //////////
114 // static member variables
115 //////////
116
117 // none
118
119 //////////
120 // global constants
121 //////////
122
123 const fail some_fail;
124 type_info const & typeid_fail=typeid(some_fail);
125
126 } // namespace GiNaC