Jpp
software
JLang
JThrow.hh
Go to the documentation of this file.
1
#ifndef __JLANG__JTHROW__
2
#define __JLANG__JTHROW__
3
4
#include <iostream>
5
6
#include "
JLang/JException.hh
"
7
8
9
/**
10
* \file
11
*
12
* Exception handling.
13
* \author mdejong
14
*/
15
namespace
JLANG
{}
16
namespace
JPP
{
using namespace
JLANG
; }
17
18
namespace
JLANG
{
19
20
/**
21
* Auxiliary base class for controling the throwing of exceptions.
22
* The template class refers to the throwing object.
23
*/
24
template
<
class
T>
25
class
JThrow
{
26
protected
:
27
28
static
bool
do_throw
;
//!< throw option
29
30
31
public
:
32
/**
33
* Enable/disable throw option.
34
*
35
* \param option true enable; false disable
36
*/
37
static
void
Throw
(
const
bool
option)
38
{
39
do_throw
= option;
40
}
41
42
43
/**
44
* Throw exception or return error.
45
*
46
* \param error exception
47
* \param value return code
48
* \return return code
49
*/
50
static
int
Throw
(
const
JException
& error,
const
int
value = -1)
51
{
52
using namespace
std
;
53
54
if
(
do_throw
) {
55
throw
error;
56
}
57
58
cerr << error.
what
() << endl;
59
60
return
value;
61
}
62
};
63
64
65
/**
66
* Set default throw option to <tt>true</tt>.
67
*/
68
template
<
class
T>
69
bool
JThrow<T>::do_throw
=
true
;
70
}
71
72
#endif
JException.hh
JLANG::JThrow
Auxiliary base class for controling the throwing of exceptions.
Definition:
JThrow.hh:25
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition:
JAAnetToolkit.hh:37
JLANG::JThrow::Throw
static int Throw(const JException &error, const int value=-1)
Throw exception or return error.
Definition:
JThrow.hh:50
JLANG::JThrow::Throw
static void Throw(const bool option)
Enable/disable throw option.
Definition:
JThrow.hh:37
std
Definition:
jaanetDictionary.h:36
JLANG::JThrow::do_throw
static bool do_throw
throw option
Definition:
JThrow.hh:28
JLANG::JException::what
virtual const char * what() const
Get error message.
Definition:
JException.hh:65
JLANG
Auxiliary classes and methods for language specific functionality.
Definition:
JAbstractClass.hh:10
JLANG::JException
General exception.
Definition:
JException.hh:40
Generated by
1.8.16