00001
00002
00003
00004
00005
00006
00007
00008 #include "BaBar/BaBar.hh"
00009
00010 #include "CdbBase/CdbTransaction.hh"
00011 #include "CdbBase/Cdb.hh"
00012
00013 #include "ErrLogger/ErrLog.hh"
00014
00015 #include <iostream>
00016 using std::endl;
00017
00018 CdbTransaction::CdbTransaction( CdbTransaction::Mode theMode ) :
00019 CdbTransactionBase( )
00020 {
00021 const char* fatalMsg = "CdbTransaction::CdbTransaction(1) -- FATAL ERROR IN THE CONSTRUCTOR.";
00022
00023
00024
00025
00026 CdbPtr ptr = Cdb::instance( );
00027 if( ptr.isNull( ))
00028 ErrMsg(fatal) << fatalMsg << endl
00029 << " Failed to obtain the top-level API object for the default CDB 'technology'" << endl
00030 << " and its 'implementation'. The current application may not be properly configured." << endmsg;
00031
00032
00033
00034
00035
00036
00037
00038 _myImplPtr = ptr->transaction( theMode );
00039
00040 if( 0 == _myImplPtr )
00041 ErrMsg(fatal) << fatalMsg << endl
00042 << " The transaction management object obtained from the top-level API object is null." << endl
00043 << " The transaction may not have started in the specified mode: " << theMode << endmsg;
00044 }
00045
00046 CdbTransaction:: CdbTransaction( const CdbPtr& thePtr,
00047 CdbTransaction::Mode theMode ) :
00048 CdbTransactionBase( )
00049 {
00050 const char* fatalMsg = "CdbTransaction::CdbTransaction(2) -- FATAL ERROR IN THE CONSTRUCTOR.";
00051
00052
00053
00054 if( thePtr.isNull( ))
00055 ErrMsg(fatal) << fatalMsg << endl
00056 << " The null pointer passed where a valid top-level API object was expected." << endl
00057 << " It may be an indication of a problem in a logic of a caller's code.." << endmsg;
00058
00059
00060
00061
00062
00063
00064
00065 _myImplPtr = thePtr->transaction( theMode );
00066 if( 0 == _myImplPtr )
00067 ErrMsg(fatal) << fatalMsg << endl
00068 << " The transaction management object obtained from the top-level API object is null." << endl
00069 << " The transaction may not have started in the specified mode: " << theMode << endmsg;
00070 }
00071
00072 CdbTransaction:: CdbTransaction( const char* theTechnologyName,
00073 const char* theImplementationName,
00074 CdbTransaction::Mode theMode ) :
00075 CdbTransactionBase( )
00076 {
00077 const char* fatalMsg = "CdbTransaction::CdbTransaction(2) -- FATAL ERROR IN THE CONSTRUCTOR.";
00078
00079
00080
00081
00082 CdbPtr ptr = Cdb::instance( theTechnologyName,
00083 theImplementationName );
00084 if( ptr.isNull( ))
00085 ErrMsg(fatal) << fatalMsg << endl
00086 << " Failed to obtain the top-level API object for the specified CDB 'technology'" << endl
00087 << " and its 'implementation'. The current application may not be properly configured." << endl
00088 << " TECHNOLOGY : \"" << theTechnologyName << "\"" << endl
00089 << " IMPLEMENTATION: \"" << theImplementationName << "\"" << endmsg;
00090
00091
00092
00093
00094
00095
00096
00097 _myImplPtr = ptr->transaction( theMode );
00098 if( 0 == _myImplPtr )
00099 ErrMsg(fatal) << fatalMsg << endl
00100 << " The transaction management object obtained from the top-level API object is null." << endl
00101 << " The transaction may not have started in the specified mode: " << theMode << endmsg;
00102 }
00103
00104 CdbTransaction::~CdbTransaction( )
00105 {
00106 delete _myImplPtr;
00107 _myImplPtr = 0;
00108 }
00109
00110 void
00111 CdbTransaction::commitAndHold( )
00112 {
00113 _myImplPtr->commitAndHold( );
00114 }
00115
00116
00117
00118