Logo ROOT   6.19/01
Reference Guide
Error.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Authors: L. Moneta
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2007 LCG ROOT Math team, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
10 #ifndef ROOT_Math_Error
11 #define ROOT_Math_Error
12 
13 #ifdef DEBUG
14 #ifndef WARNINGMSG
15 #define WARNINGMSG
16 #endif
17 #endif
18 
19 
20 
21 /**
22  Pre-processor macro to report messages
23  which can be configured to use ROOT error or
24  simply an std::iostream in case of stan-alone builds
25 */
26 
27 #ifdef MATHCORE_STANDALONE
28 
29 // use std::iostream instead of ROOT
30 
31 #include <iostream>
32 
33 #ifndef ROOT_MATH_LOG
34 #define ROOT_MATH_OS std::cerr
35 #else
36 #define ROOT_MATH_LOG
37 #endif
38 
39 // giving a location + string
40 
41 #define MATH_INFO_MSG(loc,str) \
42  ROOT_MATH_OS << "Info in ROOT::Math::" << loc << ">: " << str \
43  << std::endl;
44 #define MATH_WARN_MSG(loc,str) \
45  ROOT_MATH_OS << "Warning in ROOT::Math::" << loc << ">: " << str \
46  << std::endl;
47 #define MATH_ERROR_MSG(loc,str) \
48  ROOT_MATH_OS << "Error in ROOT::Math::" << loc << ">: " << str \
49  << std::endl;
50 
51 // giving location + a value
52 
53 # define MATH_INFO_VAL(loc,x) \
54  ROOT_MATH_OS << "Info in <ROOT::Math::" << loc << ">: " << #x << " = " << (x) << std::endl;
55 # define MATH_WARN_VAL(loc,x) \
56  ROOT_MATH_OS << "Warning in ROOT::Math::" << loc << ">: " << #x << " = " << (x) << std::endl;
57 # define MATH_ERROR_VAL(loc,x) \
58  ROOT_MATH_OS << "Error in ROOT::Math::" << loc << ">: " << #x << " = " << (x) << std::endl;
59 
60 // giving a location + string + value
61 
62 # define MATH_INFO_MSGVAL(loc,str,x) \
63  ROOT_MATH_OS << "Info in <ROOT::Math::" << loc << ">: " << str << "; " << #x << " = " << (x) << std::endl;
64 # define MATH_WARN_MSGVAL(loc,str,x) \
65  ROOT_MATH_OS << "Warning in ROOT::Math::" << loc << ">: " << str << "; " << #x << " = " << (x) << std::endl;
66 # define MATH_ERROR_MSGVAL(loc,str,x) \
67  ROOT_MATH_OS << "Error in ROOT::Math::" << loc << ">: " << str << "; " << #x << " = " << (x) << std::endl;
68 
69 
70 #else
71 // use ROOT error reporting system
72 
73 #include "TError.h"
74 #include "Math/Util.h"
75 
76 #define MATH_INFO_MSG(loc,str) \
77  {std::string sl = "ROOT::Math::" + std::string(loc); \
78  ::Info(sl.c_str(),"%s",str);}
79 #define MATH_WARN_MSG(loc,str) \
80  {std::string sl = "ROOT::Math::" + std::string(loc); \
81  ::Warning(sl.c_str(),"%s",str);}
82 #define MATH_ERROR_MSG(loc,str) \
83  {std::string sl = "ROOT::Math::" + std::string(loc); \
84  ::Error(sl.c_str(),"%s",str);}
85 
86 # define MATH_INFO_VAL(loc,x) \
87  {std::string sl = "ROOT::Math::" + std::string(loc); \
88  std::string str = std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
89  ::Info(sl.c_str(),"%s",str.c_str() );}
90 # define MATH_WARN_VAL(loc,x) \
91  {std::string sl = "ROOT::Math::" + std::string(loc); \
92  std::string str = std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
93  ::Warning(sl.c_str(),"%s",str.c_str() );}
94 # define MATH_ERROR_VAL(loc,x) \
95  {std::string sl = "ROOT::Math::" + std::string(loc); \
96  std::string str = std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
97  ::Error(sl.c_str(),"%s",str.c_str() );}
98 
99 
100 # define MATH_INFO_MSGVAL(loc,txt,x) \
101  {std::string sl = "ROOT::Math::" + std::string(loc); \
102  std::string str = std::string(txt) + std::string("; ") + std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
103  ::Info(sl.c_str(),"%s",str.c_str() );}
104 # define MATH_WARN_MSGVAL(loc,txt,x) \
105  {std::string sl = "ROOT::Math::" + std::string(loc); \
106  std::string str = std::string(txt) + std::string("; ") + std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
107  ::Warning(sl.c_str(),"%s",str.c_str() );}
108 # define MATH_ERROR_MSGVAL(loc,txt,x) \
109  {std::string sl = "ROOT::Math::" + std::string(loc); \
110  std::string str = std::string(txt) + std::string("; ") + std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
111  ::Error(sl.c_str(),"%s",str.c_str() );}
112 
113 
114 
115 #endif
116 
117 
118 #endif // ROOT_MATH_Error