CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/DetectorDescription/Base/interface/DDdebug.h

Go to the documentation of this file.
00001 #ifndef DDdebug_h
00002 #define DDdebug_h
00003 
00004 // Message logger.
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007  // If DDEBUG is defined, the debug macros DCOUT and DCOUT_V are active
00008  // Undefined DDEBUG redefines DCOUT and DCOUT_V to not to produce any code.
00009 #define DDEBUG 
00010  
00011  #ifdef DDEBUG
00012   // Extended debug macros: DDEBUG(a,b) and DDEBUG_V(a,b) for extended verbosity
00013   // Both macros are kind of CPU intensive (calls to getenv, loop over a std::string)
00014   //
00015   // Usage: DEBUGOUT(char, std::ostream )
00016   //  char (i.e. 'P') defines the module which should produce debug-output
00017   //  At runtime the environment variables DDEBUG and  DDEBUG_V specify which
00018   //  module should activate its debug-output.
00019   //
00020   //  Example:
00021   //   file DDCore/src/a.cc: DCOUT('C',"Debuginfo of moule C" << i_ << j_ );
00022   //   file Parser/src/b.cc: DCOUT('P',"Parser debug");
00023   //   runtime: setenv DDEBUG P  > activates debug-output of a.cc
00024   //            setenv DDEBUG C  > activates debug-output of b.cc
00025   //            setenv DDEBUG PC > activated debug-output of a.cc and b.cc  
00026   
00027 
00028   #include <cstdlib>
00029   #include <iostream>
00030   #include <string>
00031 
00032  inline const char* ddDebug() {
00033   static const char* c = getenv("DDEBUG");
00034   return c;
00035 }
00036 
00037  inline const char* ddDebugV() {
00038   static  const char* c = getenv("DDEBUG_V");
00039   return c;
00040 }
00041 
00042 inline const  std::string & ddDebugS() {
00043   static const std::string s(ddDebug()? ddDebug(): ""); 
00044   return s;
00045 }
00046 
00047 inline const  std::string & ddDebugVS() {
00048   static const std::string s(ddDebugV()? ddDebugV(): "");
00049   return s; 
00050 }
00051      
00052       
00053   #define DCOUT(M_v_Y,M_v_S) { for(std::string::size_type M_v_i=0; M_v_i < ddDebugS().size(); ++M_v_i) if(ddDebugS()[M_v_i]==M_v_Y) LogDebug("DDdebug") << ddDebugS()[M_v_i] << " : " << M_v_S << std::endl; }   
00054   #define DCOUT_V(M_v_Y,M_v_S) { for(std::string::size_type M_v_i=0; M_v_i < ddDebugVS().size(); ++M_v_i) if(ddDebugVS()[M_v_i]==M_v_Y) LogDebug("DDdebug") << ddDebugVS()[M_v_i] << "v: " << M_v_S << std::endl; }         
00055   
00056   // backward compatiblility, don't use anymore! 
00057   #define DEBUGOUT(s) if (ddDebug()) { LogDebug("DDdebug") << s << std::endl; }
00058   #define DEBUGOUT_V(s) if (ddDebugV()) { LogDebug("DDdebug") << s << std::endl; }
00059  
00060  #else
00061   
00062   #define DCOUT(M_v_Y, M_v_s)
00063   #define DCOUT_V(M_v_Y, M_v_s)
00064   #define DEBUGOUT(s)
00065   #define DEBUGOUT_V(s)
00066  
00067  #endif
00068 
00072 int DDmem();
00073 int DDtime();
00074 
00075 #endif