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 
19 namespace ROOT {
20 namespace Math {
21 
22 class GenVector_exception;
23 inline void Throw(GenVector_exception &e);
24 namespace GenVector {
25 inline 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.
36 class GenVector_exception : public std::runtime_error {
37 public:
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 
56 private:
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 
78 namespace GenVector {
79 /// function throwing exception, by creating internally a GenVector_exception only when needed
80 inline 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
e
#define e(i)
Definition: RSha256.hxx:121
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
ROOT::Math::GenVector_exception::Throw
friend void Throw(GenVector_exception &)
throw explicity GenVector exceptions
Definition: GenVector_exception.h:72
ROOT::Math::GenVector_exception
Definition: GenVector_exception.h:36
ROOT::Math::GenVector::Throw
void Throw(const char *)
function throwing exception, by creating internally a GenVector_exception only when needed
Definition: GenVector_exception.h:80
ROOT::Math::GenVector_exception::EnableThrow
static bool EnableThrow()
Definition: GenVector_exception.h:43
ROOT::Math::GenVector_exception::IsOn
static bool & IsOn()
Definition: GenVector_exception.h:60
ROOT::Math::Throw
void Throw(GenVector_exception &e)
throw explicity GenVector exceptions
Definition: GenVector_exception.h:72
ROOT::Math::GenVector_exception::GenVector_exception
GenVector_exception(const std::string &s)
Definition: GenVector_exception.h:38
ROOT::Math::GenVector_exception::DisableThrow
static bool DisableThrow()
Definition: GenVector_exception.h:49
ROOT
VSD Structures.
Definition: StringConv.hxx:21
Math