37 #define I_BESDebug_h 1
64 #define BESDEBUG( x, y ) do { if( BESDebug::IsSet( x ) ) *(BESDebug::GetStrm()) << "[" << BESDebug::GetPidStr() << "] " << y ; } while( 0 )
83 #define BESISDEBUG( x ) BESDebug::IsSet( x )
88 static map<string,bool> _debug_map ;
89 static ostream * _debug_strm ;
90 static bool _debug_strm_created ;
91 typedef map<string,bool>::const_iterator _debug_citer ;
92 typedef map<string,bool>::iterator _debug_iter ;
104 static void Set(
const string &flagName,
bool value )
106 if( flagName ==
"all" && value )
108 _debug_iter i = _debug_map.begin() ;
109 _debug_iter e = _debug_map.end() ;
115 _debug_map[flagName] = value ;
126 _debug_citer a = _debug_map.find(
"all" ) ;
127 _debug_citer i = _debug_map.find( flagName ) ;
128 if( i == _debug_map.end() )
130 if( a == _debug_map.end() )
132 _debug_map[flagName] = false ;
136 _debug_map[flagName] = true ;
145 static bool IsSet(
const string &flagName )
147 _debug_citer i = _debug_map.find( flagName ) ;
148 if( i != _debug_map.end() )
151 i = _debug_map.find(
"all" ) ;
152 if( i != _debug_map.end() )
185 static void SetStrm( ostream *strm,
bool created )
187 if( _debug_strm_created && _debug_strm )
189 _debug_strm->flush();
193 else if( _debug_strm )
195 _debug_strm->flush() ;
199 _debug_strm = &cerr ;
200 _debug_strm_created = false ;
205 _debug_strm_created = created ;
208 static void SetUp(
const string &values ) ;
209 static void Help( ostream &strm ) ;
212 #endif // I_BESDebug_h