Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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);
24inline void GenVector_Throw(const char *);
25
26// ----------------------------------------------------------------------
27// GenVector_exception class definition
28//
29// This class needs to be entirely contained in this header, otherwise
30// the interactive usage of entities such as ROOT::Math::PtEtaPhiMVector
31// is not possible because of missing symbols.
32// This is due to the fact that the Throw function is used in the inline
33// code bu this function is implemented in the Genvector library.
34class GenVector_exception : public std::runtime_error {
35public:
36 GenVector_exception(const std::string &s) : runtime_error(s) {}
37
38 // Compiler-generated copy ctor, copy assignment, dtor are fine
39 // Inherited what() from runtime_error is fine
40
41 static bool EnableThrow()
42 {
43 bool tmp = GenVector_exception::IsOn();
44 IsOn() = true;
45 return tmp;
46 }
47 static bool DisableThrow()
48 {
49 bool tmp = GenVector_exception::IsOn();
50 IsOn() = false;
51 return tmp;
52 }
53
54private:
55 friend void Throw(GenVector_exception &);
56 friend void GenVector_Throw(const char *);
57
58 static bool &IsOn()
59 {
60 static bool isOn = false;
61 return isOn;
62 };
63
64}; // GenVector_exception
65
66// ----------------------------------------------------------------------
67// Epilog
68
69/// throw explicitly GenVector exceptions
71{
73 throw e;
74}
75
76/// function throwing exception, by creating internally a GenVector_exception only when needed
77inline void GenVector_Throw(const char *s)
78{
80 return;
82 throw e;
83}
84
85} // namespace Math
86} // namespace ROOT
87
88#endif // GENVECTOR_EXCEPTION_H
#define e(i)
Definition RSha256.hxx:103
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
friend void Throw(GenVector_exception &)
throw explicitly GenVector exceptions
GenVector_exception(const std::string &s)
friend void GenVector_Throw(const char *)
function throwing exception, by creating internally a GenVector_exception only when needed
Namespace for new Math classes and functions.
void GenVector_Throw(const char *)
function throwing exception, by creating internally a GenVector_exception only when needed
void Throw(GenVector_exception &e)
throw explicitly GenVector exceptions
Namespace for new ROOT classes and functions.