BESReporterList.cc
Go to the documentation of this file.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
00033 #include "BESReporterList.h"
00034 #include "BESReporter.h"
00035
00036 BESReporterList *BESReporterList::_instance = 0 ;
00037
00038 BESReporterList::BESReporterList()
00039 {
00040 }
00041
00042 BESReporterList::~BESReporterList()
00043 {
00044 BESReporter *reporter = 0 ;
00045 BESReporterList::Reporter_iter i = _reporter_list.begin() ;
00046 for( ; i != _reporter_list.end(); i++ )
00047 {
00048 reporter = (*i).second ;
00049 if( reporter ) delete reporter ;
00050 _reporter_list.erase( i ) ;
00051 }
00052 }
00053
00054 bool
00055 BESReporterList::add_reporter( string reporter_name,
00056 BESReporter *reporter_object )
00057 {
00058 if( find_reporter( reporter_name ) == 0 )
00059 {
00060 _reporter_list[reporter_name] = reporter_object ;
00061 return true ;
00062 }
00063 return false ;
00064 }
00065
00066 BESReporter *
00067 BESReporterList::remove_reporter( string reporter_name )
00068 {
00069 BESReporter *ret = 0 ;
00070 BESReporterList::Reporter_iter i ;
00071 i = _reporter_list.find( reporter_name ) ;
00072 if( i != _reporter_list.end() )
00073 {
00074 ret = (*i).second;
00075 _reporter_list.erase( i ) ;
00076 }
00077 return ret ;
00078 }
00079
00080 BESReporter *
00081 BESReporterList::find_reporter( string reporter_name )
00082 {
00083 BESReporterList::Reporter_citer i ;
00084 i = _reporter_list.find( reporter_name ) ;
00085 if( i != _reporter_list.end() )
00086 {
00087 return (*i).second;
00088 }
00089 return 0 ;
00090 }
00091
00092 void
00093 BESReporterList::report( BESDataHandlerInterface &dhi )
00094 {
00095 BESReporter *reporter = 0 ;
00096 BESReporterList::Reporter_iter i = _reporter_list.begin() ;
00097 for( ; i != _reporter_list.end(); i++ )
00098 {
00099 reporter = (*i).second ;
00100 if( reporter ) reporter->report( dhi ) ;
00101 }
00102 }
00103
00111 void
00112 BESReporterList::dump( ostream &strm ) const
00113 {
00114 strm << BESIndent::LMarg << "BESReporterList::dump - ("
00115 << (void *)this << ")" << endl ;
00116 BESIndent::Indent() ;
00117 if( _reporter_list.size() )
00118 {
00119 strm << BESIndent::LMarg << "registered reporters:" << endl ;
00120 BESIndent::Indent() ;
00121 BESReporterList::Reporter_citer i = _reporter_list.begin() ;
00122 BESReporterList::Reporter_citer ie = _reporter_list.end() ;
00123 for( ; i != ie; i++ )
00124 {
00125 strm << BESIndent::LMarg << "reporter: " << (*i).first << endl ;
00126 BESIndent::Indent() ;
00127 BESReporter *reporter = (*i).second ;
00128 reporter->dump( strm ) ;
00129 BESIndent::UnIndent() ;
00130 }
00131 BESIndent::UnIndent() ;
00132 }
00133 else
00134 {
00135 strm << BESIndent::LMarg << "registered reporters: none" << endl ;
00136 }
00137 BESIndent::UnIndent() ;
00138 }
00139
00140 BESReporterList *
00141 BESReporterList::TheList()
00142 {
00143 if( _instance == 0 )
00144 {
00145 _instance = new BESReporterList ;
00146 }
00147 return _instance ;
00148 }
00149