MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::MsqDebug Class Reference

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

#include <MsqDebug.hpp>

+ Collaboration diagram for MBMesquite::MsqDebug:

Classes

class  FormatPrinter
class  InitializeFlags

Public Types

enum  { WARN = 1, INFO = 2 }

Static Public Member Functions

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

Static Private Attributes

static std::vector
< std::ostream * > 
streams
static 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 73 of file MsqDebug.hpp.


Member Enumeration Documentation

anonymous enum
Enumerator:
WARN 
INFO 

Definition at line 77 of file MsqDebug.hpp.

    {
        WARN = 1,
        INFO = 2
    };

Member Function Documentation

static void MBMesquite::MsqDebug::disable ( unsigned  flag) [inline, static]

Disable a debug flag.

Definition at line 89 of file MsqDebug.hpp.

    {
        set( flag, false );
    }

Disable all debug streams.

Definition at line 102 of file MsqDebug.cpp.

References flags.

Referenced by MBMesquite::VertexMover::loop_over_mesh().

{
    flags.clear();
}
static void MBMesquite::MsqDebug::enable ( unsigned  flag) [inline, static]

Enable a debug flag.

Definition at line 84 of file MsqDebug.hpp.

Referenced by main(), ParShapeImprover::run(), and MBMesquite::save_or_restore_debug_state().

    {
        set( flag, true );
    }
bool MBMesquite::MsqDebug::get ( unsigned  flag) [static]

Check a debug flag.

Definition at line 81 of file MsqDebug.cpp.

References flags.

Referenced by MBMesquite::MsqDebug::FormatPrinter::print(), and MBMesquite::save_or_restore_debug_state().

{
    return flag < flags.size() && flags[flag];
}
std::ostream & MBMesquite::MsqDebug::get_stream ( unsigned  flag) [static]

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

Definition at line 107 of file MsqDebug.cpp.

References streams.

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

{
    if( flag < streams.size() )
        return *streams[flag];
    else
        return std::cout;
}
void MBMesquite::MsqDebug::set ( unsigned  flag,
bool  state 
) [static]

Set a debug flag.

Definition at line 86 of file MsqDebug.cpp.

References flags.

{
    if( state )
    {
        if( flag >= flags.size() )
        {
            flags.resize( flag + 1 );
        }
        flags[flag] = true;
    }
    else
    {
        if( flag < flags.size() ) flags[flag] = false;
    }
}
void MBMesquite::MsqDebug::set_stream ( unsigned  flag,
std::ostream &  stream 
) [static]

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

Definition at line 115 of file MsqDebug.cpp.

References streams.

{
    if( flag >= streams.size() )
    {
        size_t old_size = streams.size();
        streams.resize( flag );
        for( unsigned i = old_size; i < flag; ++i )
            streams[i] = &std::cout;
    }
    streams[flag] = &stream;
}

Member Data Documentation

std::vector< bool > MBMesquite::MsqDebug::flags [static, private]

Definition at line 132 of file MsqDebug.hpp.

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

Definition at line 133 of file MsqDebug.hpp.

std::vector< std::ostream * > MBMesquite::MsqDebug::streams [static, private]

Definition at line 131 of file MsqDebug.hpp.

Referenced by get_stream(), and set_stream().

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines