]> Creatis software - gdcm.git/blobdiff - src/gdcmDebug.cxx
* bug fix in the Python demos, due to the recent changes
[gdcm.git] / src / gdcmDebug.cxx
index 82c4ee96a91e1fbb45b22ed59bc42e5092fcef4c..d9a56182e30bb7fcb0ff5bb45e77f96f129570ae 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDebug.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/13 22:30:11 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2005/06/24 10:55:58 $
+  Version:   $Revision: 1.25 $
                                                                                 
   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 bool DebugFlag = false;
+//-----------------------------------------------------------------------------
+// Warning message level to be displayed
+static bool DebugFlag   = false;
 static bool DebugToFile = false;
 static std::ofstream DebugFile;
+
+//-----------------------------------------------------------------------------
+// Constructor / Destructor
+Debug::Debug()
+{
+
+}
+
+Debug::~Debug()
+{
+  if ( DebugFile.is_open() )
+      DebugFile.close();     
+}
+
 //-----------------------------------------------------------------------------
+// Public
 /**
- * \brief   Accessor
+ * \brief   Sets the debug flag
  * @param   flag Set the debug flag
  */ 
 void Debug::SetDebugFlag (bool flag) 
@@ -37,8 +52,8 @@ void Debug::SetDebugFlag (bool flag)
 }
 
 /**
- * \brief   Accessor
- * @param   level Get the debug flag
+ * \brief   Gets the debug flag value
+ * @return debug flag value
  */ 
 bool Debug::GetDebugFlag ()
 {
@@ -47,7 +62,7 @@ bool Debug::GetDebugFlag ()
 
 /**
  * \brief   Accessor
- * @param   flag Set the debug flag to redirect to file
+ * @param   flag whether we want to redirect to file
  */ 
 void Debug::SetDebugToFile (bool flag) 
 {
@@ -55,8 +70,7 @@ void Debug::SetDebugToFile (bool flag)
 }
 
 /**
- * \brief   Accessor
- * @param   level Get the debug flag to redirect to file
+ * \brief   Accessor to know whether debug info are redirected to file
  */ 
 bool Debug::GetDebugToFile ()
 {
@@ -64,23 +78,39 @@ bool Debug::GetDebugToFile ()
 }
 
 /**
- * \brief   Accessor
- * @param   flag Set the debug flag to redirect to file
+ * \brief Set the filename the debug stream should be redirect to
+ *        Settting a filename also sets DebugToFile to true
+ * @param   filename  File to redirect debug info
  *          Absolutely nothing is check. You have to pass in
  *          a correct filename
  */ 
-void Debug::SetDebugFilename (std::string constfilename)
+void Debug::SetDebugFilename (std::string const &filename)
 {
    DebugToFile = true;  // Just in case ... 
-   DebugFlag = true;    // Just in case ... 
+   DebugFlag   = true;  // Just in case ...
+   if ( DebugFile.is_open() )
+      DebugFile.close();
    DebugFile.open( filename.c_str() );
 }
 
-std::ofstream & Debug::GetDebugFile ()
+/**
+ * \brief Internal use only. Allow us to retrieve the static from anywhere
+ *        in gdcm code
+ * @return Debug file
+ */
+std::ofstream &Debug::GetDebugFile ()
 {
   return DebugFile;
 }
 
-} // end namespace gdcm
+//-----------------------------------------------------------------------------
+// Protected
 
+//-----------------------------------------------------------------------------
+// Private
+   
+//-----------------------------------------------------------------------------
+// Print
 
+//-----------------------------------------------------------------------------
+} // end namespace gdcm