ML Reference
MeVis/Foundation/Sources/MLUtilities/mlDebug.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //-------------------------------------------------------------------------
00004 
00059 //-------------------------------------------------------------------------
00060 #ifndef __mlDebug_H
00061 #define __mlDebug_H
00062 
00063 #ifndef __mlErrorOutput_H
00064 #include "mlErrorOutput.h"
00065 #endif
00066 #ifndef __mlErrorOutputInfos_H
00067 #include "mlErrorOutputInfos.h"
00068 #endif
00069 
00070 //--------------------------------------------------------------------------------------------
00071 //
00073 
00074 //
00075 //--------------------------------------------------------------------------------------------
00076 
00077 
00078 //--------------------------------------------------------------------------------------------
00081 //--------------------------------------------------------------------------------------------
00082 #ifdef _DEBUG
00083 // Implement outputting debug information in debug mode.
00084 #define _mlDebugConst(ENV_VAR, COUTS)                                         \
00085 {                                                                             \
00086   /* Print debug infor only if global debug state is non zero. */             \
00087   if ((ML_NAMESPACE::MLErrorOutput.getMessageFilter() & ML_DEBUG) ||          \
00088       (ML_NAMESPACE::MLErrorOutput.isFullDebuggingOn())){                     \
00089     /* Redirect debug output into a stream buffer. */                         \
00090     /* Be sure that the stream is terminated to avoid crashes. */             \
00091     std::stringstream __ML_local_TMp_streamBuFfer;                            \
00092     __ML_local_TMp_streamBuFfer << COUTS << '\0';                             \
00093     ML_NAMESPACE::MLErrorOutput.handleDebugPrint(ENV_VAR,                     \
00094                                                  ML_PREFIX,                   \
00095                                                  __ML_local_TMp_streamBuFfer, \
00096                                                  __FILE__,                    \
00097                                                  __LINE__);                   \
00098   }                                                                           \
00099 }
00100 #else
00101 // Do not code anything in release mode.
00102 #define _mlDebugConst(ENV_VAR, COUTS)
00103 #endif
00104 
00105 //--------------------------------------------------------------------------------------------
00109 //--------------------------------------------------------------------------------------------
00110 #define mlDebugConst(ENV_VAR, COUTS)    _mlDebugConst(ENV_VAR, COUTS)
00111 
00112 //--------------------------------------------------------------------------------------------
00121 //--------------------------------------------------------------------------------------------
00122 #ifdef _DEBUG
00123 #define mlDebug(COUTS)                  { const RuntimeType *rt = getClassTypeId();                     \
00124                                           ML_CHECK_RUNTIME_TYPE(rt);                                    \
00125                                           _mlDebugConst((static_cast<std::string>(ML_CONSTANT_PREFIX))+ \
00126                                                         rt->getName(),                                  \
00127                                                         COUTS);                                         \
00128                                         }
00129 #else
00130 #define mlDebug(COUTS)
00131 #endif
00132 
00133 //--------------------------------------------------------------------------------------------
00160 //--------------------------------------------------------------------------------------------
00161 #ifdef _DEBUG
00162 #define mlDebugConditional(COND_SYM, COUTS)                     \
00163 {                                                               \
00164   const RuntimeType *rt = getClassTypeId();                     \
00165   ML_CHECK_RUNTIME_TYPE(rt);                                    \
00166   _mlDebugConst((static_cast<std::string>(ML_CONSTANT_PREFIX))+ \
00167                 rt->getName() +"-" + (COND_SYM),                \
00168                 COUTS);                                         \
00169   mlDebug(COUTS);                                               \
00170 }
00171 #else
00172 #define mlDebugConditional(COND_SYM, COUTS)
00173 #endif
00174 
00175 //--------------------------------------------------------------------------------------------
00183 //--------------------------------------------------------------------------------------------
00184 #define mlDebugPrint(COUTS)             _mlDebugConst(ML_DEBUG_ENV_NAME, COUTS)
00185 
00186 //--------------------------------------------------------------------------------------------
00195 //--------------------------------------------------------------------------------------------
00196 #ifdef _DEBUG
00197 #define mlDebugClass(CLASS_NAME, COUTS) { const RuntimeType *rt = CLASS_NAME::getClassTypeId();         \
00198                                           ML_CHECK_RUNTIME_TYPE(rt);                                    \
00199                                           _mlDebugConst((static_cast<std::string>(ML_CONSTANT_PREFIX))+ \
00200                                                           rt->getName(),                                \
00201                                                           COUTS);                                       \
00202                                         }
00203 #else
00204 #define mlDebugClass(CLASS_NAME, COUTS)
00205 #endif
00206 
00207 
00208 
00209 #endif // End of __mlDebug_H
00210 
00211 
00212