CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CondCore/DBCommon/src/DbScopedTransaction.cc

Go to the documentation of this file.
00001 // local includes
00002 #include "CondCore/DBCommon/interface/DbSession.h"
00003 #include "CondCore/DBCommon/interface/DbTransaction.h"
00004 #include "CondCore/DBCommon/interface/DbScopedTransaction.h"
00005 
00006 cond::DbScopedTransaction::DbScopedTransaction( cond::DbSession& session ):
00007   m_session(session),m_locallyActive(false){
00008 }
00009 
00010 cond::DbScopedTransaction::~DbScopedTransaction(){
00011   if(m_locallyActive) m_session.transaction().rollback();
00012 }
00013 
00014 int cond::DbScopedTransaction::start(bool readOnly){
00015   if(m_locallyActive) return -1;
00016   int ret = m_session.transaction().start( readOnly );
00017   m_locallyActive = true;
00018   return ret;
00019 }
00020 
00021 int cond::DbScopedTransaction::commit(){
00022   if(!m_locallyActive) return -1;
00023   int ret = m_session.transaction().commit();
00024   m_locallyActive = false;
00025   return ret;
00026 }
00027 
00028 bool cond::DbScopedTransaction::rollback(){
00029   if(!m_locallyActive) return false;
00030   bool ret = m_session.transaction().rollback();
00031   m_locallyActive = false;
00032   return ret;
00033 }
00034 
00035 bool cond::DbScopedTransaction::isLocallyActive() const {
00036   return m_locallyActive;
00037 }
00038 
00039 int cond::DbScopedTransaction::isActive() const {
00040   return m_session.transaction().isActive();
00041 }
00042 
00043 bool cond::DbScopedTransaction::isReadOnly() const 
00044 {
00045   /*if(m_locallyActive) */return m_session.transaction().isReadOnly();
00046   //return true;
00047 }
00048