| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# PoolDbDataConnection Class Reference

The DataConnection incanation for the usage in GaudiPoolDb. More...

`#include <PoolDbDataConnection.h>`

Collaboration diagram for PoolDbDataConnection:

[legend]

List of all members.

## 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.

## Detailed Description

The DataConnection incanation for the usage in GaudiPoolDb.

This entity interacts with the IODataManager from the GaudiUtils package and allows to connect refereneces between objects stored in POOL files.

M.Frank

Version:
  1.0

Date:
  20/10/2007

Definition at line 29 of file PoolDbDataConnection.h.

## Constructor & Destructor Documentation

PoolDbDataConnection::PoolDbDataConnection | ( | IInterface * | owner,
|  | const std::string & | nam,
|  | int | typ,
|  | int | mode,
|  | pool::DbDomain & | domH |
| ) |  |  |

Standard constructor.

Definition at line 34 of file PoolDbDataConnection.cpp.

    00035 : IDataConnection(own,nam), m_type(typ), m_mode(mode), m_domH(domH)
    00036 {
    00037   s_connectionCount->increment();
    00038   if ( typ == Gaudi::IIODataManager::FID && strncmp(nam.c_str(),"FID:",4) != 0 ) {
    00039     m_name = "FID:"+nam;
    00040   }
    00041 }

PoolDbDataConnection::~PoolDbDataConnection | ( |  | ) | `[virtual]`

Standard destructor.

Definition at line 44 of file PoolDbDataConnection.cpp.

    00044                                                     {
    00045   s_connectionCount->decrement();
    00046 }

## Member Function Documentation

StatusCode PoolDbDataConnection::i_connect | ( |  | ) | `[protected, virtual]`

Internal connect call.

Open data stream.

Definition at line 49 of file PoolDbDataConnection.cpp.

    00049                                             {
    00050   DbAccessMode mode = (DbAccessMode)m_mode;
    00051   bool open_existing = isEqualMode(mode,pool::READ)||isEqualMode(mode,pool::UPDATE)||(1<<4);
    00052   m_dbH = DbDatabase(m_domH.find(fid()));
    00053   if ( !m_dbH.isValid() )  {
    00054     std::string true_fid;
    00055     pool::DbStatus sc = m_dbH.open(m_domH, pfn(), fid(), mode);
    00056     if ( sc.isSuccess() && open_existing )  {
    00057       m_dbH.param("FID",true_fid);
    00058       if ( fid() == pfn() ) {
    00059         m_fid = true_fid;
    00060         m_dbH.close();
    00061         sc = m_dbH.open(m_domH, pfn(), fid(), mode);
    00062       }
    00063       else if ( strcasecmp(true_fid.c_str(),fid().c_str()) != 0 )  {
    00064         m_dbH.close();
    00065         throw std::runtime_error("FID mismatch:\n\t\t\t\tFID="+
    00066                                  fid()+" (catalog) <> \n\t\t\t\t"+
    00067                                  true_fid+" (file) for PFN="+pfn());
    00068         return BAD_DATA_CONNECTION;
    00069       }
    00070     }
    00071     else if ( open_existing ) {
    00072       return BAD_DATA_CONNECTION;
    00073     }
    00074     return sc.isSuccess() ? StatusCode::SUCCESS : StatusCode::FAILURE;
    00075   }
    00076   return StatusCode::SUCCESS;
    00077 }

pool::DbDatabase& PoolDbDataConnection::database | ( |  | ) | `[inline]`

Access to POOL database handle.

Definition at line 49 of file PoolDbDataConnection.h.

    00049 {     return m_dbH;                }

pool::DbTransaction& PoolDbDataConnection::transaction | ( |  | ) | `[inline]`

Access to POOL transaction handle.

Definition at line 51 of file PoolDbDataConnection.h.

    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.

    00053 {     return m_dbH.ptr() != 0;     }

virtual StatusCode PoolDbDataConnection::connectRead | ( |  | ) | `[inline, virtual]`

Open data stream in read mode.

Definition at line 55 of file PoolDbDataConnection.h.

    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.

    00057 {return i_connect();    }

StatusCode PoolDbDataConnection::disconnect | ( |  | ) | `[virtual]`

Release data stream.

Definition at line 80 of file PoolDbDataConnection.cpp.

    00080                                              {
    00081   if ( m_dbH.isValid() )  {
    00082     m_dbH.close();
    00083     m_dbH = DbDatabase(pool::POOL_StorageType);
    00084     return StatusCode::SUCCESS;
    00085   }
    00086   return StatusCode::FAILURE;
    00087 }

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.

    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.

    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.

    00068   {  return -1;                                                              }

## Member Data Documentation

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.

pool::DbTransaction PoolDbDataConnection::m_transaction`[protected]`

Transaction handle for this data source.

Definition at line 35 of file PoolDbDataConnection.h.

pool::DbDatabase PoolDbDataConnection::m_dbH`[protected]`

Database handle for this data source.

Definition at line 37 of file PoolDbDataConnection.h.

pool::DbDomain PoolDbDataConnection::m_domH`[protected]`

Domain handle specifying the storage domain.

Definition at line 39 of file PoolDbDataConnection.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/GaudiPoolDb/GaudiPoolDb/PoolDbDataConnection.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/GaudiPoolDb/src/PoolDbDataConnection.cpp