Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

CdbBdbSFolderPItr.cc

Go to the documentation of this file.
00001 // File and Version Information:
00002 //      $Id: CdbBdbSFolderPItr.cc,v 1.3 2002/09/23 22:41:09 gapon Exp $
00003 
00004 /// The implementation of the CdbBdbSFolderPItr class.
00005 /**
00006   * @see CdbBdbSFolderPItr
00007   */
00008 
00009 #include "BaBar/BaBar.hh"
00010 
00011 #include "CdbBdbShared/CdbBdbSFolderPItr.hh"
00012 
00013 #include "CdbBase/CdbPathName.hh"
00014 #include "CdbBdbShared/CdbBdbSFolderP.hh"
00015 
00016 #include <assert.h>
00017 
00018 CdbBdbSFolderPItr::CdbBdbSFolderPItr( const BdbRef(ooMap)& theMapRef ) :
00019     _isValid(false),
00020     _hasEverBeenAdvanced(false),
00021     _mapRef(theMapRef)
00022 { }
00023 
00024 CdbBdbSFolderPItr::~CdbBdbSFolderPItr( )
00025 { }
00026 
00027 CdbStatus
00028 CdbBdbSFolderPItr::reset( )
00029 {
00030     _isValid             = false;
00031     _hasEverBeenAdvanced = false;
00032 
00033     return CdbStatus::Success;
00034 }
00035 
00036 bool
00037 CdbBdbSFolderPItr::next( )
00038 {
00039     if( BdbIsNull(_mapRef)) {
00040 
00041       // There is only one ROOT directory at this catalog level.
00042 
00043         if( _hasEverBeenAdvanced )
00044             _isValid             = false;
00045         else {
00046 
00047             _value = CdbPathName::separator( );
00048 
00049             _isValid             = true;
00050             _hasEverBeenAdvanced = true;
00051         }
00052 
00053     } else {
00054 
00055       // Use the ooMap to get to the actual persistent folders and then
00056       // to their names.
00057 
00058         if( ! _hasEverBeenAdvanced ) _mapItr = _mapRef;
00059 
00060         if( _mapItr.next( )) {
00061 
00062             BdbHandle(CdbBdbSFolderP) folderH;
00063             folderH = (const BdbRef(CdbBdbSFolderP)&) (_mapItr->oid( ));
00064 
00065             if( ! BdbIsNull(folderH) && folderH.isValid( )) {
00066 
00067                 _value = folderH->name( );
00068 
00069                 _isValid             = true;
00070                 _hasEverBeenAdvanced = true;
00071             }
00072 
00073         } else {
00074 
00075           // We're beyond the end of the collection
00076 
00077             _isValid             = false;
00078             _hasEverBeenAdvanced = false;
00079         }
00080     }
00081     return _isValid;
00082 }
00083 
00084 CdbBdbSFolderPItr::ValueType
00085 CdbBdbSFolderPItr::value( )
00086 {
00087     if( ! _isValid ) {
00088         assert( 0 );        // FATAL ERROR: Inproper use of the iterator!!!
00089         return 0;
00090     }
00091     return _value.head( );
00092 }
00093 
00094 bool
00095 CdbBdbSFolderPItr::isValid( )
00096 {
00097     return _isValid;
00098 }
00099 
00100 CdbBdbSFolderPItr::InterfaceType*
00101 CdbBdbSFolderPItr::clone( ) const
00102 {
00103   // Note, that the resulting iterator will always be at the initial
00104   // state, even if the current one is not. See more details at the
00105   // header file.
00106 
00107     return new CdbBdbSFolderPItr( _mapRef );
00108 }
00109 
00110 /////////////////
00111 // End Of File //
00112 /////////////////

Generated on Mon Dec 5 18:22:02 2005 for CDB by doxygen1.3-rc3