]> Creatis software - gdcm.git/blob - src/gdcmDebug.cxx
* Reorder file content
[gdcm.git] / src / gdcmDebug.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDebug.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/02/02 14:52:22 $
7   Version:   $Revision: 1.23 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmDebug.h"
20 #include <iostream>
21
22 namespace gdcm 
23 {
24 //-----------------------------------------------------------------------------
25 // Warning message level to be displayed
26 static bool DebugFlag   = false;
27 static bool DebugToFile = false;
28 static std::ofstream DebugFile;
29
30 //-----------------------------------------------------------------------------
31 // Constructor / Destructor
32 Debug::Debug()
33 {
34
35 }
36
37 Debug::~Debug()
38 {
39   if ( DebugFile.is_open() )
40       DebugFile.close();     
41 }
42
43 //-----------------------------------------------------------------------------
44 // Public
45 /**
46  * \brief   Accessor
47  * @param   flag Set the debug flag
48  */ 
49 void Debug::SetDebugFlag (bool flag) 
50 {
51    DebugFlag = flag;
52 }
53
54 /**
55  * \brief   Gets the debug flag value
56  * @return debug flag value
57  */ 
58 bool Debug::GetDebugFlag ()
59 {
60    return DebugFlag;
61 }
62
63 /**
64  * \brief   Accessor
65  * @param   flag whether we want to redirect to file
66  */ 
67 void Debug::SetDebugToFile (bool flag) 
68 {
69    DebugToFile = flag;
70 }
71
72 /**
73  * \brief   Accessor to know if debug info are redirected to file
74  */ 
75 bool Debug::GetDebugToFile ()
76 {
77    return DebugToFile;
78 }
79
80 /**
81  * \brief   Set Accessor
82  * @param   filename  File to redirect debug info
83  *          Absolutely nothing is check. You have to pass in
84  *          a correct filename
85  */ 
86 void Debug::SetDebugFilename (std::string const &filename)
87 {
88    DebugToFile = true;  // Just in case ... 
89    DebugFlag = true;    // Just in case ...
90    if( DebugFile.is_open() )
91       DebugFile.close();
92    DebugFile.open( filename.c_str() );
93 }
94
95 /**
96  * \brief   Get Accessor
97  * @return Debug file
98  */
99 std::ofstream &Debug::GetDebugFile ()
100 {
101   return DebugFile;
102 }
103
104 //-----------------------------------------------------------------------------
105 // Protected
106
107 //-----------------------------------------------------------------------------
108 // Private
109    
110 //-----------------------------------------------------------------------------
111 // Print
112
113 //-----------------------------------------------------------------------------
114 } // end namespace gdcm