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