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

CdbTransaction.cc

Go to the documentation of this file.
00001 // File and Version Information:
00002 //      $Id: CdbTransaction.cc,v 1.3 2005/02/02 15:59:14 gapon Exp $
00003 
00004 /// The implementation of the CdbTransaction.
00005 /**
00006   * @see CdbTransaction
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   // Find the top-level API object for the default "technology"
00024   // and "implementation"
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   // Get an instance of the transaction manager. The operation will also start
00033   // the transaction in the desired mode if none is available yet.
00034   //
00035   // NOTE: We're assuming that the returned object's ownership is also being
00036   //       transferred.
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   // Verify the top-level API object passed as the parameter.
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   // Get an instance of the transaction manager. The operation will also start
00060   // the transaction in the desired mode if none is available yet.
00061   //
00062   // NOTE: We're assuming that the returned object's ownership is also being
00063   //       transferred.
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   // Find the top-level API object for the specified "technology"
00080   // and "implementation"
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   // Get an instance of the transaction manager. The operation will also start
00092   // the transaction in the desired mode if none is available yet.
00093   //
00094   // NOTE: We're assuming that the returned object's ownership is also being
00095   //       transferred.
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 // End Of File //
00118 /////////////////

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