00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00036 #ifndef I_BESDebug_h
00037 #define I_BESDebug_h 1
00038
00039 #include <iostream>
00040 #include <map>
00041 #include <string>
00042
00043 using std::cerr ;
00044 using std::endl ;
00045 using std::ostream ;
00046 using std::map ;
00047 using std::string ;
00048
00061 #define BESDEBUG( x, y ) { if( BESDebug::IsSet( x ) ) *(BESDebug::GetStrm()) << y ; }
00062
00080 #define BESISDEBUG( x ) BESDebug::IsSet( x )
00081
00082 class BESDebug
00083 {
00084 private:
00085 static map<string,bool> _debug_map ;
00086 static ostream * _debug_strm ;
00087 static bool _debug_strm_created ;
00088 typedef map<string,bool>::const_iterator _debug_citer ;
00089 public:
00100 static void Set( const string &flagName, bool value )
00101 {
00102 _debug_map[flagName] = value ;
00103 }
00111 static void Register( const string &flagName )
00112 {
00113 _debug_citer i = _debug_map.find( flagName ) ;
00114 if( i == _debug_map.end() )
00115 {
00116 _debug_map[flagName] = false ;
00117 }
00118 }
00124 static bool IsSet( const string &flagName )
00125 {
00126 _debug_citer i = _debug_map.find( flagName ) ;
00127 if( i != _debug_map.end() )
00128 return (*i).second ;
00129 else
00130 i = _debug_map.find( "all" ) ;
00131 if( i != _debug_map.end() )
00132 return (*i).second ;
00133 else
00134 return false ;
00135 }
00142 static ostream * GetStrm()
00143 {
00144 return _debug_strm ;
00145 }
00161 static void SetStrm( ostream *strm, bool created )
00162 {
00163 if( _debug_strm_created && _debug_strm )
00164 {
00165 delete _debug_strm ;
00166 _debug_strm = NULL ;
00167 }
00168 if( !strm )
00169 {
00170 _debug_strm = &cerr ;
00171 _debug_strm_created = false ;
00172 }
00173 else
00174 {
00175 _debug_strm = strm ;
00176 _debug_strm_created = created ;
00177 }
00178 }
00179 static void SetUp( const string &values ) ;
00180 static void Help( ostream &strm ) ;
00181 } ;
00182
00183 #endif // I_BESDebug_h
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199