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

CdbBdbEnvProxy.cc

Go to the documentation of this file.
00001 // File and Version Information:
00002 //      $Id: CdbBdbEnvProxy.cc,v 1.8 2004/08/06 05:54:18 bartoldu Exp $
00003 
00004 /// The implementation of the CdbBdbEnvProxy class.
00005 /**
00006   * @see CdbBdbEnvProxy
00007   */
00008 #include "BaBar/BaBar.hh"
00009 
00010 #include "CdbBdb/CdbBdbEnvProxy.hh"
00011 #include "CdbBdb/CdbBdbProxyElement.hh"
00012 
00013 #include "CdbBase/CdbPathName.hh"
00014 #include "CdbBase/CdbTimeUtils.hh"
00015 
00016 #include "ErrLogger/ErrLog.hh"
00017 
00018 #include <string>
00019 using std::endl;
00020 
00021 template< class T, class P >
00022 CdbBdbEnvProxy<T,P>::CdbBdbEnvProxy( const char*         theDetectorName,
00023                                      const char*         theConditionName,
00024                                      BdbCondDefStrategy* theStrategy ) :
00025     CdbBdbProxyBase<T>( theStrategy )
00026 {
00027     if( 0 == theDetectorName )  ErrMsg(fatal) << "a null string passed where a detector name was expected." << endmsg;
00028     if( 0 == theConditionName ) ErrMsg(fatal) << "a null string passed where a condition name was expected." << endmsg;
00029 
00030   // Build full path name for the condition and make a subscription
00031 
00032     std::string pathName = std::string( CdbPathName::separator( )) +
00033                            std::string( theDetectorName ) +
00034                            std::string( CdbPathName::separator( )) +
00035                            std::string( theConditionName );
00036 
00037     subscribeCondition( pathName );
00038 }
00039 
00040 template< class T, class P >
00041 CdbBdbEnvProxy<T,P>::~CdbBdbEnvProxy( )
00042 { }
00043 
00044 template< class T, class P >
00045 T*
00046 CdbBdbEnvProxy<T,P>::redefinedFaultHandler( const std::vector<CdbBdbProxyElement>& listOfElements )
00047 {
00048   // Just one element is expected
00049 
00050     assert( 1 == listOfElements.size( ));  // if it's not one then the code is fatally broken
00051 
00052     BdbRef(BdbObject) objectRef  = listOfElements[0].objectRef();
00053     BdbRef(P)         pObjectRef = (const BdbRef(P)&) objectRef;
00054 
00055     if( !pObjectRef.isValid( ))
00056          ErrMsg(fatal) << "a persistent object " << pObjectRef.sprint( ) << endl
00057                        << "found in the condition \"" << listOfElements[0].name( ) << "\"" << endl
00058                        << "with an interval of validity: [ "
00059                        << CdbTimeUtils::time2string( listOfElements[0].validity( ).beginTime( ))
00060                        << " , "
00061                        << CdbTimeUtils::time2string( listOfElements[0].validity( ).endTime( ))
00062                        << " )" << endl
00063                        << "is not valid. The database may be corrupted or it's not available" << endl
00064                        << "for some other reason." << endmsg;
00065 
00066     return pObjectRef->transient( );
00067 }
00068 
00069 /////////////////
00070 // End Of File //
00071 /////////////////

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