CoreLinux++  0.4.32
Exception.hpp
1 #if !defined (__EXCEPTION_HPP)
2 #define __EXCEPTION_HPP
3 
4 /*
5  CoreLinux++
6  Copyright (C) 1999 CoreLinux Consortium
7 
8  The CoreLinux++ Library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12 
13  The CoreLinux++ Library Library is distributed in the hope that it will
14  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public
19  License along with the GNU C Library; see the file COPYING.LIB. If not,
20  write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA 02111-1307, USA.
22 */
23 
24 #if !defined IN_COMMON_HPP
25  #error except.hpp is included by common.hpp only.
26 #endif
27 
28 #include <string>
29 //
30 // Base exception class
31 //
32 
33 
34 namespace corelinux
35 {
36 
37 
38  DECLARE_CLASS( Exception );
39 
40  // Define a reference to line number
41 
42  DECLARE_TYPE( Dword, LineNum );
43 
44 
51  class Exception
52  {
53 
54  public:
55 
56 
58 
59  enum Severity
60  {
61  CONTINUABLE = 1,
66  };
67 
68 
78  Exception
79  (
80  CharCptr why,
81  CharCptr file,
82  LineNum line,
83  Severity severity = Exception::CONTINUABLE,
84  bool outOfMemory = false
85  );
86 
92  Exception( ExceptionCref crOther );
93 
95 
96  virtual ~Exception(void);
97 
98  //
99  // Operator overloads
100  //
101 
109 
116  bool operator==( ExceptionCref otherRef );
117 
118  //
119  // Accessor methods
120  //
121 
128  const std::string & getFile( void ) const;
129 
136  LineNumCref getLine( void ) const;
137 
143  const std::string & getWhy( void ) const;
144 
150  const Severity & getSeverity( void ) const;
151 
157  const std::string & getUnwind( void ) const;
158 
164  bool isOutOfMemory( void ) const
165  { return theOutOfMemoryFlag;}
166 
167  //
168  // Mutator methods
169  //
170 
177  void addUnwindInfo( CharCptr unwindInfo );
178 
180 
181  void setThreadFatalSeverity( void );
182 
184 
185  void setProcessFatalSeverity( void );
186 
193  void setThreadTerminateSeverity( void );
194 
200  void setProcessTerminateSeverity( void );
201 
202  protected:
203 
209  Exception( void );
210 
215  Exception
216  (
217  CharCptr file,
218  LineNum line,
219  Severity severity = Exception::CONTINUABLE,
220  bool outOfMemory = false
221  );
222 
224 
225  void setWhy( const std::string & );
226 
228 
229  void setWhy( CharCptr );
230 
231  private:
232 
233 
234  private:
235 
236  // Reason why the exception is being thrown.
237 
238  std::string theReason;
239 
240  // File that threw the exception.
241 
242  std::string theFile;
243 
244  // Severity of the exception.
245 
246  Severity theSeverity;
247 
248  // Unwind information added as exception is unwound from
249  // stack.
250 
251  std::string theUnwindInfo;
252 
253  // Line number in the file throwing the exception.
254 
255  LineNum theLine;
256 
257  // Flag that indicates if there is a low memory situation.
258 
259  bool theOutOfMemoryFlag;
260  };
261 
262 }
263 
264 
265 #endif // !defined __EXCEPTION_HPP
266 
267 /*
268  Common rcs information do not modify
269  $Author: frankc $
270  $Revision: 1.2 $
271  $Date: 2000/07/28 01:37:09 $
272  $Locker: $
273 */
274 
275 
Exception may prove to be thread fatal.
Definition: Exception.hpp:63
LineNumCref getLine(void) const
Accessor.
Definition: Exception.cpp:144
const std::string & getWhy(void) const
Accessor.
Definition: Exception.cpp:149
bool operator==(ExceptionCref otherRef)
Comparisson operator overload.
Definition: Exception.cpp:134
const std::string & getUnwind(void) const
Accessor.
Definition: Exception.cpp:160
virtual ~Exception(void)
Virtual Destructor.
Definition: Exception.cpp:102
void addUnwindInfo(CharCptr unwindInfo)
Append unwind information to the Exception.
Definition: Exception.cpp:165
void setThreadFatalSeverity(void)
Change the severity to Severity::THREADFATAL.
Definition: Exception.cpp:178
const std::string & getFile(void) const
Accessor.
Definition: Exception.cpp:139
System should kill thread.
Definition: Exception.hpp:65
void setThreadTerminateSeverity(void)
Change the severity to Severity::THREADTERMINATE.
Definition: Exception.cpp:203
Exception(void)
Exceptions must have a reason.
Definition: Exception.cpp:93
Forward reference the various common classes.
Definition: AbstractAllocator.hpp:32
void setWhy(const std::string &)
Changes the exception reason.
Definition: Exception.cpp:227
Severity
Exception Severity States.
Definition: Exception.hpp:59
ExceptionRef operator=(ExceptionCref otherRef)
Assignment operator overload.
Definition: Exception.cpp:111
Exception is the base exception class used in the CoreLinux++ libraries.
Definition: Exception.hpp:51
bool isOutOfMemory(void) const
Accessor.
Definition: Exception.hpp:164
Exception may prove to be process fatal.
Definition: Exception.hpp:64
const Severity & getSeverity(void) const
Accessor.
Definition: Exception.cpp:154
void setProcessTerminateSeverity(void)
Change the severity to Severity::PROCESSTERMINATE.
Definition: Exception.cpp:215
System can continue processing.
Definition: Exception.hpp:62
void setProcessFatalSeverity(void)
Change the severity to Severity::PROCESSFATAL.
Definition: Exception.cpp:191

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium