Logo ROOT  
Reference Guide
GenVector_exception.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Authors: W. Brown, M. Fischler, L. Moneta 2005
3
4#ifndef ROOT_Math_GenVector_GenVector_exception
5#define ROOT_Math_GenVector_GenVector_exception 1
6
7// ======================================================================
8// $Id $
9//
10// Define the exception type used throughout this package.
11// ======================================================================
12
13// ----------------------------------------------------------------------
14// Prolog
15
16#include <stdexcept>
17#include <string>
18
19namespace ROOT {
20namespace Math {
21
22class GenVector_exception;
23inline void Throw(GenVector_exception &e);
24namespace GenVector {
25inline void Throw(const char *);
26}
27
28// ----------------------------------------------------------------------
29// GenVector_exception class definition
30//
31// This class needs to be entirely contained in this header, otherwise
32// the interactive usage of entities such as ROOT::Math::PtEtaPhiMVector
33// is not possible because of missing symbols.
34// This is due to the fact that the Throw function is used in the inline
35// code bu this function is implemented in the Genvector library.
36class GenVector_exception : public std::runtime_error {
37public:
38 GenVector_exception(const std::string &s) : runtime_error(s) {}
39
40 // Compiler-generated copy ctor, copy assignment, dtor are fine
41 // Inherited what() from runtime_error is fine
42
43 static bool EnableThrow()
44 {
45 bool tmp = GenVector_exception::IsOn();
46 IsOn() = true;
47 return tmp;
48 }
49 static bool DisableThrow()
50 {
51 bool tmp = GenVector_exception::IsOn();
52 IsOn() = false;
53 return tmp;
54 }
55
56private:
57 friend void Throw(GenVector_exception &);
58 friend void GenVector::Throw(const char *);
59
60 static bool &IsOn()
61 {
62 static bool isOn = false;
63 return isOn;
64 };
65
66}; // GenVector_exception
67
68// ----------------------------------------------------------------------
69// Epilog
70
71/// throw explicity GenVector exceptions
73{
75 throw e;
76}
77
78namespace GenVector {
79/// function throwing exception, by creating internally a GenVector_exception only when needed
80inline void Throw(const char *s)
81{
83 return;
85 throw e;
86}
87} // namespace GenVector
88
89} // namespace Math
90} // namespace ROOT
91
92#endif // GENVECTOR_EXCEPTION_H
#define e(i)
Definition: RSha256.hxx:103
friend void Throw(GenVector_exception &)
throw explicity GenVector exceptions
GenVector_exception(const std::string &s)
Namespace for new Math classes and functions.
void Throw(const char *)
function throwing exception, by creating internally a GenVector_exception only when needed
void Throw(GenVector_exception &e)
throw explicity GenVector exceptions
VSD Structures.
Definition: StringConv.hxx:21
static constexpr double s