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

CdbBdbNTupleProxy.cc

Go to the documentation of this file.
00001 // File and Version Information:
00002 //      $Id: CdbBdbNTupleProxy.cc,v 1.3 2004/08/06 05:54:31 bartoldu Exp $
00003 
00004 /// The implementation of the CdbBdbNTupleProxy class.
00005 /**
00006   * @see CdbBdbNTupleProxy
00007   */
00008 #include "BaBar/BaBar.hh"
00009 
00010 #include "CdbBdbTable/CdbBdbNTupleProxy.hh"
00011 #include "CdbBdbTable/CdbBdbNTupleP2T.hh"
00012 
00013 #include "CdbBdb/CdbBdbProxyElement.hh"
00014 
00015 #include <assert.h>
00016 #include <iostream>
00017 using std::cout;
00018 using std::endl;
00019 
00020 template< class T, unsigned int NCOL >
00021 CdbBdbNTupleProxy<T,NCOL>::CdbBdbNTupleProxy( const char*         theConditionPathName,
00022                                               BdbCondDefStrategy* theStrategy ) :
00023     CdbBdbProxyBase< CdbCPtr< CdbNTuple< T, NCOL > > >( theStrategy )
00024 {
00025     assert( 0 != theConditionPathName );
00026 
00027     subscribeCondition( theConditionPathName );
00028 }
00029 
00030 template< class T, unsigned int NCOL >
00031 CdbBdbNTupleProxy<T,NCOL>::~CdbBdbNTupleProxy( )
00032 { }
00033 
00034 template< class T, unsigned int NCOL >
00035 CdbCPtr< CdbNTuple< T, NCOL > >*
00036 CdbBdbNTupleProxy<T,NCOL>::redefinedFaultHandler( const std::vector<CdbBdbProxyElement>& listOfElements )
00037 {
00038   // Just one element is expected
00039 
00040     assert( 1 == listOfElements.size( ));
00041 
00042     BdbRef(BdbObject) objectRef = listOfElements[0].objectRef();
00043     assert( objectRef.isValid( ));
00044 
00045   // Convert the persistent object into the transient form
00046 
00047     CdbCPtr< CdbNTuple< T, NCOL > >* ptr = new CdbCPtr< CdbNTuple< T, NCOL > >( );
00048 
00049     if( CdbStatus::Success != CdbBdbNTupleP2T<>::convert( *ptr,
00050                                                           objectRef )) {
00051 
00052         cout << "CdbBdbNTupleProxy<T,NCOL>::redefinedFaultHandler() - ERROR." << endl
00053              << "    failed to convert the persistent object " << objectRef.sprint( ) << " got from the database" << endl
00054              << "    for condition \"" << listOfElements[0].name( ).c_str( ) << "\" into a transient tuple." << endl;
00055 
00056         delete ptr;
00057         return 0;
00058     }
00059 
00060   // NOTE: That we're also returning the ownership over this object back
00061   //       to our caller.
00062 
00063     return ptr;
00064 }
00065 
00066 /////////////////
00067 // End Of File //
00068 /////////////////

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