]> Creatis software - gdcm.git/blobdiff - src/gdcmDebug.cxx
ENH: properly handle compiler that does not have __FUNCTION__
[gdcm.git] / src / gdcmDebug.cxx
index 6bff5c2b828c18efcd3f26921f22fa9b9b119367..ee7216641d0ae583c9742a2a6f49da76c793c88f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDebug.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/09 22:30:43 $
-  Version:   $Revision: 1.12 $
+  Date:      $Date: 2005/01/07 19:20:38 $
+  Version:   $Revision: 1.15 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 namespace gdcm 
 {
 
+/// warning message level to be displayed
+static int DebugFlag = 0;
 //-----------------------------------------------------------------------------
-/**
- * \brief   constructor
- * @param level debug level
- */ 
-Debug::Debug(int level) 
-{
-   DebugLevel = level;
-}
-
 /**
  * \brief   Accessor
  * @param   level Set the debug level
  */ 
-void Debug::SetDebug(int level) 
-{
-   DebugLevel = level;
-}
-
-/**
- * \brief   Verbose 
- * @param level level
- * @param msg1 first message part
- * @param msg2 second message part 
- */
-void Debug::Verbose(int level, const char * msg1, const char * msg2) 
+void Debug::SetDebugFlag (int flag) 
 {
-   if (level > DebugLevel)
-   {
-      return ;
-   }
-   std::cerr << "gdcm::" << msg1 << ' ' << msg2 << std::endl << std::flush;
+   DebugFlag = flag;
 }
 
 /**
- * \brief   Error 
- * @param test test
- * @param msg1 first message part
- * @param msg2 second message part 
- */
-void Debug::Error(bool test, const char * msg1, const char * msg2) 
-{
-   if (!test)
-   {
-      return;
-   }
-   std::cerr << "gdcm::" << msg1 << ' ' << msg2 << std::endl << std::flush;
-   Exit(1);
-}
-
-/**
- * \brief   Error 
- * @param msg1 first message part
- * @param msg2 second message part
- * @param msg3 Third message part  
- */
-void Debug::Error(const char* msg1, const char* msg2,
-                      const char* msg3) 
+ * \brief   Accessor
+ * @param   level Get the debug level
+ */ 
+int Debug::GetDebugFlag ()
 {
-   std::cerr << "gdcm::" << msg1 << ' ' << msg2 << ' ' << msg3
-             << std::endl << std::flush;
-   Exit(1);
+   return DebugFlag;
 }
 
-/**
- * \brief   Assert 
- * @param level level 
- * @param test test
- * @param msg1 first message part
- * @param msg2 second message part
- */
-void Debug::Assert(int level, bool test, const char * msg1, 
-                       const char * msg2) 
-{
-   if (level > DebugLevel)
-   {
-      return ;
-   }
-   if (!test)
-   {
-      std::cerr << "gdcm::" <<  msg1 << ' ' << msg2
-                << std::endl << std::flush;
-   }
-}
+} // end namespace gdcm
 
-/**
- * \brief   Exit 
- * @param a return code 
- */
-void Debug::Exit(int a) 
-{
-#ifdef __GNUC__
-   std::exit(a);
-#endif
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-   exit(a);    // Found in #include <stdlib.h>
-#endif
-}
 
-} // end namespace gdcm