1 |
|
2 |
/* $Id$ */ |
3 |
|
4 |
/******************************************************* |
5 |
* |
6 |
* Copyright 2003-2007 by ACceSS MNRF |
7 |
* Copyright 2007 by University of Queensland |
8 |
* |
9 |
* http://esscc.uq.edu.au |
10 |
* Primary Business: Queensland, Australia |
11 |
* Licensed under the Open Software License version 3.0 |
12 |
* http://www.opensource.org/licenses/osl-3.0.php |
13 |
* |
14 |
*******************************************************/ |
15 |
|
16 |
#if !defined escript_EsysAssertException_20040330_H |
17 |
#define escript_EsysAssertException_20040330_H |
18 |
#include "system_dep.h" |
19 |
|
20 |
#include "EsysException.h" |
21 |
|
22 |
namespace esysUtils { |
23 |
|
24 |
/** |
25 |
\brief |
26 |
EsysAssertException exception class. |
27 |
|
28 |
Description: |
29 |
EsysAssertException exception class. |
30 |
The class provides a public function returning the exception name. |
31 |
*/ |
32 |
class EsysAssertException : public EsysException |
33 |
{ |
34 |
|
35 |
protected: |
36 |
|
37 |
typedef EsysException Parent; |
38 |
|
39 |
public: |
40 |
/** |
41 |
\brief |
42 |
Default constructor for the exception. |
43 |
*/ |
44 |
inline |
45 |
EsysAssertException() : Parent() { updateMessage();} |
46 |
/** |
47 |
\brief |
48 |
Constructor for the exception. |
49 |
*/ |
50 |
inline |
51 |
EsysAssertException(const char *cstr) : Parent(cstr) { updateMessage();} |
52 |
/** |
53 |
\brief |
54 |
Constructor for the exception. |
55 |
*/ |
56 |
inline |
57 |
EsysAssertException(const std::string &str) : |
58 |
Parent(str) { updateMessage();} |
59 |
/** |
60 |
\brief |
61 |
Copy Constructor for the exception. |
62 |
*/ |
63 |
inline |
64 |
EsysAssertException(const EsysAssertException &other) : Parent(other) |
65 |
{ |
66 |
updateMessage(); |
67 |
} |
68 |
|
69 |
|
70 |
/// Destructor |
71 |
ESYSUTILS_DLL_API |
72 |
virtual ~EsysAssertException() THROW_ANY {} |
73 |
|
74 |
/** |
75 |
\brief |
76 |
Returns the name of the exception. |
77 |
*/ |
78 |
ESYSUTILS_DLL_API |
79 |
virtual const std::string & exceptionName() const; |
80 |
|
81 |
/** |
82 |
\brief |
83 |
Builds a formatted message and throws an EsysAssertException. |
84 |
*/ |
85 |
ESYSUTILS_DLL_API |
86 |
static void assertFailure (const std::string& assertion, |
87 |
const std::string& date, |
88 |
const std::string& file, |
89 |
int line, const std::string& errDesc); |
90 |
private: |
91 |
|
92 |
// |
93 |
// the exception name is immutable and class-wide. |
94 |
// Inheritor note; you need one of these too. |
95 |
// and an overloaded exceptionName() in your .cpp implementation file. |
96 |
static const std::string exceptionNameValue; |
97 |
}; |
98 |
|
99 |
} // end of namespace |
100 |
|
101 |
#endif |