Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include <string>
33
34#ifndef ROOT_MATH_LOG
35#define ROOT_MATH_OS std::cerr
36#else
37#define ROOT_MATH_LOG
38#endif
39
40// giving a location + string
41
42#define MATH_INFO_MSG(loc,str) \
43 ROOT_MATH_OS << "Info in ROOT::Math::" << loc << ">: " << str \
44 << std::endl;
45#define MATH_WARN_MSG(loc,str) \
46 ROOT_MATH_OS << "Warning in ROOT::Math::" << loc << ">: " << str \
47 << std::endl;
48#define MATH_ERROR_MSG(loc,str) \
49 ROOT_MATH_OS << "Error in ROOT::Math::" << loc << ">: " << str \
50 << std::endl;
51
52// giving location + a value
53
54# define MATH_INFO_VAL(loc,x) \
55 ROOT_MATH_OS << "Info in <ROOT::Math::" << loc << ">: " << #x << " = " << (x) << std::endl;
56# define MATH_WARN_VAL(loc,x) \
57 ROOT_MATH_OS << "Warning in ROOT::Math::" << loc << ">: " << #x << " = " << (x) << std::endl;
58# define MATH_ERROR_VAL(loc,x) \
59 ROOT_MATH_OS << "Error in ROOT::Math::" << loc << ">: " << #x << " = " << (x) << std::endl;
60
61// giving a location + string + value
62
63# define MATH_INFO_MSGVAL(loc,str,x) \
64 ROOT_MATH_OS << "Info in <ROOT::Math::" << loc << ">: " << str << "; " << #x << " = " << (x) << std::endl;
65# define MATH_WARN_MSGVAL(loc,str,x) \
66 ROOT_MATH_OS << "Warning in ROOT::Math::" << loc << ">: " << str << "; " << #x << " = " << (x) << std::endl;
67# define MATH_ERROR_MSGVAL(loc,str,x) \
68 ROOT_MATH_OS << "Error in ROOT::Math::" << loc << ">: " << str << "; " << #x << " = " << (x) << std::endl;
69
70
71#else
72// use ROOT error reporting system
73
74#include "TError.h"
75#include "Math/Util.h"
76
77#define MATH_INFO_MSG(loc,str) \
78 {std::string sl = "ROOT::Math::" + std::string(loc); \
79 ::Info(sl.c_str(),"%s",str);}
80#define MATH_WARN_MSG(loc,str) \
81 {std::string sl = "ROOT::Math::" + std::string(loc); \
82 ::Warning(sl.c_str(),"%s",str);}
83#define MATH_ERROR_MSG(loc,str) \
84 {std::string sl = "ROOT::Math::" + std::string(loc); \
85 ::Error(sl.c_str(),"%s",str);}
86
87# define MATH_INFO_VAL(loc,x) \
88 {std::string sl = "ROOT::Math::" + std::string(loc); \
89 std::string str = std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
90 ::Info(sl.c_str(),"%s",str.c_str() );}
91# define MATH_WARN_VAL(loc,x) \
92 {std::string sl = "ROOT::Math::" + std::string(loc); \
93 std::string str = std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
94 ::Warning(sl.c_str(),"%s",str.c_str() );}
95# define MATH_ERROR_VAL(loc,x) \
96 {std::string sl = "ROOT::Math::" + std::string(loc); \
97 std::string str = std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
98 ::Error(sl.c_str(),"%s",str.c_str() );}
99
100
101# define MATH_INFO_MSGVAL(loc,txt,x) \
102 {std::string sl = "ROOT::Math::" + std::string(loc); \
103 std::string str = std::string(txt) + std::string("; ") + std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
104 ::Info(sl.c_str(),"%s",str.c_str() );}
105# define MATH_WARN_MSGVAL(loc,txt,x) \
106 {std::string sl = "ROOT::Math::" + std::string(loc); \
107 std::string str = std::string(txt) + std::string("; ") + std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
108 ::Warning(sl.c_str(),"%s",str.c_str() );}
109# define MATH_ERROR_MSGVAL(loc,txt,x) \
110 {std::string sl = "ROOT::Math::" + std::string(loc); \
111 std::string str = std::string(txt) + std::string("; ") + std::string(#x) + std::string(" = ") + ::ROOT::Math::Util::ToString(x); \
112 ::Error(sl.c_str(),"%s",str.c_str() );}
113
114
115
116#endif
117
118
119#endif // ROOT_MATH_Error