otsdaq  v2_00_00
CoutHeaderMacros.h
1 #ifndef _ots_Utilities_Macro_h_
2 #define _ots_Utilities_Macro_h_
3 
4 
5 #include <string.h> //for strstr
6 #include <iostream> //for cout
7 #include <sstream> //for stringstream
8 
9 //take filename only after srcs/ (this gives by repo name)
10 #define __SHORTFILE__ (strstr(&__FILE__[0], "/srcs/") ? strstr(&__FILE__[0], "/srcs/") + 6 : __FILE__)
11 
12 //take only file name
13 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
14 
15 #define __E__ std::endl
16 
17 //#define __COUT_HDR__ __FILE__ << " : " << __PRETTY_FUNCTION__ << " [" << __LINE__ << "]\t"
18 #define __COUT_HDR_FL__ __SHORTFILE__ << " [" << std::dec << __LINE__ << "]\t"
19 #define __COUT_HDR_FP__ __SHORTFILE__ << " : " << __PRETTY_FUNCTION__ << "\t"
20 #define __COUT_HDR_PL__ __PRETTY_FUNCTION__ << " [" << std::dec << __LINE__ << "]\t"
21 #define __COUT_HDR_F__ __SHORTFILE__ << "\t"
22 #define __COUT_HDR_L__ std::dec << __LINE__ << "\t"
23 #define __COUT_HDR_P__ __PRETTY_FUNCTION__ << "\t"
24 #define __COUT_HDR__ __COUT_HDR_FL__
25 
26 
27 #define __COUT_TYPE__(X) std::cout << QUOTE(X) << ":" << __MF_SUBJECT__ << ":"
28 
29 #define __COUT_ERR__ __COUT_TYPE__(LogError) << __COUT_HDR__
30 #define __COUT_WARN__ __COUT_TYPE__(LogWarning) << __COUT_HDR__
31 #define __COUT_INFO__ __COUT_TYPE__(LogInfo) << __COUT_HDR__
32 #define __COUT__ __COUT_TYPE__(LogDebug) << __COUT_HDR__
33 #define __COUTV__(X) __COUT__ << QUOTE(X) << " = " << X << __E__
34 
35 
39 
40 #define __MF_SUBJECT__ "ots" //default subject.. others can #undef and re-#define
41 //Note: to turn off MF everywhere, just replace with std::cout here at __MF_TYPE__(X)!
42 
43 #define Q(X) #X
44 #define QUOTE(X) Q(X)
45 //#define __MF_TYPE__(X) FIXME ?? how to do this ...(getenv("OTSDAQ_USING_MF")=="1"? mf::X (__MF_SUBJECT__) : std::cout << QUOTE(X) << ":" << __MF_SUBJECT__ << ":")
46 #define __MF_TYPE__(X) mf::X (__MF_SUBJECT__)
47 
48 
49 
50 #define __MF_HDR__ __COUT_HDR_FL__
51 #define __MOUT_ERR__ __MF_TYPE__(LogError) << __MF_HDR__
52 #define __MOUT_WARN__ __MF_TYPE__(LogWarning) << __MF_HDR__
53 #define __MOUT_INFO__ __MF_TYPE__(LogInfo) << __MF_HDR__
54 #define __MOUT__ __MF_TYPE__(LogDebug) << __MF_HDR__
55 #define __MOUTV__(X) __MOUT__ << QUOTE(X) << " = " << X
56 
57 
58 
59 #define __SS__ std::stringstream ss; ss << __MF_HDR__
60 #define __SS_THROW__ __COUT_ERR__ << "\n" << ss.str(); throw std::runtime_error(ss.str())
61 
63 
64 //for configurable objects, add name to subject
65 #define __CFG_COUT_TYPE__(X) std::cout << QUOTE(X) << ":" << __MF_SUBJECT__ << "-" << theConfigurationRecordName_ << ":"
66 #define __CFG_MF_TYPE__(X) mf::X (std::string(__MF_SUBJECT__) + theConfigurationRecordName_)
67 
68 #define __CFG_MOUT_ERR__ __CFG_MF_TYPE__(LogError) << __MF_HDR__
69 #define __CFG_MOUT_WARN__ __CFG_MF_TYPE__(LogWarning) << __MF_HDR__
70 #define __CFG_MOUT_INFO__ __CFG_MF_TYPE__(LogInfo) << __MF_HDR__
71 #define __CFG_MOUT__ __CFG_MF_TYPE__(LogDebug) << __MF_HDR__
72 #define __CFG_MOUTV__(X) __CFG_MOUT__ << QUOTE(X) << " = " << X
73 #define __CFG_COUT_ERR__ __CFG_COUT_TYPE__(LogError) << __COUT_HDR__
74 #define __CFG_COUT_WARN__ __CFG_COUT_TYPE__(LogWarning) << __COUT_HDR__
75 #define __CFG_COUT_INFO__ __CFG_COUT_TYPE__(LogInfo) << __COUT_HDR__
76 #define __CFG_COUT__ __CFG_COUT_TYPE__(LogDebug) << __COUT_HDR__
77 #define __CFG_COUTV__(X) __CFG_COUT__ << QUOTE(X) << " = " << X << __E__
78 
79 //========================================================================================================================
80 //const_cast away the const
81 // so that otsdaq is compatible with slf6 and slf7 versions of xdaq
82 // where they changed to const xdaq::ApplicationDescriptor* in slf7
83 #ifdef XDAQ_NOCONST
84 #define XDAQ_CONST_CALL
85 #else
86 #define XDAQ_CONST_CALL const
87 #endif
88 //========================================================================================================================
89 
90 
91 
92 
93 #endif