$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_Cout_Macros_h_ 00002 #define _ots_Cout_Macros_h_ 00003 00004 #include <string.h> //for strstr (not the same as <string>) 00005 #include <iostream> //for cout 00006 #include <sstream> //for stringstream, std::stringbuf 00007 #if MESSAGEFACILITY_HEX_VERSION > 0x20106 00008 #include "tracemf.h" 00009 #endif 00010 00011 // take filename only after srcs/ (this gives by repo name) 00012 #define __SHORTFILE__ \ 00013 (strstr(&__FILE__[0], "/srcs/") ? strstr(&__FILE__[0], "/srcs/") + 6 : __FILE__) 00014 00015 // take only file name 00016 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) 00017 00018 #define __E__ std::endl 00019 00020 //#define __COUT_HDR__ __FILE__ << " : " << __PRETTY_FUNCTION__ << " [" << __LINE__ << 00021 //"]\t" 00022 00023 #define __COUT_HDR_FL__ __SHORTFILE__ << " [" << std::dec << __LINE__ << "]\t" 00024 #define __COUT_HDR_FP__ __SHORTFILE__ << " : " << __PRETTY_FUNCTION__ << "\t" 00025 #define __COUT_HDR_PL__ __PRETTY_FUNCTION__ << " [" << std::dec << __LINE__ << "]\t" 00026 #define __COUT_HDR_F__ __SHORTFILE__ << "\t" 00027 #define __COUT_HDR_L__ std::dec << __LINE__ << "\t" 00028 #define __COUT_HDR_P__ __PRETTY_FUNCTION__ << "\t" 00029 #define __COUT_HDR__ __COUT_HDR_FL__ 00030 00031 #define __COUT_TYPE__(X) std::cout << QUOTE(X) << ":" << __MF_SUBJECT__ << ":" 00032 00033 #define __COUT_ERR__ __COUT_TYPE__(LogError) << __COUT_HDR__ 00034 #define __COUT_WARN__ __COUT_TYPE__(LogWarning) << __COUT_HDR__ 00035 #define __COUT_INFO__ __COUT_TYPE__(LogInfo) << __COUT_HDR__ 00036 #define __COUT__ __COUT_TYPE__(LogDebug) << __COUT_HDR__ 00037 #define __COUTV__(X) __COUT__ << QUOTE(X) << " = " << X << __E__ 00038 00039 #define __THROW__(X) throw std::runtime_error(X) 00040 00044 00045 #define __MF_SUBJECT__ "ots" // default subject.. others can #undef and re-#define 00046 // Note: to turn off MF everywhere, just replace with std::cout here at __MF_TYPE__(X)! 00047 00048 #define Q(X) #X 00049 #define QUOTE(X) Q(X) 00050 //#define __MF_TYPE__(X) FIXME ?? how to do this ...(getenv("OTSDAQ_USING_MF")=="1"? 00051 // mf::X (__MF_SUBJECT__) : std::cout << QUOTE(X) << ":" << __MF_SUBJECT__ << ":") 00052 00053 #define __MF_HDR__ __COUT_HDR__ 00054 #if MESSAGEFACILITY_HEX_VERSION > 0x20106 00055 #define __MF_TYPE__(X) TLOG(X, __MF_SUBJECT__) // for latest artdaq 00056 #define __MOUT_ERR__ __MF_TYPE__(TLVL_ERROR) << __MF_HDR__ 00057 #define __MOUT_WARN__ __MF_TYPE__(TLVL_WARNING) << __MF_HDR__ 00058 #define __MOUT_INFO__ __MF_TYPE__(TLVL_INFO) << __MF_HDR__ 00059 #define __MOUT__ __MF_TYPE__(TLVL_DEBUG) << __MF_HDR__ 00060 #else 00061 #define __MF_TYPE__(X) mf::X(__MF_SUBJECT__) 00062 #define __MOUT_ERR__ __MF_TYPE__(LogError) << __MF_HDR__ 00063 #define __MOUT_WARN__ __MF_TYPE__(LogWarning) << __MF_HDR__ 00064 #define __MOUT_INFO__ __MF_TYPE__(LogInfo) << __MF_HDR__ 00065 #define __MOUT__ __MF_TYPE__(LogDebug) << __MF_HDR__ 00066 00067 #endif 00068 00069 #define __MOUTV__(X) __MOUT__ << QUOTE(X) << " = " << X << _E__ 00070 00075 #define __MCOUT_ERR__(X) \ 00076 { \ 00077 __MOUT_ERR__ << X; \ 00078 __COUT_ERR__ << X; \ 00079 } 00080 #define __MCOUT_WARN__(X) \ 00081 { \ 00082 __MOUT_WARN__ << X; \ 00083 __COUT_WARN__ << X; \ 00084 } 00085 #define __MCOUT_INFO__(X) \ 00086 { \ 00087 __MOUT_INFO__ << X; \ 00088 __COUT_INFO__ << X; \ 00089 } 00090 #define __MCOUT__(X) \ 00091 { \ 00092 __MOUT__ << X; \ 00093 __COUT__ << X; \ 00094 } 00095 #define __MCOUTV__(X) \ 00096 { \ 00097 __MOUTV__(X); \ 00098 __COUTV__(X); \ 00099 } 00100 00102 00103 #define __SS__ \ 00104 std::stringstream ss; \ 00105 ss << ":" << __MF_SUBJECT__ << ":" << __COUT_HDR__ 00106 #define __SS_THROW__ \ 00107 __COUT_ERR__ << "\n" << ss.str(); \ 00108 throw std::runtime_error(ss.str()) 00109 #define __SS_ONLY_THROW__ throw std::runtime_error(ss.str()) 00110 00112 00113 // for configurable objects, add name to subject 00114 #define __CFG_COUT_TYPE__(X) \ 00115 std::cout << QUOTE(X) << ":" << __MF_SUBJECT__ << ":" << theConfigurationRecordName_ \ 00116 << ":" 00117 #define __CFG_MF_TYPE__(X) \ 00118 mf::X(std::string(__MF_SUBJECT__) + "-" + theConfigurationRecordName_) 00119 00120 #define __CFG_MOUT_ERR__ __CFG_MF_TYPE__(LogError) << __COUT_HDR__ 00121 #define __CFG_MOUT_WARN__ __CFG_MF_TYPE__(LogWarning) << __COUT_HDR__ 00122 #define __CFG_MOUT_INFO__ __CFG_MF_TYPE__(LogInfo) << __COUT_HDR__ 00123 #define __CFG_MOUT__ __CFG_MF_TYPE__(LogDebug) << __COUT_HDR__ 00124 #define __CFG_MOUTV__(X) __CFG_MOUT__ << QUOTE(X) << " = " << X 00125 #define __CFG_COUT_ERR__ __CFG_COUT_TYPE__(LogError) << __COUT_HDR__ 00126 #define __CFG_COUT_WARN__ __CFG_COUT_TYPE__(LogWarning) << __COUT_HDR__ 00127 #define __CFG_COUT_INFO__ __CFG_COUT_TYPE__(LogInfo) << __COUT_HDR__ 00128 #define __CFG_COUT__ __CFG_COUT_TYPE__(LogDebug) << __COUT_HDR__ 00129 #define __CFG_COUTV__(X) __CFG_COUT__ << QUOTE(X) << " = " << X << __E__ 00130 00131 #define __CFG_MCOUT_ERR__(X) \ 00132 { \ 00133 __CFG_MOUT_ERR__ << X; \ 00134 __CFG_COUT_ERR__ << X; \ 00135 } 00136 #define __CFG_MCOUT_WARN__(X) \ 00137 { \ 00138 __CFG_MOUT_WARN__ << X; \ 00139 __CFG_COUT_WARN__ << X; \ 00140 } 00141 #define __CFG_MCOUT_INFO__(X) \ 00142 { \ 00143 __CFG_MOUT_INFO__ << X; \ 00144 __CFG_COUT_INFO__ << X; \ 00145 } 00146 #define __CFG_MCOUT__(X) \ 00147 { \ 00148 __CFG_MOUT__ << X; \ 00149 __CFG_COUT__ << X; \ 00150 } 00151 #define __CFG_MCOUTV__(X) \ 00152 { \ 00153 __CFG_MOUTV__(X); \ 00154 __CFG_COUTV__(X); \ 00155 } 00156 00157 #define __CFG_SS__ \ 00158 std::stringstream ss; \ 00159 ss << ":" << __MF_SUBJECT__ << ":" << theConfigurationRecordName_ << ":" \ 00160 << __COUT_HDR__ 00161 #define __CFG_SS_THROW__ \ 00162 __CFG_COUT_ERR__ << "\n" << ss.str(); \ 00163 throw std::runtime_error(ss.str()) 00164 00166 00167 // for front-end interface objects, add name to subject 00168 #define __FE_COUT_TYPE__(X) \ 00169 std::cout << QUOTE(X) << ":FE:" << getInterfaceType() << ":" << getInterfaceUID() \ 00170 << ":" << theConfigurationRecordName_ << ":" 00171 #define __FE_MF_TYPE__(X) \ 00172 mf::X(std::string("FE-") + getInterfaceType() + "-" + getInterfaceUID() + "-" + \ 00173 theConfigurationRecordName_) 00174 00175 #define __FE_MOUT_ERR__ __FE_MF_TYPE__(LogError) << __COUT_HDR__ 00176 #define __FE_MOUT_WARN__ __FE_MF_TYPE__(LogWarning) << __COUT_HDR__ 00177 #define __FE_MOUT_INFO__ __FE_MF_TYPE__(LogInfo) << __COUT_HDR__ 00178 #define __FE_MOUT__ __FE_MF_TYPE__(LogDebug) << __COUT_HDR__ 00179 #define __FE_MOUTV__(X) __FE_MOUT__ << QUOTE(X) << " = " << X 00180 #define __FE_COUT_ERR__ __FE_COUT_TYPE__(LogError) << __COUT_HDR__ 00181 #define __FE_COUT_WARN__ __FE_COUT_TYPE__(LogWarning) << __COUT_HDR__ 00182 #define __FE_COUT_INFO__ __FE_COUT_TYPE__(LogInfo) << __COUT_HDR__ 00183 #define __FE_COUT__ __FE_COUT_TYPE__(LogDebug) << __COUT_HDR__ 00184 #define __FE_COUTV__(X) __FE_COUT__ << QUOTE(X) << " = " << X << __E__ 00185 00186 #define __FE_MCOUT_ERR__(X) \ 00187 { \ 00188 __FE_MOUT_ERR__ << X; \ 00189 __FE_COUT_ERR__ << X; \ 00190 } 00191 #define __FE_MCOUT_WARN__(X) \ 00192 { \ 00193 __FE_MOUT_WARN__ << X; \ 00194 __FE_COUT_WARN__ << X; \ 00195 } 00196 #define __FE_MCOUT_INFO__(X) \ 00197 { \ 00198 __FE_MOUT_INFO__ << X; \ 00199 __FE_COUT_INFO__ << X; \ 00200 } 00201 #define __FE_MCOUT__(X) \ 00202 { \ 00203 __FE_MOUT__ << X; \ 00204 __FE_COUT__ << X; \ 00205 } 00206 #define __FE_MCOUTV__(X) \ 00207 { \ 00208 __FE_MOUTV__(X); \ 00209 __FE_COUTV__(X); \ 00210 } 00211 00212 #define __FE_SS__ \ 00213 std::stringstream ss; \ 00214 ss << ":FE:" << getInterfaceType() << ":" << getInterfaceUID() << ":" \ 00215 << theConfigurationRecordName_ << ":" << __COUT_HDR__ 00216 #define __FE_SS_THROW__ \ 00217 __FE_COUT_ERR__ << "\n" << ss.str(); \ 00218 throw std::runtime_error(ss.str()) 00219 00221 00222 // for generic decoration override, just have mfSubject declared 00223 #define __GEN_COUT_TYPE__(X) std::cout << QUOTE(X) << ":" << mfSubject_ << ":" 00224 #define __GEN_MF_TYPE__(X) mf::X(mfSubject_) 00225 00226 #define __GEN_MOUT_ERR__ __GEN_MF_TYPE__(LogError) << __COUT_HDR__ 00227 #define __GEN_MOUT_WARN__ __GEN_MF_TYPE__(LogWarning) << __COUT_HDR__ 00228 #define __GEN_MOUT_INFO__ __GEN_MF_TYPE__(LogInfo) << __COUT_HDR__ 00229 #define __GEN_MOUT__ __GEN_MF_TYPE__(LogDebug) << __COUT_HDR__ 00230 #define __GEN_MOUTV__(X) __GEN_MOUT__ << QUOTE(X) << " = " << X 00231 #define __GEN_COUT_ERR__ __GEN_COUT_TYPE__(LogError) << __COUT_HDR__ 00232 #define __GEN_COUT_WARN__ __GEN_COUT_TYPE__(LogWarning) << __COUT_HDR__ 00233 #define __GEN_COUT_INFO__ __GEN_COUT_TYPE__(LogInfo) << __COUT_HDR__ 00234 #define __GEN_COUT__ __GEN_COUT_TYPE__(LogDebug) << __COUT_HDR__ 00235 #define __GEN_COUTV__(X) __GEN_COUT__ << QUOTE(X) << " = " << X << __E__ 00236 00237 #define __GEN_MCOUT_ERR__(X) \ 00238 { \ 00239 __GEN_MOUT_ERR__ << X; \ 00240 __GEN_COUT_ERR__ << X; \ 00241 } 00242 #define __GEN_MCOUT_WARN__(X) \ 00243 { \ 00244 __GEN_MOUT_WARN__ << X; \ 00245 __GEN_COUT_WARN__ << X; \ 00246 } 00247 #define __GEN_MCOUT_INFO__(X) \ 00248 { \ 00249 __GEN_MOUT_INFO__ << X; \ 00250 __GEN_COUT_INFO__ << X; \ 00251 } 00252 #define __GEN_MCOUT__(X) \ 00253 { \ 00254 __GEN_MOUT__ << X; \ 00255 __GEN_COUT__ << X; \ 00256 } 00257 #define __GEN_MCOUTV__(X) \ 00258 { \ 00259 __GEN_MOUTV__(X); \ 00260 __GEN_COUTV__(X); \ 00261 } 00262 00263 #define __GEN_SS__ \ 00264 std::stringstream ss; \ 00265 ss << ":" << mfSubject_ << ":" << __COUT_HDR__ 00266 #define __GEN_SS_THROW__ \ 00267 __GEN_COUT_ERR__ << "\n" << ss.str(); \ 00268 throw std::runtime_error(ss.str()) 00269 00271 00272 // for core supervisor objects (with supervisorClassNoNamespace_ defined), add class to 00273 // subject 00274 #define __SUP_COUT_TYPE__(X) \ 00275 std::cout << QUOTE(X) << ":" << supervisorClassNoNamespace_ << ":" \ 00276 << CorePropertySupervisorBase::getSupervisorUID() << ":" 00277 #define __SUP_MF_TYPE__(X) \ 00278 mf::X(supervisorClassNoNamespace_ + "-" + \ 00279 CorePropertySupervisorBase::getSupervisorUID()) 00280 00281 #define __SUP_MOUT_ERR__ __SUP_MF_TYPE__(LogError) << __COUT_HDR__ 00282 #define __SUP_MOUT_WARN__ __SUP_MF_TYPE__(LogWarning) << __COUT_HDR__ 00283 #define __SUP_MOUT_INFO__ __SUP_MF_TYPE__(LogInfo) << __COUT_HDR__ 00284 #define __SUP_MOUT__ __SUP_MF_TYPE__(LogDebug) << __COUT_HDR__ 00285 #define __SUP_MOUTV__(X) __SUP_MOUT__ << QUOTE(X) << " = " << X 00286 #define __SUP_COUT_ERR__ __SUP_COUT_TYPE__(LogError) << __COUT_HDR__ 00287 #define __SUP_COUT_WARN__ __SUP_COUT_TYPE__(LogWarning) << __COUT_HDR__ 00288 #define __SUP_COUT_INFO__ __SUP_COUT_TYPE__(LogInfo) << __COUT_HDR__ 00289 #define __SUP_COUT__ __SUP_COUT_TYPE__(LogDebug) << __COUT_HDR__ 00290 #define __SUP_COUTV__(X) __SUP_COUT__ << QUOTE(X) << " = " << X << __E__ 00291 00292 #define __SUP_MCOUT_ERR__(X) \ 00293 { \ 00294 __SUP_MOUT_ERR__ << X; \ 00295 __SUP_COUT_ERR__ << X; \ 00296 } 00297 #define __SUP_MCOUT_WARN__(X) \ 00298 { \ 00299 __SUP_MOUT_WARN__ << X; \ 00300 __SUP_COUT_WARN__ << X; \ 00301 } 00302 #define __SUP_MCOUT_INFO__(X) \ 00303 { \ 00304 __SUP_MOUT_INFO__ << X; \ 00305 __SUP_COUT_INFO__ << X; \ 00306 } 00307 #define __SUP_MCOUT__(X) \ 00308 { \ 00309 __SUP_MOUT__ << X; \ 00310 __SUP_COUT__ << X; \ 00311 } 00312 #define __SUP_MCOUTV__(X) \ 00313 { \ 00314 __SUP_MOUTV__(X); \ 00315 __SUP_COUTV__(X); \ 00316 } 00317 00318 #define __SUP_SS__ \ 00319 std::stringstream ss; \ 00320 ss << ":" << supervisorClassNoNamespace_ << ":" \ 00321 << CorePropertySupervisorBase::getSupervisorUID() << ":" << __COUT_HDR__ 00322 #define __SUP_SS_THROW__ \ 00323 __SUP_COUT_ERR__ << "\n" << ss.str(); \ 00324 throw std::runtime_error(ss.str()) 00325 00326 //======================================================================================================================== 00327 // const_cast away the const 00328 // so that otsdaq is compatible with slf6 and slf7 versions of xdaq 00329 // where they changed to const xdaq::ApplicationDescriptor* in slf7 00330 #ifdef XDAQ_NOCONST 00331 #define XDAQ_CONST_CALL 00332 #else 00333 #define XDAQ_CONST_CALL const 00334 #endif 00335 //======================================================================================================================== 00336 00337 //======================================================================================================================== 00338 // declare special ots soft exception 00339 // a SOFT exception thrown during runnning workloop by a state machine plugin will pause 00340 // the global state machine and allow for manual intervention to resume a run. 00341 namespace ots 00342 { 00343 struct __OTS_SOFT_EXCEPTION__ : public std::exception 00344 { 00345 __OTS_SOFT_EXCEPTION__(const std::string& what) : what_(what) {} 00346 virtual char const* what() const throw() { return what_.c_str(); } 00347 std::string what_; 00348 }; 00349 00350 } // namespace ots 00351 00352 #endif