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