GDCM_NAME_SPACE::Debug Class Reference

Debug is an object for warning/logging/tracing programs. It has the following modes : More...

#include <gdcmDebug.h>

List of all members.

Public Member Functions

 Debug ()
 ~Debug ()

Static Public Member Functions

static void SetDebugFlag (bool flag)
 Sets both the debug flag and warning flag (both used for debugging purpose).
static bool GetDebugFlag ()
 Gets the debug flag value.
static void DebugOn ()
 Sets the Debug Flag to true.
static void DebugOff ()
 Sets the Debug Flag to false.
static void SetLogFlag (bool flag)
 Sets the log flag.
static bool GetLogFlag ()
 Gets the Log flag value.
static void LogOn ()
 Sets the Log Flag to true.
static void LogOff ()
 Sets the Log Flag to false.
static void SetWarningFlag (bool flag)
 Sets the warning flag.
static bool GetWarningFlag ()
 Gets the warning flag value.
static void WarningOn ()
 Sets the Warning Flag to true.
static void WarningOff ()
 Sets the Warning Flag to false.
static void SetOutputToFile (bool flag)
 Accessor.
static bool GetOutputToFile ()
 Accessor to know whether debug info are redirected to file.
static void OutputToFileOn ()
 Next debug messages will be sent in the debug file.
static void OutputToFileOff ()
 Next debug messages will be sent in the standard output.
static void SetOutputFileName (std::string const &filename)
 Set the filename the debug stream should be redirect to Settting a filename also sets DebugToFile to true.
static std::ostream & GetOutput ()
 Internal use only. Allow us to retrieve the static from anywhere in gdcm code.
static void SendToOutput (unsigned int type, std::string const &msg, const Base *object=NULL)

Static Private Attributes

static bool WarningFlag = false
static bool LogFlag = false
static bool DebugFlag = false
static bool OutputToFile = false
static std::ofstream OutputFileStream
static std::ostream & StandardStream = std::cerr
static const int LINE_LENGTH = 79


Detailed Description

Debug is an object for warning/logging/tracing programs. It has the following modes :

A debugging message is only shown if the flag is on (DebugFlag) This is static var and can be set at beginning of code: GDCM_NAME_SPACE::Debug::SetDebugOn();

Warning : Warns the user when some oddity occured, and we used an heuristics to bypass the trouble. e.g. : SamplesPerPixel missing, we assume it's a grey level image e.g : Pixel Representation missing : we assume 'unsigned' (we hope our assumption is OK, but user may disagree.) Log : we display messages when anything is not Dicom Kosher e.g. : non even length field e.g : file is declared as Explicit VR, but a DataElement is Implicit e.g : a file holds an illegal group (0x0005, ...) Debug : We help developper to trace, at a glance, the execution. (before refining with a debugging tool)

Setting ON Debug leads to set ON Warning (but not Log) Setting ON Log leads to set ON Warning (but not Debug)

Definition at line 70 of file gdcmDebug.h.


Constructor & Destructor Documentation

GDCM_NAME_SPACE::Debug::Debug  ) 
 

Definition at line 40 of file gdcmDebug.cxx.

00041 {
00042 }

GDCM_NAME_SPACE::Debug::~Debug  ) 
 

Definition at line 44 of file gdcmDebug.cxx.

References OutputFileStream.

00045 {
00046   if ( OutputFileStream.is_open() )
00047       OutputFileStream.close();     
00048 }


Member Function Documentation

static void GDCM_NAME_SPACE::Debug::DebugOff  )  [inline, static]
 

Sets the Debug Flag to false.

Definition at line 85 of file gdcmDebug.h.

00085 { SetDebugFlag(false); }

static void GDCM_NAME_SPACE::Debug::DebugOn  )  [inline, static]
 

Sets the Debug Flag to true.

Definition at line 83 of file gdcmDebug.h.

00083 { SetDebugFlag(true);  }

