Program: gdcm
Module: $RCSfile: gdcmDebug.h,v $
Language: C++
- Date: $Date: 2005/01/07 19:20:38 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2005/01/07 20:31:36 $
+ Version: $Revision: 1.14 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \ingroup Debug
* \brief Debug is an object for debugging in program.
* It has 2 debugging modes :
- * - error : for bad library use
- * - debug : for debugging messages
+ * - error : for bad library use, seriously wrong DICOM
+ * - debug : for information/debug messages
+ * - warning : for warning about DICOM quality (kosher)
*
- * A debugging message has a level of priority and is
- * Shown only when the debug level is higher than the
- * message level.
+ * A debugging message is only show if the flag is on (DebugFlag)
+ * This is static var and can be set at begining of code:
+ * gdcm::Debug::SetDebugOn();
*/
class GDCM_EXPORT Debug
{
// You cannot use function unless you use vnsprintf ...
// __FUNCTION is not always defined by preprocessor
-#ifndef __FUNCTION__
-# define __FUNCTION__ ""
+// In c++ we should use __PRETTY_FUNCTION__ instead...
+#ifndef __GNUC__
+# define __FUNCTION__ "<unknow>"
#endif
/**
- * \brief Verbose
- * @param level level
- * @param msg1 first message part
- * @param msg2 second message part
+ * \brief Debug
+ * @param msg message part
*/
-#define gdcmDebugMacro(x) \
+#define gdcmDebugMacro(msg) \
{ \
if( gdcm::Debug::GetDebugFlag() ) \
{ \
std::ostringstream osmacro; \
osmacro << "Debug: In " __FILE__ ", line " << __LINE__ \
- << ", function " << __FUNCTION__ << '\n' \
- << x << "\n\n"; \
+ << ", function " << __FUNCTION__ << '\n' \
+ << msg << "\n\n"; \
std::cerr << osmacro.str() << std::endl; \
} \
}
/**
* \brief Verbose
- * @param level level
- * @param msg1 first message part
- * @param msg2 second message part
+ * @param msg message part
*/
-#define gdcmVerboseMacro(x) \
+#define gdcmVerboseMacro(msg) \
{ \
if( gdcm::Debug::GetDebugFlag() ) \
{ \
std::ostringstream osmacro; \
osmacro << "Verbose: In " __FILE__ ", line " << __LINE__ \
- << ", function " __FUNCTION__ "\n" \
- << x << "\n\n"; \
+ << ", function " << __FUNCTION__ << "\n" \
+ << msg << "\n\n"; \
std::cerr << osmacro.str() << std::endl; \
} \
}
/**
* \brief Error
- * @param test test
- * @param msg1 first message part
- * @param msg2 second message part
+ * @param msg second message part
*/
-#define gdcmErrorMacro(x) \
+#define gdcmErrorMacro(msg) \
{ \
if( gdcm::Debug::GetDebugFlag() ) \
{ \
std::ostringstream osmacro; \
osmacro << "Error: In " __FILE__ ", line " << __LINE__ \
- << ", function " << __FUNCTION__ << '\n' \
- << x << "\n\n"; \
+ << ", function " << __FUNCTION__ << '\n' \
+ << msg << "\n\n"; \
std::cerr << osmacro.str() << std::endl; \
exit(1); \
} \
/**
* \brief Assert
- * @param level level
- * @param test test
- * @param msg1 first message part
- * @param msg2 second message part
+ * @param arg argument to test
+ * An easy solution to pass also a message is to do:
+ * gdcmAssertMacro( "my message" && 2 < 3 )
*/
-#define gdcmAssertMacro(x) \
+#define gdcmAssertMacro(arg) \
{ \
- if( x ) \
+ if( arg ) \
{ \
std::ostringstream osmacro; \
osmacro << "Assert: In " __FILE__ ", line " << __LINE__ \
- << ", function " << __FUNCTION__ \
- << "\n\n"; \
+ << ", function " << __FUNCTION__ \
+ << "\n\n"; \
std::cerr << osmacro.str() << std::endl; \
- assert ( x ); \
+ assert ( arg ); \
} \
}