00001 // $Id: TDbiExceptionLog.cxx,v 1.1 2011/01/18 05:49:19 finch Exp $ 00002 00003 00004 ////////////////////////////////////////////////////////////////////////// 00005 //////////////////////////// ROOT API //////////////////////////// 00006 ////////////////////////////////////////////////////////////////////////// 00007 00008 #include <iostream> 00009 00010 #include "TDbiExceptionLog.hxx" 00011 #include <TSK_DBI_Log.hxx> 00012 #include <MsgFormat.h> 00013 using std::endl; 00014 00015 ClassImp(TDbiExceptionLog) 00016 00017 // Definition of static data members 00018 // ********************************* 00019 00020 00021 TDbiExceptionLog TDbiExceptionLog::fgGELog; 00022 00023 // Definition of all member functions (static or otherwise) 00024 // ******************************************************* 00025 // 00026 // - ordered: ctors, dtor, operators then in alphabetical order. 00027 00028 //..................................................................... 00029 00030 TDbiExceptionLog::TDbiExceptionLog(const TDbiException* e) { 00031 00032 SK_DBI_Trace( "Creating TDbiExceptionLog" << " "); 00033 if ( e ) this->AddEntry(*e); 00034 00035 } 00036 //..................................................................... 00037 00038 00039 TDbiExceptionLog::~TDbiExceptionLog() { 00040 00041 00042 SK_DBI_Trace( "Destroying TDbiExceptionLog" << " "); 00043 00044 } 00045 00046 //..................................................................... 00047 00048 std::ostream& operator<<(std::ostream& os, const TDbiExceptionLog& el) { 00049 00050 if ( el.IsEmpty() ) { 00051 os << "The database exception log is empty" << endl; 00052 } 00053 else { 00054 os << "Database exception log:-" << endl; 00055 std::vector<TDbiException>::const_iterator itr(el.GetEntries().begin()), 00056 itrEnd(el.GetEntries().end()); 00057 while ( itr != itrEnd ) { 00058 os << *itr << endl; 00059 ++itr; 00060 } 00061 } 00062 00063 return os; 00064 00065 } 00066 00067 //..................................................................... 00068 /// 00069 /// 00070 /// Purpose: Add all entries from el. 00071 void TDbiExceptionLog::AddLog(const TDbiExceptionLog& el) { 00072 00073 const std::vector<TDbiException>& ve = el.GetEntries(); 00074 std::vector<TDbiException>::const_iterator itr(ve.begin()), itrEnd(ve.end()); 00075 while ( itr != itrEnd ) this->AddEntry(*itr++); 00076 00077 } 00078 00079 //..................................................................... 00080 /// Purpose: Copy exception log starting at 'start' (default 0) 00081 void TDbiExceptionLog::Copy(TDbiExceptionLog& that, UInt_t start) const { 00082 // 00083 // 00084 00085 00086 UInt_t maxEntry = fEntries.size(); 00087 while (start <= maxEntry ) that.AddEntry(fEntries[start++]); 00088 00089 } 00090 //..................................................................... 00091 /// Purpose: Print contents to cout. 00092 void TDbiExceptionLog::Print () const { 00093 // 00094 // 00095 00096 00097 std::cout << *this << std::endl; 00098 00099 } 00100 00101 00102 00103