static bool GDCM_NAME_SPACE::Debug::GetDebugFlag  )  [inline, static]
 

Gets the debug flag value.

Definition at line 81 of file gdcmDebug.h.

Referenced by GDCM_NAME_SPACE::Document::ParseDES().

00081 {return DebugFlag; }

static bool GDCM_NAME_SPACE::Debug::GetLogFlag  )  [inline, static]
 

Gets the Log flag value.

Definition at line 91 of file gdcmDebug.h.

00091 {return LogFlag; }

std::ostream & GDCM_NAME_SPACE::Debug::GetOutput  )  [static]
 

Internal use only. Allow us to retrieve the static from anywhere in gdcm code.

Returns:
Debug file

Definition at line 130 of file gdcmDebug.cxx.

References OutputFileStream, OutputToFile, and StandardStream.

Referenced by SendToOutput().

00131 {
00132    if(OutputToFile)
00133       return OutputFileStream;
00134    else
00135       return StandardStream;
00136 }

bool GDCM_NAME_SPACE::Debug::GetOutputToFile  )  [static]
 

Accessor to know whether debug info are redirected to file.

Definition at line 104 of file gdcmDebug.cxx.

References OutputToFile.

00105 {
00106    return OutputToFile;
00107 }

static bool GDCM_NAME_SPACE::Debug::GetWarningFlag  )  [inline, static]
 

Gets the warning flag value.

Definition at line 101 of file gdcmDebug.h.

00101 {return WarningFlag; }

static void GDCM_NAME_SPACE::Debug::LogOff  )  [inline, static]
 

Sets the Log Flag to false.

Definition at line 95 of file gdcmDebug.h.

00095 { SetLogFlag(false); } 

static void GDCM_NAME_SPACE::Debug::LogOn  )  [inline, static]
 

Sets the Log Flag to true.

Definition at line 93 of file gdcmDebug.h.

00093 { SetLogFlag(true);  }

static void GDCM_NAME_SPACE::Debug::OutputToFileOff  )  [inline, static]
 

Next debug messages will be sent in the standard output.

Definition at line 114 of file gdcmDebug.h.

00114 { SetOutputToFile(false); }

static void GDCM_NAME_SPACE::Debug::OutputToFileOn  )  [inline, static]
 

Next debug messages will be sent in the debug file.

Definition at line 112 of file gdcmDebug.h.

00112 { SetOutputToFile(true);  }

void GDCM_NAME_SPACE::Debug::SendToOutput unsigned int  type,
std::string const &  msg,
const Base object = NULL
[static]
 

Definition at line 138 of file gdcmDebug.cxx.

References GDCM_NAME_SPACE::CMD_ASSERT, GDCM_NAME_SPACE::CMD_DEBUG, GDCM_NAME_SPACE::CommandManager::ExecuteCommandConst(), GDCM_NAME_SPACE::Command::GetCommandAsString(), and GetOutput().

00139 {
00140    bool executed=false;
00141    if( type != CMD_DEBUG && type != CMD_ASSERT )
00142       executed=CommandManager::ExecuteCommandConst(object,type,msg);
00143 
00144    if(!executed)
00145       GetOutput() << Command::GetCommandAsString(type) << ": " << msg;
00146 }

void GDCM_NAME_SPACE::Debug::SetDebugFlag bool  flag  )  [static]
 

Sets both the debug flag and warning flag (both used for debugging purpose).

Parameters:
flag Set the debug flag and warning flag

Definition at line 57 of file gdcmDebug.cxx.

References DebugFlag, and WarningFlag.

00058 {
00059    // To help tracking a bug, both flags are necessary
00060    DebugFlag   = flag;
00061    WarningFlag = flag;
00062 }

void GDCM_NAME_SPACE::Debug::SetLogFlag bool  flag  )  [static]
 

Sets the log flag.

Parameters:
flag Set the log flag

Definition at line 85 of file gdcmDebug.cxx.

