]> Creatis software - gdcm.git/blob - src/gdcmDebug.cxx
82ced4141d27c695ad8e4630adafaa88f2ddc7ca
[gdcm.git] / src / gdcmDebug.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDebug.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/30 17:30:57 $
7   Version:   $Revision: 1.19 $
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 //-----------------------------------------------------------------------------
32 // Constructor / Destructor
33
34 Debug::Debug()
35 {
36
37 }
38
39 Debug::~Debug()
40 {
41   if ( DebugFile.is_open() )
42       DebugFile.close();     
43 }
44
45 //-----------------------------------------------------------------------------
46 // Print
47
48
49 //-----------------------------------------------------------------------------
50 // Public
51
52 /**
53  * \brief   Accessor
54  * @param   flag Set the debug flag
55  */ 
56 void Debug::SetDebugFlag (bool flag) 
57 {
58    DebugFlag = flag;
59 }
60
61 /**
62  * \brief   Accessor
63  * @param   level Get the debug flag
64  */ 
65 bool Debug::GetDebugFlag ()
66 {
67    return DebugFlag;
68 }
69
70 /**
71  * \brief   Accessor
72  * @param   flag Set the debug flag to redirect to file
73  */ 
74 void Debug::SetDebugToFile (bool flag) 
75 {
76    DebugToFile = flag;
77 }
78
79 /**
80  * \brief   Accessor
81  * @param   level Get the debug flag to redirect to file
82  */ 
83 bool Debug::GetDebugToFile ()
84 {
85    return DebugToFile;
86 }
87
88 /**
89  * \brief   Set Accessor
90  * @param   flag Set the debug flag to redirect to file
91  *          Absolutely nothing is check. You have to pass in
92  *          a correct filename
93  */ 
94 void Debug::SetDebugFilename (std::string const &filename)
95 {
96    DebugToFile = true;  // Just in case ... 
97    DebugFlag = true;    // Just in case ...
98    if( DebugFile.is_open() )
99       DebugFile.close();
100    DebugFile.open( filename.c_str() );
101 }
102
103 /**
104  * \brief   Get Accessor
105  * @return Debug file
106  */
107 std::ofstream &Debug::GetDebugFile ()
108 {
109   return DebugFile;
110 }
111
112 //-----------------------------------------------------------------------------
113 // Protected
114
115 //-----------------------------------------------------------------------------
116 // Private
117    
118 //-----------------------------------------------------------------------------
119 } // end namespace gdcm
120
121