Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MsqDebug Class Reference

Run-time activation/deactivation of debug flags. More...

#include <MsqDebug.hpp>

Collaboration diagram for MsqDebug:

Classes

class  FormatPrinter
 
class  InitializeFlags
 

Public Types

enum  { WARN = 1, INFO = 2 }
 
enum  { WARN = 1, INFO = 2 }
 

Static Public Member Functions

static void enable (unsigned flag)
 Enable a debug flag. More...
 
static void disable (unsigned flag)
 Disable a debug flag. More...
 
static void set (unsigned flag, bool state)
 Set a debug flag. More...
 
static bool get (unsigned flag)
 Check a debug flag. More...
 
static void disable_all ()
 Disable all debug streams. More...
 
static msq_stdio::ostream & get_stream (unsigned flag)
 Get the output stream to be used for a given debug flag. More...
 
static void set_stream (unsigned flag, msq_stdio::ostream &stream)
 Set the output stream to be used for a given debug flag. More...
 
static void enable (unsigned flag)
 Enable a debug flag. More...
 
static void disable (unsigned flag)
 Disable a debug flag. More...
 
static void set (unsigned flag, bool state)
 Set a debug flag. More...
 
static bool get (unsigned flag)
 Check a debug flag. More...
 
static void disable_all ()
 Disable all debug streams. More...
 
static msq_stdio::ostream & get_stream (unsigned flag)
 Get the output stream to be used for a given debug flag. More...
 
static void set_stream (unsigned flag, msq_stdio::ostream &stream)
 Set the output stream to be used for a given debug flag. More...
 

Static Private Attributes

static msq_std::vector
< msq_stdio::ostream * > 
streams
 
static msq_std::vector< bool > flags
 
static InitializeFlags init
 

Detailed Description

Run-time activation/deactivation of debug flags.

Author
Jason Kraftcheck
Date
2004-10-18

Wrap static functions for managing debug flags and associated output streams. Output is expected do be done using the provided macros MSQ_DBGOUT, MSQ_PRINT, and MSQ_DBG.

The default output stream for all flags is cout.

Definition at line 87 of file includeLinks/MsqDebug.hpp.

Member Enumeration Documentation

anonymous enum
Enumerator
WARN 
INFO 

Definition at line 92 of file includeLinks/MsqDebug.hpp.

anonymous enum
Enumerator
WARN 
INFO 

Definition at line 92 of file src/Misc/MsqDebug.hpp.

Member Function Documentation

static void disable ( unsigned  flag)
inlinestatic

Disable a debug flag.

Definition at line 100 of file includeLinks/MsqDebug.hpp.

References MsqDebug::set().

100 { set( flag, false ); }
static void set(unsigned flag, bool state)
Set a debug flag.

Here is the call graph for this function:

static void disable ( unsigned  flag)
inlinestatic

Disable a debug flag.

Definition at line 100 of file src/Misc/MsqDebug.hpp.

References MsqDebug::set().

100 { set( flag, false ); }
static void set(unsigned flag, bool state)
Set a debug flag.

Here is the call graph for this function:

void disable_all ( )
static

Disable all debug streams.

Definition at line 76 of file Misc/MsqDebug.cpp.

References MsqDebug::flags.

77 {
78  flags.clear();
79 }
static msq_std::vector< bool > flags
static void disable_all ( )
static

Disable all debug streams.

static void enable ( unsigned  flag)
inlinestatic

Enable a debug flag.

Definition at line 98 of file src/Misc/MsqDebug.hpp.

References MsqDebug::set().

98 { set( flag, true ); }
static void set(unsigned flag, bool state)
Set a debug flag.

Here is the call graph for this function:

static void enable ( unsigned  flag)
inlinestatic

Enable a debug flag.

Definition at line 98 of file includeLinks/MsqDebug.hpp.

References MsqDebug::set().

98 { set( flag, true ); }
static void set(unsigned flag, bool state)
Set a debug flag.

Here is the call graph for this function:

bool get ( unsigned  flag)
static

Check a debug flag.

Definition at line 54 of file Misc/MsqDebug.cpp.

References MsqDebug::flags.

Referenced by MsqDebug::FormatPrinter::print().

55 {
56  return flag < flags.size() && flags[flag];
57 }
static msq_std::vector< bool > flags

Here is the caller graph for this function:

static bool get ( unsigned  flag)
static

Check a debug flag.

static msq_stdio::ostream& get_stream ( unsigned  flag)
static

Get the output stream to be used for a given debug flag.

msq_stdio::ostream & get_stream ( unsigned  flag)
static

Get the output stream to be used for a given debug flag.

Definition at line 81 of file Misc/MsqDebug.cpp.

References MsqDebug::streams.

Referenced by MsqDebug::FormatPrinter::print().

82 {
83  if (flag < streams.size())
84  return *streams[flag];
85  else
86  return msq_stdio::cout;
87 }
static msq_std::vector< msq_stdio::ostream * > streams

Here is the caller graph for this function:

static void set ( unsigned  flag,
bool  state 
)
static

Set a debug flag.

void set ( unsigned  flag,
bool  state 
)
static

Set a debug flag.

Definition at line 59 of file Misc/MsqDebug.cpp.

References MsqDebug::flags.

Referenced by MsqDebug::disable(), and MsqDebug::enable().

60 {
61  if (state)
62  {
63  if (flag >= flags.size())
64  {
65  flags.resize(flag+1);
66  }
67  flags[flag] = true;
68  }
69  else
70  {
71  if (flag < flags.size())
72  flags[flag] = false;
73  }
74 }
static msq_std::vector< bool > flags

Here is the caller graph for this function:

void set_stream ( unsigned  flag,
msq_stdio::ostream &  stream 
)
static

Set the output stream to be used for a given debug flag.

Definition at line 89 of file Misc/MsqDebug.cpp.

References i, and MsqDebug::streams.

90 {
91  if (flag >= streams.size())
92  {
93  size_t old_size = streams.size();
94  streams.resize( flag );
95  for (unsigned i = old_size; i < flag; ++i)
96  streams[i] = &msq_stdio::cout;
97  }
98  streams[flag] = &stream;
99 }
static msq_std::vector< msq_stdio::ostream * > streams
blockLoc i
Definition: read.cpp:79
static void set_stream ( unsigned  flag,
msq_stdio::ostream &  stream 
)
static

Set the output stream to be used for a given debug flag.

Member Data Documentation

msq_std::vector< bool > flags
staticprivate

Definition at line 139 of file includeLinks/MsqDebug.hpp.

Referenced by MsqDebug::disable_all(), MsqDebug::get(), and MsqDebug::set().

MsqDebug::InitializeFlags init
staticprivate

Definition at line 140 of file includeLinks/MsqDebug.hpp.

msq_std::vector< msq_stdio::ostream * > streams
staticprivate

Definition at line 138 of file includeLinks/MsqDebug.hpp.

Referenced by MsqDebug::get_stream(), and MsqDebug::set_stream().


The documentation for this class was generated from the following files: