MeVisLab Toolbox Reference
mlDebug.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_DEBUG_H
14 #define ML_DEBUG_H
15 
17 
67 #include "mlErrorOutput.h"
68 #include "mlErrorOutputInfos.h"
69 
70 //--------------------------------------------------------------------------------------------
71 //
74 //
75 //--------------------------------------------------------------------------------------------
76 
77 
78 //--------------------------------------------------------------------------------------------
81 //--------------------------------------------------------------------------------------------
82 #ifdef _DEBUG
83 // Implement outputting debug information in debug mode.
84 #define _mlDebugConst(ENV_VAR, COUTS) \
85 { \
86  /* Print debug infor only if global debug state is non zero. */ \
87  if ((ML_NAMESPACE::MLErrorOutput.getMessageFilter() & ML_DEBUG) || \
88  (ML_NAMESPACE::MLErrorOutput.isFullDebuggingOn())){ \
89  /* Redirect debug output into a stream buffer. */ \
90  /* Be sure that the stream is terminated to avoid crashes. */ \
91  std::stringstream __ML_local_TMp_streamBuFfer; \
92  __ML_local_TMp_streamBuFfer << COUTS << '\0'; \
93  ML_NAMESPACE::MLErrorOutput.handleDebugPrint(ENV_VAR, \
94  ML_PREFIX, \
95  __ML_local_TMp_streamBuFfer, \
96  __FILE__, \
97  __LINE__); \
98  } \
99 }
100 #else
101 // Do not code anything in release mode.
102 #define _mlDebugConst(ENV_VAR, COUTS)
103 #endif
104 
105 //--------------------------------------------------------------------------------------------
109 //--------------------------------------------------------------------------------------------
110 #define mlDebugConst(ENV_VAR, COUTS) _mlDebugConst(ENV_VAR, COUTS)
111 
112 //--------------------------------------------------------------------------------------------
121 //--------------------------------------------------------------------------------------------
122 #ifdef _DEBUG
123 #define mlDebug(COUTS) { const RuntimeType *rt = getClassTypeId(); \
124  ML_CHECK_RUNTIME_TYPE(rt); \
125  _mlDebugConst(std::string{ML_CONSTANT_PREFIX}+ \
126  rt->getName(), \
127  COUTS); \
128  }
129 #else
130 #define mlDebug(COUTS)
131 #endif
132 
133 //--------------------------------------------------------------------------------------------
160 //--------------------------------------------------------------------------------------------
161 #ifdef _DEBUG
162 #define mlDebugConditional(COND_SYM, COUTS) \
163 { \
164  const RuntimeType *rt = getClassTypeId(); \
165  ML_CHECK_RUNTIME_TYPE(rt); \
166  _mlDebugConst(std::string{ML_CONSTANT_PREFIX} + \
167  rt->getName() +"-" + (COND_SYM), \
168  COUTS); \
169  mlDebug(COUTS); \
170 }
171 #else
172 #define mlDebugConditional(COND_SYM, COUTS)
173 #endif
174 
175 //--------------------------------------------------------------------------------------------
183 //--------------------------------------------------------------------------------------------
184 #define mlDebugPrint(COUTS) _mlDebugConst(ML_DEBUG_ENV_NAME, COUTS)
185 
186 //--------------------------------------------------------------------------------------------
195 //--------------------------------------------------------------------------------------------
196 #ifdef _DEBUG
197 #define mlDebugClass(CLASS_NAME, COUTS) { const RuntimeType *rt = CLASS_NAME::getClassTypeId(); \
198  ML_CHECK_RUNTIME_TYPE(rt); \
199  _mlDebugConst(std::string{ML_CONSTANT_PREFIX} + \
200  rt->getName(), \
201  COUTS); \
202  }
203 #else
204 #define mlDebugClass(CLASS_NAME, COUTS)
205 #endif
207 
208 
209 #endif // End of __mlDebug_H