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 "BESInfoList.h"
00034 #include "BESInfo.h"
00035 #include "TheBESKeys.h"
00036
00037 #define BES_DEFAULT_INFO_TYPE "txt"
00038
00039 BESInfoList *BESInfoList::_instance = 0 ;
00040
00041 BESInfoList::BESInfoList()
00042 {
00043 }
00044
00045 BESInfoList::~BESInfoList()
00046 {
00047 }
00048
00049 bool
00050 BESInfoList::add_info_builder( const string &info_type,
00051 p_info_builder info_builder )
00052 {
00053 BESInfoList::Info_citer i ;
00054 i = _info_list.find( info_type ) ;
00055 if( i == _info_list.end() )
00056 {
00057 _info_list[info_type] = info_builder ;
00058 return true ;
00059 }
00060 return false ;
00061 }
00062
00063 bool
00064 BESInfoList::rem_info_builder( const string &info_type )
00065 {
00066 BESInfoList::Info_iter i ;
00067 i = _info_list.find( info_type ) ;
00068 if( i != _info_list.end() )
00069 {
00070 _info_list.erase( i ) ;
00071 return true ;
00072 }
00073 return false ;
00074 }
00075
00076 BESInfo *
00077 BESInfoList::build_info( )
00078 {
00079 string info_type = "" ;
00080 bool found = false ;
00081 TheBESKeys::TheKeys()->get_value( "BES.Info.Type", info_type, found ) ;
00082
00083 if( !found || info_type == "" )
00084 info_type = BES_DEFAULT_INFO_TYPE ;
00085
00086 BESInfoList::Info_citer i ;
00087 i = _info_list.find( info_type ) ;
00088 if( i != _info_list.end() )
00089 {
00090 p_info_builder p = (*i).second ;
00091 if( p )
00092 {
00093 return p( info_type ) ;
00094 }
00095 }
00096 return 0 ;
00097 }
00098
00106 void
00107 BESInfoList::dump( ostream &strm ) const
00108 {
00109 strm << BESIndent::LMarg << "BESInfoList::dump - ("
00110 << (void *)this << ")" << endl ;
00111 BESIndent::Indent() ;
00112 if( _info_list.size() )
00113 {
00114 strm << BESIndent::LMarg << "registered builders:" << endl ;
00115 BESIndent::Indent() ;
00116 BESInfoList::Info_citer i = _info_list.begin() ;
00117 BESInfoList::Info_citer ie = _info_list.end() ;
00118 for( ; i != ie; i++ )
00119 {
00120 p_info_builder p = (*i).second ;
00121 if( p )
00122 {
00123 BESInfo *info = p( "dump" ) ;
00124 info->dump( strm ) ;
00125 delete info ;
00126 }
00127 else
00128 {
00129 strm << BESIndent::LMarg << "builder is null" << endl ;
00130 }
00131 }
00132 BESIndent::UnIndent() ;
00133 }
00134 else
00135 {
00136 strm << BESIndent::LMarg << "registered builders: none" << endl ;
00137 }
00138 BESIndent::UnIndent() ;
00139 }
00140
00141 BESInfoList *
00142 BESInfoList::TheList()
00143 {
00144 if( _instance == 0 )
00145 {
00146 _instance = new BESInfoList ;
00147 }
00148 return _instance ;
00149 }
00150