00001 // File and Version Information: 00002 // $Id: CdbBdbObjectVisitorContext.cc,v 1.5 2004/10/21 20:35:50 gapon Exp $ 00003 #include "BaBar/BaBar.hh" 00004 00005 /// The implementation of the CdbBdbObjectVisitorContext. 00006 /** 00007 * @see CdbBdbObjectVisitorContext 00008 */ 00009 00010 #include "BaBar/BaBar.hh" 00011 00012 #include "CdbBdb/CdbBdbObjectVisitorContext.hh" 00013 00014 #include <assert.h> 00015 00016 #include <iostream> 00017 using std::cerr; 00018 using std::endl; 00019 00020 CdbBdbObjectVisitorContext::CdbBdbObjectVisitorContext( ) 00021 { } 00022 00023 CdbBdbObjectVisitorContext::~CdbBdbObjectVisitorContext( ) 00024 { } 00025 00026 void 00027 CdbBdbObjectVisitorContext::reset( ) 00028 { 00029 _elements.clear( ); 00030 } 00031 00032 void 00033 CdbBdbObjectVisitorContext::push( const CdbBdbObjectVisitorContext::Element& theElement ) 00034 { 00035 _elements.push_back( theElement ); 00036 } 00037 00038 void 00039 CdbBdbObjectVisitorContext::pop( ) 00040 { 00041 if( size( ) > 0 ) _elements.pop_back( ); 00042 } 00043 00044 const CdbBdbObjectVisitorContext::Element& 00045 CdbBdbObjectVisitorContext::first( ) const 00046 { 00047 if( size( ) <= 0 ) { 00048 std::cerr << "CdbBdbObjectVisitorContext::first( ) -- an incorrect use of the method. No elements" << std::endl 00049 << "in the object's context." << std::endl; 00050 ::abort( ); 00051 } 00052 return _elements[0]; 00053 } 00054 00055 const CdbBdbObjectVisitorContext::Element& 00056 CdbBdbObjectVisitorContext::last( ) const 00057 { 00058 if( size( ) <= 0 ) { 00059 std::cerr << "CdbBdbObjectVisitorContext::last( ) -- an incorrect use of the method. No elements" << std::endl 00060 << "in the object's context." << std::endl; 00061 ::abort( ); 00062 } 00063 return _elements[size( ) - 1]; 00064 } 00065 00066 size_t 00067 CdbBdbObjectVisitorContext::size( ) const 00068 { 00069 return _elements.size( ); 00070 } 00071 00072 const CdbBdbObjectVisitorContext::Element& 00073 CdbBdbObjectVisitorContext::operator[]( size_t theIndex ) const 00074 { 00075 if( theIndex >= size( ) ) { 00076 std::cerr << "CdbBdbObjectVisitorContext::operator[] -- an incorrect use of the method. The index " << theIndex << " passed" << std::endl 00077 << "to the method is beyond the number of elements " << size( ) << "." << std::endl; 00078 ::abort( ); 00079 } 00080 return _elements[theIndex]; 00081 } 00082 00083 ///////////////// 00084 // End Of File // 00085 /////////////////
1.3-rc3