otsdaq  v1_01_04
 All Classes Namespaces Functions
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 __COUT_HDR__ __FILE__ << " : " << __PRETTY_FUNCTION__ << " [" << __LINE__ << "]\t"
16 #define __COUT_HDR_FL__ __SHORTFILE__ << " [" << std::dec << __LINE__ << "]\t"
17 #define __COUT_HDR_FP__ __SHORTFILE__ << " : " << __PRETTY_FUNCTION__ << "\t"
18 #define __COUT_HDR_PL__ __PRETTY_FUNCTION__ << " [" << std::dec << __LINE__ << "]\t"
19 #define __COUT_HDR_F__ __SHORTFILE__ << "\t"
20 #define __COUT_HDR_L__ std::dec << __LINE__ << "\t"
21 #define __COUT_HDR_P__ __PRETTY_FUNCTION__ << "\t"
22 #define __COUT_HDR__ __COUT_HDR_FL__
23 
24 
25 #define __COUT_TYPE__(X) std::cout << QUOTE(X) << ":" << __MF_SUBJECT__ << ":"
26 
27 #define __COUT_ERR__ __COUT_TYPE__(LogError) << __COUT_HDR__
28 #define __COUT_WARN__ __COUT_TYPE__(LogWarning) << __COUT_HDR__
29 #define __COUT_INFO__ __COUT_TYPE__(LogInfo) << __COUT_HDR__
30 #define __COUT__ __COUT_TYPE__(LogDebug) << __COUT_HDR__
31 
32 #define __E__ std::endl
33 
37 
38 #define __MF_SUBJECT__ "ots" //default subject.. others can #undef and re-#define
39 //Note: to turn off MF everywhere, just replace with std::cout here at __MF_TYPE__(X)!
40 
41 #define Q(X) #X
42 #define QUOTE(X) Q(X)
43 //#define __MF_TYPE__(X) FIXME ?? how to do this ...(getenv("OTSDAQ_USING_MF")=="1"? mf::X (__MF_SUBJECT__) : std::cout << QUOTE(X) << ":" << __MF_SUBJECT__ << ":")
44 #define __MF_TYPE__(X) mf::X (__MF_SUBJECT__)
45 
46 
47 
48 #define __MF_HDR__ __COUT_HDR_FL__
49 #define __MOUT_ERR__ __MF_TYPE__(LogError) << __MF_HDR__
50 #define __MOUT_WARN__ __MF_TYPE__(LogWarning) << __MF_HDR__
51 #define __MOUT_INFO__ __MF_TYPE__(LogInfo) << __MF_HDR__
52 #define __MOUT__ __MF_TYPE__(LogDebug) << __MF_HDR__
53 
54 
55 
56 #define __SS__ std::stringstream ss; ss << __MF_HDR__
57 
59 
60 
61 
62 
63 
64 //========================================================================================================================
65 //const_cast away the const
66 // so that otsdaq is compatible with slf6 and slf7 versions of xdaq
67 // where they changed to const xdaq::ApplicationDescriptor* in slf7
68 #ifdef XDAQ_NOCONST
69 #define XDAQ_CONST_CALL
70 #else
71 #define XDAQ_CONST_CALL const
72 #endif
73 //========================================================================================================================
74 
75 
76 
77 
78 #endif