Bdb packages | Design docs | Source docs | Guidelines | Recent releases

Search | Site Map .

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

/CdbBase/CdbItr.cc

Go to the documentation of this file.
00001 /// The implementation of the CdbItr class.
00002 /**
00003   * @see CdbItr
00004   */
00005 
00006 #include "BaBar/BaBar.hh"
00007 
00008 #include "CdbBase/CdbItr.hh"
00009 
00010 #include <assert.h>
00011 #include <string.h>
00012 #include <iostream.h>
00013 
00014 template < typename T >
00015 CdbItr<T>::CdbItr( ) :
00016     _myItr(0)
00017 {
00018 }
00019 
00020 template < typename T >
00021 CdbItr<T>::CdbItr( const CdbItr<T>& theItr ) :
00022     _myItr(0)
00023 {
00024     set( theItr._myItr );
00025 }
00026 
00027 template < typename T >
00028 CdbItr<T>::CdbItr( InterfaceType* thePtr ) :
00029     _myItr(thePtr)
00030 { }
00031 
00032 template < typename T >
00033 CdbItr<T>::~CdbItr( )
00034 {
00035     if( 0 != _myItr ) delete _myItr;
00036 }
00037 
00038 template < typename T >
00039 CdbItr<T>&
00040 CdbItr<T>::operator=( const CdbItr<T>& theItr )
00041 {
00042     if( this != &theItr ) set( theItr._myItr );
00043     return *this;
00044 }
00045 
00046 /*
00047 template < typename T >
00048 CdbItr<T>&
00049 CdbItr<T>::operator=( const InterfaceType* thePtr )
00050 {
00051     set( thePtr );
00052     return *this;
00053 }
00054 */
00055 
00056 template < typename T >
00057 CdbStatus
00058 CdbItr<T>::reset( )
00059 {
00060     if( 0 == _myItr ) return CdbStatus::Error;
00061     return _myItr->reset( );
00062 }
00063 
00064 template < typename T >
00065 bool
00066 CdbItr<T>::next( )
00067 {
00068     if( 0 == _myItr ) return false;
00069     return _myItr->next( );
00070 }
00071 
00072 template < typename T >
00073 CdbItr<T>::ValueType
00074 CdbItr<T>::value( )
00075 {
00076     assert( 0 != _myItr );
00077 
00078     if( 0 == _myItr )
00079         cout << "CdbItr<T>::value( ) -- ERROR." << endl
00080              << "    This is an attempt to use an iterator which was not" << endl
00081              << "    properly initialized. Expect the core dump." << endl;
00082 
00083     return _myItr->value( );
00084 }
00085 
00086 template < typename T >
00087 bool
00088 CdbItr<T>::isValid( )
00089 {
00090     return ( 0 != _myItr ) && _myItr->isValid( );
00091 }
00092 
00093 template < typename T >
00094 CdbItr<T>::InterfaceType*
00095 CdbItr<T>::clone( ) const
00096 {
00097     return new CdbItr<T>( *this );
00098 }
00099 
00100 template < typename T >
00101 void
00102 CdbItr<T>::set( const InterfaceType* thePtr )
00103 {
00104     if( thePtr != _myItr ) {
00105         if( 0 != _myItr ) {
00106             delete _myItr;
00107             _myItr = 0;
00108         }
00109         if( 0 != thePtr ) _myItr = thePtr->clone( );
00110     }
00111 }
00112 
00113 /////////////////
00114 // End Of File //
00115 /////////////////

 


BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us

Page Owner: Jacek Becla
Last Update: October 04, 2002