00001
00002
00003
00004 #include "BaBar/BaBar.hh"
00005
00006 #include "CdbRoo/CdbRooObjectTranslatorRT.hh"
00007 #include "CdbRoo/CdbRooObjectR.hh"
00008 #include "CdbRoo/CdbRooObjectConvertor.hh"
00009
00010 #include "CdbBase/CdbObject.hh"
00011 #include "CdbBase/CdbTransaction.hh"
00012
00013 #include "ErrLogger/ErrLog.hh"
00014
00015 #include "TClass.h"
00016
00017 #include <iostream>
00018 using std::endl;
00019
00020 template< class R,
00021 class T >
00022 std::string
00023 CdbRooObjectTranslatorRT<R,T>::persistentType2Name( )
00024 {
00025 const char* fatalStr = "CdbRooObjectTranslatorRT<R,T>::persistentType2Name( ) -- FATAL";
00026
00027
00028
00029 std::string rTypeName = "";
00030 {
00031
00032
00033 CdbTransaction readOnlyTransaction;
00034
00035
00036
00037
00038 rTypeName = R::Class( )->GetName( );
00039
00040 if( !R::Class( )->InheritsFrom( CdbRooObjectR::Class( )))
00041 ErrMsg(fatal) << fatalStr << endl
00042 << " The passed as a parameter of the template type \"" << rTypeName << "\"" << endl
00043 << " doesn't correspond to a persistent class deriving from CdbRooObjectR, which is" << endl
00044 << " the very base class of payload objects of the current persistnet technology." << endmsg;
00045 }
00046 return rTypeName;
00047 }
00048
00049 template< class R,
00050 class T >
00051 CdbRooObjectTranslatorRT<R,T>::CdbRooObjectTranslatorRT( ) :
00052 CdbObjectTranslatorT<T>( persistentType2Name( ))
00053 { }
00054
00055 template< class R,
00056 class T >
00057 CdbStatus
00058 CdbRooObjectTranslatorRT<R,T>::toTransientT( T*& theTransientPtr,
00059 const CdbObjectPtr& theObjectPtr ) const
00060 {
00061 const char* errorStr = "CdbRooObjectTranslatorRT<R,T>::toTransientT( ) -- ERROR";
00062
00063
00064
00065
00066 CdbStatus result = CdbStatus::Error;
00067
00068 CdbCPtr<R> persObjectPtr;
00069
00070 if( CdbStatus::Success != ( result = CdbRooObjectConvertor::typeSafeNarrow( persObjectPtr,
00071 theObjectPtr ))) {
00072 ErrMsg(error) << errorStr << endl
00073 << " Failed to obtain a persistent handle out of the passed metadata object." << endl
00074 << " OBJECT ID: " << theObjectPtr->id( ) << endmsg;
00075 return result;
00076 }
00077
00078
00079
00080 return toTransientRT( theTransientPtr,
00081 persObjectPtr );
00082 }
00083
00084
00085
00086