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