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