![]() |
|
|
Generated: 18 Jul 2008 |
#include <PoolDbDataConnection.h>
Collaboration diagram for PoolDbDataConnection:

This entity interacts with the IODataManager from the GaudiUtils package and allows to connect refereneces between objects stored in POOL files.
M.Frank
Definition at line 29 of file PoolDbDataConnection.h.
Public Member Functions | |
| PoolDbDataConnection (IInterface *owner, const std::string &nam, int typ, int mode, pool::DbDomain &domH) | |
| Standard constructor. | |
| virtual | ~PoolDbDataConnection () |
| Standard destructor. | |
| pool::DbDatabase & | database () |
| Access to POOL database handle. | |
| pool::DbTransaction & | transaction () |
| Access to POOL transaction handle. | |
| virtual bool | isConnected () const |
| Check if connected to data source. | |
| virtual StatusCode | connectRead () |
| Open data stream in read mode. | |
| virtual StatusCode | connectWrite (IoType) |
| Open data stream in write mode. | |
| virtual StatusCode | disconnect () |
| Release data stream. | |
| virtual StatusCode | read (void *const , size_t) |
| Read raw byte buffer from input stream. | |
| virtual StatusCode | write (const void *, int) |
| Write raw byte buffer to output stream. | |
| virtual long long int | seek (long long int, int) |
| Seek on the file described by ioDesc. Arguments as in seek(). | |
Protected Member Functions | |
| virtual StatusCode | i_connect () |
| Internal connect call. | |
Protected Attributes | |
| int | m_type |
| int | m_mode |
| Datasource access mode. | |
| pool::DbTransaction | m_transaction |
| Transaction handle for this data source. | |
| pool::DbDatabase | m_dbH |
| Database handle for this data source. | |
| pool::DbDomain | m_domH |
| Domain handle specifying the storage domain. | |
| PoolDbDataConnection::PoolDbDataConnection | ( | IInterface * | owner, | |
| const std::string & | nam, | |||
| int | typ, | |||
| int | mode, | |||
| pool::DbDomain & | domH | |||
| ) |
Standard constructor.
Definition at line 30 of file PoolDbDataConnection.cpp.
References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), pool::DbInstanceCount::Counter::increment(), m_name, and s_connectionCount.
00031 : IDataConnection(own,nam), m_type(typ), m_mode(mode), m_domH(domH) 00032 { 00033 s_connectionCount->increment(); 00034 if ( typ == Gaudi::IIODataManager::FID && strncmp(nam.c_str(),"FID:",4) != 0 ) { 00035 m_name = "FID:"+nam; 00036 } 00037 }
| PoolDbDataConnection::~PoolDbDataConnection | ( | ) | [virtual] |
Standard destructor.
Definition at line 40 of file PoolDbDataConnection.cpp.
References pool::DbInstanceCount::Counter::decrement(), and s_connectionCount.
00040 { 00041 s_connectionCount->decrement(); 00042 }
| StatusCode PoolDbDataConnection::i_connect | ( | ) | [protected, virtual] |
Internal connect call.
Definition at line 45 of file PoolDbDataConnection.cpp.
References pool::DbDatabase::close(), StatusCode::FAILURE, pool::DbDomain::find(), isEqualMode(), pool::DbStatus::isSuccess(), pool::DbHandleBase< T >::isValid(), m_dbH, m_domH, m_mode, pool::DbDatabase::open(), pool::DbDatabase::param(), pool::READ, StatusCode::SUCCESS, and pool::UPDATE.
Referenced by connectRead(), and connectWrite().
00045 { 00046 DbAccessMode mode = (DbAccessMode)m_mode; 00047 bool open_existing = isEqualMode(mode,pool::READ)||isEqualMode(mode,pool::UPDATE)||(1<<4); 00048 m_dbH = DbDatabase(m_domH.find(fid())); 00049 if ( !m_dbH.isValid() ) { 00050 std::string true_fid; 00051 pool::DbStatus sc = m_dbH.open(m_domH, pfn(), fid(), mode); 00052 if ( sc.isSuccess() && open_existing ) { 00053 m_dbH.param("FID",true_fid); 00054 if ( fid() == pfn() ) { 00055 m_fid = true_fid; 00056 m_dbH.close(); 00057 sc = m_dbH.open(m_domH, pfn(), fid(), mode); 00058 } 00059 else if ( strcasecmp(true_fid.c_str(),fid().c_str()) != 0 ) { 00060 m_dbH.close(); 00061 throw std::runtime_error("FID mismatch:\n\t\t\t\tFID="+ 00062 fid()+" (catalog) <> \n\t\t\t\t"+ 00063 true_fid+" (file) for PFN="+pfn()); 00064 return BAD_DATA_CONNECTION; 00065 } 00066 } 00067 else if ( open_existing ) { 00068 return BAD_DATA_CONNECTION; 00069 } 00070 return sc.isSuccess() ? StatusCode::SUCCESS : StatusCode::FAILURE; 00071 } 00072 return StatusCode::SUCCESS; 00073 }
| pool::DbDatabase& PoolDbDataConnection::database | ( | ) | [inline] |
Access to POOL database handle.
Definition at line 49 of file PoolDbDataConnection.h.
References m_dbH.
00049 { return m_dbH; }
| pool::DbTransaction& PoolDbDataConnection::transaction | ( | ) | [inline] |
Access to POOL transaction handle.
Definition at line 51 of file PoolDbDataConnection.h.
References m_transaction.
00051 { return m_transaction; }
| virtual bool PoolDbDataConnection::isConnected | ( | ) | const [inline, virtual] |
Check if connected to data source.
Definition at line 53 of file PoolDbDataConnection.h.
References m_dbH, and pool::DbHandleBase< T >::ptr().
| virtual StatusCode PoolDbDataConnection::connectRead | ( | ) | [inline, virtual] |
Open data stream in read mode.
Definition at line 55 of file PoolDbDataConnection.h.
References i_connect().
00055 { return i_connect(); }
| virtual StatusCode PoolDbDataConnection::connectWrite | ( | IoType | ) | [inline, virtual] |
Open data stream in write mode.
Definition at line 57 of file PoolDbDataConnection.h.
References i_connect().
00057 {return i_connect(); }
| StatusCode PoolDbDataConnection::disconnect | ( | ) | [virtual] |
Release data stream.
Definition at line 76 of file PoolDbDataConnection.cpp.
References pool::DbDatabase::close(), StatusCode::FAILURE, pool::DbHandleBase< T >::isValid(), m_dbH, pool::POOL_StorageType, and StatusCode::SUCCESS.
00076 { 00077 if ( m_dbH.isValid() ) { 00078 m_dbH.close(); 00079 m_dbH = DbDatabase(pool::POOL_StorageType); 00080 return StatusCode::SUCCESS; 00081 } 00082 return StatusCode::FAILURE; 00083 }
| virtual StatusCode PoolDbDataConnection::read | ( | void * | const, | |
| size_t | ||||
| ) | [inline, virtual] |
Read raw byte buffer from input stream.
Definition at line 61 of file PoolDbDataConnection.h.
References StatusCode::FAILURE.
00062 { return StatusCode::FAILURE; }
| virtual StatusCode PoolDbDataConnection::write | ( | const void * | , | |
| int | ||||
| ) | [inline, virtual] |
Write raw byte buffer to output stream.
Definition at line 64 of file PoolDbDataConnection.h.
References StatusCode::FAILURE.
00065 { return StatusCode::FAILURE; }
| virtual long long int PoolDbDataConnection::seek | ( | long long | int, | |
| int | ||||
| ) | [inline, virtual] |
Seek on the file described by ioDesc. Arguments as in seek().
Definition at line 67 of file PoolDbDataConnection.h.
int PoolDbDataConnection::m_type [protected] |
Definition at line 31 of file PoolDbDataConnection.h.
int PoolDbDataConnection::m_mode [protected] |
Datasource access mode.
Definition at line 33 of file PoolDbDataConnection.h.
Referenced by i_connect().
Transaction handle for this data source.
Definition at line 35 of file PoolDbDataConnection.h.
Referenced by transaction().
pool::DbDatabase PoolDbDataConnection::m_dbH [protected] |
Database handle for this data source.
Definition at line 37 of file PoolDbDataConnection.h.
Referenced by database(), disconnect(), i_connect(), and isConnected().
pool::DbDomain PoolDbDataConnection::m_domH [protected] |
Domain handle specifying the storage domain.
Definition at line 39 of file PoolDbDataConnection.h.
Referenced by i_connect().