00001
00002
00003
00004
00005
00006
00007
00008 #include "BaBar/BaBar.hh"
00009
00010 #include "CdbBdb/CdbBdbObjectCreator.hh"
00011
00012 #include "CdbBase/Cdb.hh"
00013 #include "CdbBase/CdbDatabase.hh"
00014 #include "CdbBase/CdbCondition.hh"
00015 #include "CdbBase/CdbObject.hh"
00016
00017 #include "CdbBdb/CdbBdb.hh"
00018 #include "CdbBdb/CdbBdbObject.hh"
00019 #include "CdbBdb/CdbBdbHintProvider.hh"
00020
00021 #include "BdbTime/BdbTime.hh"
00022
00023 #include <ErrLogger/ErrLog.hh>
00024 using std::endl;
00025
00026 CdbStatus
00027 CdbBdbObjectCreator::hint( BdbRefAny& theHint,
00028 const CdbConditionPtr& theConditionPtr,
00029 const BdbTime& theBegin,
00030 const BdbTime& theEnd )
00031 {
00032 CdbStatus result = CdbStatus::Error;
00033
00034 do {
00035
00036
00037
00038 CdbPtr cdbPtr = theConditionPtr->parentDatabase( )->parent( );
00039 if( cdbPtr.isNull( )) break;
00040
00041
00042
00043
00044 const char* objectTechnology = cdbPtr->technologyName( );
00045
00046 if( 0 != strcmp( CdbBdb::technology( ),
00047 objectTechnology )) {
00048
00049 ErrMsg(error) << "an object pointer passed into this procedure does not" << endl
00050 << "match the expected database technology." << endl
00051 << " EXPECTED: \"" << CdbBdb::technology( ) << "\"" << endl
00052 << " FOUND: \"" << objectTechnology << "\"" << endmsg;
00053 break;
00054 }
00055
00056
00057
00058 CdbBdbHintProvider* hpPtr = dynamic_cast<CdbBdbHintProvider*>( theConditionPtr.get( ));
00059 if( 0 == hpPtr ) break;
00060
00061 result = hpPtr->hint( theHint,
00062 theBegin,
00063 theEnd );
00064 } while( false );
00065
00066 return result;
00067 }
00068
00069 CdbStatus
00070 CdbBdbObjectCreator::verify( const BdbRefAny& theHint,
00071 const BdbHandle(BdbObject)& thePersObj,
00072 const CdbConditionPtr& theConditionPtr )
00073 {
00074 CdbStatus result = CdbStatus::Error;
00075
00076 do {
00077
00078
00079
00080 CdbPtr cdbPtr = theConditionPtr->parentDatabase( )->parent( );
00081 if( cdbPtr.isNull( )) break;
00082
00083
00084
00085
00086 const char* objectTechnology = cdbPtr->technologyName( );
00087
00088 if( 0 != strcmp( CdbBdb::technology( ),
00089 objectTechnology )) {
00090
00091 ErrMsg(error) << "an object pointer passed into this procedure does not" << endl
00092 << "match the expected database technology." << endl
00093 << " EXPECTED: \"" << CdbBdb::technology( ) << "\"" << endl
00094 << " FOUND: \"" << objectTechnology << "\"" << endmsg;
00095 break;
00096 }
00097
00098
00099
00100 CdbBdbHintProvider* hpPtr = dynamic_cast<CdbBdbHintProvider*>( theConditionPtr.get( ));
00101 if( 0 == hpPtr ) break;
00102
00103 result = hpPtr->verify( theHint,
00104 thePersObj );
00105 } while( false );
00106
00107 return result;
00108 }
00109
00110 CdbStatus
00111 CdbBdbObjectCreator::object( CdbObjectPtr& theObjectPtr,
00112 const CdbConditionPtr& theConditionPtr,
00113 const BdbTime& theBeginOriginalValidity,
00114 const BdbTime& theEndOriginalValidity,
00115 const BdbTime& theBeginValidity,
00116 const BdbTime& theEndValidity,
00117 const BdbTime& theBeginDuration,
00118 const BdbTime& theEndDuration,
00119 const BdbTime& theInsertionTime,
00120 const BdbHandle(BdbObject)& thePersObj )
00121 {
00122
00123
00124 theObjectPtr = new CdbBdbObject( theConditionPtr,
00125 theBeginOriginalValidity,
00126 theEndOriginalValidity,
00127 theBeginValidity,
00128 theEndValidity,
00129 theBeginDuration,
00130 theEndDuration,
00131 theInsertionTime,
00132 thePersObj );
00133
00134 return CdbStatus::Success;
00135 }
00136
00137
00138
00139