00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #define DBCNV_DBSESSION_CPP
00018
00019 #include "GaudiKernel/System.h"
00020 #include "GaudiKernel/MsgStream.h"
00021
00022 #include "GaudiDb/IOODataBase.h"
00023 #include "GaudiDb/DbFederation.h"
00024 #include "GaudiDb/DbObject.h"
00025
00026 #include "DbSessionObj.h"
00027 #include "DbFederationObj.h"
00028 #include "DbDataBaseObj.h"
00029 #include "DbContainerObj.h"
00030
00031
00032 DbSession::DbSession(IOODataBase* db, IMessageSvc* msg, unsigned char type) {
00033 m_mode = DbOOMs::READ;
00034 m_type = type;
00035 m_info = 0;
00036 m_dbOOMs = db;
00037 m_msgSvc = msg;
00038 if ( 0 == m_dbOOMs ) {
00039 MsgStream log(m_msgSvc,System::moduleName());
00040 log << MSG::ERROR
00041 << System::moduleName()
00042 << "--> Access DbSession "
00043 << " Type:" << "UNKNOWN"
00044 << " Mode:" << DbOOMs::accessMode(m_mode)
00045 << " impossible. Cannot link to implementation."
00046 << endreq;
00047 return;
00048 }
00049 }
00050
00051
00052 DbSession::~DbSession() {
00053 clearEntries();
00054 if ( 0 != m_info ) m_info->release();
00055 }
00056
00057
00058 DbResult DbSession::open(DbAccessMode mode) {
00059 MsgStream log(m_msgSvc,m_dbOOMs==0 ? System::moduleName() : m_dbOOMs->driver());
00060 if ( 0 != m_dbOOMs ) {
00061 m_mode = mode;
00062 log << MSG::INFO
00063 << "--> Open DbSession "
00064 << " Type:" << m_dbOOMs->name()
00065 << " Mode:" << DbOOMs::accessMode(m_mode)
00066 << " " << m_name
00067 << endreq;
00068 if ( 0 == m_info && 0 != m_dbOOMs ) {
00069 m_info = m_dbOOMs->createSession();
00070 }
00071 return m_info ? m_info->open(mode) : DbOOMs::DbError;
00072 }
00073 return DbOOMs::DbError;
00074 }
00075
00076
00077 DbResult DbSession::close() {
00078 DbResult result = (0 == m_info ) ? DbOOMs::DbSuccess : m_info->close();
00079 MsgStream log(m_msgSvc,m_dbOOMs==0 ? System::moduleName() : m_dbOOMs->driver());
00080 std::string dbtyp((m_dbOOMs) ? m_dbOOMs->name() : "UNKNOWN");
00081 log << MSG::INFO
00082 << "--> Closed DbSession " << m_name
00083 << " Type:" << dbtyp
00084 << endreq;
00085 m_mode = DbOOMs::NOT_OPEN;
00086 return result;
00087 }
00088