References LogFlag, and WarningFlag.

00086 {
00087    // To log oddities, both flags are necessary      
00088    WarningFlag = flag;   
00089    LogFlag = flag;
00090 }

void GDCM_NAME_SPACE::Debug::SetOutputFileName std::string const &  filename  )  [static]
 

Set the filename the debug stream should be redirect to Settting a filename also sets DebugToFile to true.

Parameters:
filename File to redirect debug info Absolutely nothing is check. You have to pass in a correct filename

Definition at line 116 of file gdcmDebug.cxx.

References DebugFlag, OutputFileStream, and OutputToFile.

00117 {
00118    OutputToFile = true;  // Just in case ... 
00119    DebugFlag   = true;  // Just in case ...
00120    if ( OutputFileStream.is_open() )
00121       OutputFileStream.close();
00122    OutputFileStream.open( filename.c_str() );
00123 }

void GDCM_NAME_SPACE::Debug::SetOutputToFile bool  flag  )  [static]
 

Accessor.

Parameters:
flag whether we want to redirect to file

Definition at line 96 of file gdcmDebug.cxx.

References OutputToFile.

00097 {
00098    OutputToFile = flag;
00099 }

void GDCM_NAME_SPACE::Debug::SetWarningFlag bool  flag  )  [static]
 

Sets the warning flag.

Parameters:
flag Set the warning flag

Definition at line 68 of file gdcmDebug.cxx.

References DebugFlag, LogFlag, and WarningFlag.

00069 {
00070    // Cannot unset Warning flag if Debug flag is on or if LogFlag is on.
00071    if (flag == false)
00072    { 
00073       if (DebugFlag == true)
00074          return;
00075       if (LogFlag == true)
00076          return;
00077    }
00078    WarningFlag = flag;
00079 }

static void GDCM_NAME_SPACE::Debug::WarningOff  )  [inline, static]
 

Sets the Warning Flag to false.

Definition at line 105 of file gdcmDebug.h.

00105 { SetWarningFlag(false); }      

static void GDCM_NAME_SPACE::Debug::WarningOn  )  [inline, static]
 

Sets the Warning Flag to true.

Definition at line 103 of file gdcmDebug.h.

00103 { SetWarningFlag(true);  }


Member Data Documentation

bool GDCM_NAME_SPACE::Debug::DebugFlag = false [static, private]
 

Definition at line 126 of file gdcmDebug.h.

Referenced by SetDebugFlag(), SetOutputFileName(), and SetWarningFlag().

const int GDCM_NAME_SPACE::Debug::LINE_LENGTH = 79 [static, private]
 

Definition at line 133 of file gdcmDebug.h.

bool GDCM_NAME_SPACE::Debug::LogFlag = false [static, private]
 

Definition at line 125 of file gdcmDebug.h.

Referenced by SetLogFlag(), and SetWarningFlag().

std::ofstream GDCM_NAME_SPACE::Debug::OutputFileStream [static, private]
 

Definition at line 130 of file gdcmDebug.h.

Referenced by GetOutput(), SetOutputFileName(), and ~Debug().

bool GDCM_NAME_SPACE::Debug::OutputToFile = false [static, private]
 

Definition at line 128 of file gdcmDebug.h.

Referenced by GetOutput(), GetOutputToFile(), SetOutputFileName(), and SetOutputToFile().

std::ostream & GDCM_NAME_SPACE::Debug::StandardStream = std::cerr [static, private]
 

Definition at line 131 of file gdcmDebug.h.

Referenced by GetOutput().

bool GDCM_NAME_SPACE::Debug::WarningFlag = false [static, private]
 

Definition at line 124 of file gdcmDebug.h.

Referenced by SetDebugFlag(), SetLogFlag(), and SetWarningFlag().


The documentation for this class was generated from the following files:
Generated on Fri Aug 24 13:01:24 2007 for gdcm by  doxygen 1.4.6