00001 // File and Version Information: 00002 // $Id: CdbBdbSCollectionNameItr.cc,v 1.6 2002/09/23 22:41:07 gapon Exp $ 00003 00004 /// Implementation file for the CdbBdbSCollectionNameItr class. 00005 /** 00006 * @see CdbBdbSCollectionNameItr 00007 */ 00008 00009 #include "BaBar/BaBar.hh" 00010 00011 #include "CdbBdbShared/CdbBdbSCollectionNameItr.hh" 00012 00013 #include "CdbBdbShared/CdbBdbSCollectionElementP.hh" 00014 00015 #include <assert.h> 00016 00017 CdbBdbSCollectionNameItr::CdbBdbSCollectionNameItr( const BdbRef( BdbMap )& theMapRef ) : 00018 _isValid(false), 00019 _hasEverBeenAdvanced(false), 00020 _mapRef(theMapRef) 00021 { 00022 assert( ! BdbIsNull(theMapRef)); 00023 } 00024 00025 CdbBdbSCollectionNameItr::~CdbBdbSCollectionNameItr( ) 00026 { } 00027 00028 CdbStatus 00029 CdbBdbSCollectionNameItr::reset( ) 00030 { 00031 _isValid = false; 00032 _hasEverBeenAdvanced = false; 00033 00034 return CdbStatus::Success; 00035 } 00036 00037 bool 00038 CdbBdbSCollectionNameItr::next( ) 00039 { 00040 if( ! _hasEverBeenAdvanced ) _mapItr = _mapRef; 00041 00042 if( _mapItr.next( )) { 00043 00044 BdbHandle(CdbBdbSCollectionElementP) eH; 00045 eH = (const BdbRef(CdbBdbSCollectionElementP)&) (_mapItr->oid( )); 00046 00047 if( ! BdbIsNull(eH) && eH.isValid( )) { 00048 00049 _value = eH->name( ); 00050 00051 _isValid = true; 00052 _hasEverBeenAdvanced = true; 00053 } 00054 00055 } else { 00056 00057 // We're beyond the end of the collection 00058 00059 _isValid = false; 00060 _hasEverBeenAdvanced = false; 00061 } 00062 return _isValid; 00063 } 00064 00065 CdbBdbSCollectionNameItr::ValueType 00066 CdbBdbSCollectionNameItr::value( ) 00067 { 00068 if( ! _isValid ) { 00069 assert( 0 ); // FATAL ERROR: Inproper use of the iterator!!! 00070 return 0; 00071 } 00072 return _value.head( ); 00073 } 00074 00075 bool 00076 CdbBdbSCollectionNameItr::isValid( ) 00077 { 00078 return _isValid; 00079 } 00080 00081 CdbBdbSCollectionNameItr::InterfaceType* 00082 CdbBdbSCollectionNameItr::clone( ) const 00083 { 00084 // Note, that the resulting iterator will always be at the initial 00085 // state, even if the current one is not. See more details at the 00086 // header file. 00087 00088 return new CdbBdbSCollectionNameItr( _mapRef ); 00089 } 00090 00091 ///////////////// 00092 // End Of File // 00093 /////////////////
1.3-rc3