00001
00002
00003
00004
00005
00006
00007
00008 #include "BaBar/BaBar.hh"
00009
00010 #include "CdbBase/CdbEnvProxy.hh"
00011 #include "CdbBase/CdbProxyElement.hh"
00012 #include "CdbBase/CdbObject.hh"
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 >
00022 CdbEnvProxy<T>::CdbEnvProxy( const char* theDetectorName,
00023 const char* theConditionName,
00024 CdbDefStrategy* theStrategy ) :
00025 CdbProxyBase<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
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 >
00041 CdbEnvProxy<T>::~CdbEnvProxy( )
00042 { }
00043
00044 template< class T >
00045 T*
00046 CdbEnvProxy<T>::redefinedFaultHandler( const std::vector<CdbProxyElement>& listOfElements )
00047 {
00048 const char* fatalStr = "CdbEnvProxy<T>::redefinedFaultHandler() -- FATAL";
00049 const char* errorStr = "CdbEnvProxy<T>::redefinedFaultHandler() -- ERROR";
00050
00051
00052
00053 assert( 1 == listOfElements.size( ));
00054
00055 CdbObjectPtr objectPtr = listOfElements[0].objectPtr( );
00056
00057 if( objectPtr.isNull( ))
00058 ErrMsg(fatal) << fatalStr << endl
00059 << " A persistent object found in the condition is not valid." << endl
00060 << " CONDITION NAME: \"" << listOfElements[0].name( ) << "\"" << endl
00061 << " BEGIN VALIDITY: " << CdbTimeUtils::time2string( listOfElements[0].validity( ).beginTime( )) << endl
00062 << " END VALIDITY: " << CdbTimeUtils::time2string( listOfElements[0].validity( ).endTime( )) << endl
00063 << " The database may be corrupted or it's not available for some other reason." << endmsg;
00064
00065
00066
00067 T* transientObjectPtr = 0;
00068 if( CdbStatus::Success != CdbObject::transient( transientObjectPtr,
00069 objectPtr )) {
00070 ErrMsg(error) << errorStr << endl
00071 << " Failed to convert a persistent object into the transient one." << endl
00072 << " OBJECT ID: \"" << objectPtr->id( ) << "\"" << endl
00073 << " CONDITION NAME: \"" << listOfElements[0].name( ) << "\"" << endl
00074 << " BEGIN VALIDITY: " << CdbTimeUtils::time2string( listOfElements[0].validity( ).beginTime( )) << endl
00075 << " END VALIDITY: " << CdbTimeUtils::time2string( listOfElements[0].validity( ).endTime( )) << endl
00076 << " The current application may be improperly configured to set up the corresponding" << endl
00077 << " persistent-to-transient converter." << endmsg;
00078 }
00079
00080
00081
00082 return transientObjectPtr;
00083 }
00084
00085
00086
00087