00001
00002
00003 #include "BaBar/BaBar.hh"
00004
00005
00006
00007
00008
00009
00010 #include "CdbBase/CdbAdapterItr.hh"
00011
00012 #include "ErrLogger/ErrLog.hh"
00013
00014 #include <assert.h>
00015 using std::endl;
00016
00017 template< class T,
00018 class I >
00019 CdbAdapterItr<T,I>::CdbAdapterItr( CdbIItr<I>* theInputItrPtr ) :
00020 _myInputItrPtr(theInputItrPtr)
00021 {
00022 const char* fatalStr = "CdbAdapterItr<T,I>::CdbAdapterItr() -- FATAL ERROR IN THE CONSTRUCTOR";
00023
00024 if( 0 == _myInputItrPtr )
00025 ErrMsg(fatal) << fatalStr << endl
00026 << " Null pointer passed as a parameter where a valid input iterator was expected." << endl
00027 << " An application may have a memory corruption problem or is inproperly configured.." << endmsg;
00028 }
00029
00030 template< class T,
00031 class I >
00032 CdbAdapterItr<T,I>::CdbAdapterItr( const CdbAdapterItr<T,I>& theItr ) :
00033 _myInputItrPtr(theItr._myInputItrPtr->clone( ))
00034 { }
00035
00036 template< class T,
00037 class I >
00038 CdbAdapterItr<T,I>::~CdbAdapterItr( )
00039 {
00040 if( 0 != _myInputItrPtr ) {
00041 delete _myInputItrPtr;
00042 _myInputItrPtr = 0;
00043 }
00044 }
00045
00046 template< class T,
00047 class I >
00048 CdbStatus
00049 CdbAdapterItr<T,I>::reset( )
00050 {
00051 return _myInputItrPtr->reset( );
00052 }
00053
00054 template< class T,
00055 class I >
00056 bool
00057 CdbAdapterItr<T,I>::next( )
00058 {
00059
00060
00061
00062 while( _myInputItrPtr->next( )) {
00063 if( isAccepted( _myInputItrPtr->value( ))) return true;
00064 }
00065 return false;
00066 }
00067
00068 template< class T,
00069 class I >
00070 T
00071 CdbAdapterItr<T,I>::value( )
00072 {
00073 const char* fatalStr = "CdbAdapterItr<T,I>::value() -- FATAL ERROR";
00074
00075 if( !_myInputItrPtr->isValid( ))
00076 ErrMsg(fatal) << fatalStr << endl
00077 << " Improper use of the iterator. It's either empty or it has not been" << endl
00078 << " advanced to the first element before calling the current method." << endmsg;
00079
00080 return toValue( _myInputItrPtr->value( ));
00081 }
00082
00083 template< class T,
00084 class I >
00085 bool
00086 CdbAdapterItr<T,I>::isValid( )
00087 {
00088 return _myInputItrPtr->isValid( );
00089 }
00090
00091
00092
00093