thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Utilities
Throw.h
1
// -*- C++ -*-
2
//
3
// Throw.h is a part of ThePEG - Toolkit for HEP Event Generation
4
// Copyright (C) 1999-2019 Leif Lonnblad
5
//
6
// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8
//
9
#ifndef ThePEG_Throw_H
10
#define ThePEG_Throw_H
11
// This is the declaration of the Throw class.
12
13
#include "
ThePEG/Config/ThePEG.h
"
14
#include "ThePEG/Utilities/Exception.h"
15
#include "ThePEG/Repository/CurrentGenerator.h"
16
#include "ThePEG/Repository/Repository.h"
17
18
19
namespace
ThePEG
{
43
template
<
typename
Ex>
44
struct
Throw
{
45
public
:
49
Throw
():
ex
(Ex()),
handled
(false) {}
50
54
template
<
typename
T>
Throw
&
operator<<
(
const
T & t) {
55
ex
<< t;
56
return
*
this
;
57
}
58
59
private
:
65
void
writeWarning
() {
66
if
(
CurrentGenerator::isVoid
() ) {
67
Repository::clog
() <<
ex
.message() << endl;
68
ex
.handle();
69
}
else
{
70
CurrentGenerator::current
().
logWarning
(
ex
);
71
}
72
}
73
74
public
:
81
void
operator<<
(
Exception::Severity
sev) {
82
handled
=
true
;
83
ex
<< sev;
84
if
( sev !=
Exception::warning
&& sev !=
Exception::info
) {
85
throw
ex
;
86
}
else
{
87
writeWarning
();
88
}
89
}
90
94
~Throw
() {
95
if
( !
handled
) {
96
ex
<<
Exception::warning
;
97
writeWarning
();
98
}
99
}
100
104
Ex
ex
;
105
110
bool
handled
;
111
};
112
113
114
}
115
116
#endif
/* ThePEG_Throw_H */
ThePEG.h
This is the main config header file for ThePEG.
ThePEG::BaseRepository::clog
static ostream & clog()
Get the standard log stream.
Definition:
BaseRepository.h:476
ThePEG::CurrentGenerator::isVoid
static bool isVoid()
Returns true if there is no currently chosen EventGenerator object.
Definition:
CurrentGenerator.h:73
ThePEG::CurrentGenerator::current
static EventGenerator & current()
Return a reference to the currently chosen EventGenerator object.
Definition:
CurrentGenerator.h:80
ThePEG::EventGenerator::logWarning
void logWarning(const Exception &)
Log a given exception.
ThePEG::Exception::Severity
Severity
The levels of severity.
Definition:
Exception.h:51
ThePEG::Exception::warning
@ warning
Possibly severe, (the user should be warned).
Definition:
Exception.h:55
ThePEG::Exception::info
@ info
Not severe (but the user should be informed).
Definition:
Exception.h:53
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
ThePEG::Throw
Helper function to make it easier to throw exceptions.
Definition:
Throw.h:44
ThePEG::Throw::operator<<
void operator<<(Exception::Severity sev)
Specify the Exception::Severity of the exception.
Definition:
Throw.h:81
ThePEG::Throw::ex
Ex ex
The ExceptionObject to be thrown.
Definition:
Throw.h:104
ThePEG::Throw::handled
bool handled
If true, the exception has been handled and should not be thrown in the destructor.
Definition:
Throw.h:110
ThePEG::Throw::~Throw
~Throw()
The destructor will throw the exception if it has not been handled.
Definition:
Throw.h:94
ThePEG::Throw::Throw
Throw()
Standard constructor creating an internal Exception object.
Definition:
Throw.h:49
ThePEG::Throw::operator<<
Throw & operator<<(const T &t)
Add information to the current Exception object.
Definition:
Throw.h:54
ThePEG::Throw::writeWarning
void writeWarning()
Write warning messages to the current EventGenerator.
Definition:
Throw.h:65
Generated on Thu Jun 20 2024 14:47:02 for ThePEG by
1.9.6