| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Public Member Functions | Protected Member Functions | Protected Attributes

# PoolDbDataConnection Class Reference

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

`#include <PoolDbDataConnection.h>`

Inheritance diagram for PoolDbDataConnection:
[legend]
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 38 of file PoolDbDataConnection.cpp.

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

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

Standard destructor.

Definition at line 48 of file PoolDbDataConnection.cpp.

                                                        {
      s_connectionCount->decrement();
    }

## Member Function Documentation

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

Open data stream in read mode.

Implements Gaudi::IDataConnection.

Definition at line 55 of file PoolDbDataConnection.h.

    {     return i_connect();          }

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

Open data stream in write mode.

Implements Gaudi::IDataConnection.

Definition at line 57 of file PoolDbDataConnection.h.

    {return i_connect();    }

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

Access to POOL database handle.

Definition at line 49 of file PoolDbDataConnection.h.

    {     return m_dbH;                }

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

Release data stream.

Implements Gaudi::IDataConnection.

Definition at line 86 of file PoolDbDataConnection.cpp.

                                                 {
      if ( m_dbH.isValid() )  {
        m_dbH.close();
        m_dbH = DbDatabase(pool::POOL_StorageType);
        return StatusCode::SUCCESS;
      }
      return StatusCode::FAILURE;
    }

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

Internal connect call.

Open data stream.

Definition at line 53 of file PoolDbDataConnection.cpp.

                                                {
      DbAccessMode mode = (DbAccessMode)m_mode;
      // Note: (1<<4) means RECREATE existing: We need to get the GUID in order to not
      //       create a new one, if the catalog is pre-allocated
      bool open_existing = isEqualMode(mode,pool::READ)||isEqualMode(mode,pool::UPDATE|(1<<4));
      m_dbH = DbDatabase(m_domH.find(fid()));
      if ( !m_dbH.isValid() )  {
        std::string true_fid;
        pool::DbStatus sc = m_dbH.open(m_domH, pfn(), fid(), mode);
        if ( sc.isSuccess() && open_existing )  {
          m_dbH.param("FID",true_fid);
          if ( fid() == pfn() ) {
            m_fid = true_fid;
            m_dbH.close();
            sc = m_dbH.open(m_domH, pfn(), fid(), mode);
          }
          else if ( strcasecmp(true_fid.c_str(),fid().c_str()) != 0 )  {
            m_dbH.close();
            throw std::runtime_error("FID mismatch:\n\t\t\t\tFID="+
                                     fid()+" (catalog) <> \n\t\t\t\t"+
                                     true_fid+" (file) for PFN="+pfn());
            return BAD_DATA_CONNECTION;
          }
        }
        else if ( open_existing ) {
          return BAD_DATA_CONNECTION;
        }
        return sc.isSuccess() ? StatusCode::SUCCESS : StatusCode::FAILURE;
      }
      return StatusCode::SUCCESS;
    }

virtual bool PoolDbDataConnection::isConnected | ( | ) | const`[inline, virtual]`

Check if connected to data source.

Implements Gaudi::IDataConnection.

Definition at line 53 of file PoolDbDataConnection.h.

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

virtual StatusCode PoolDbDataConnection::read | ( | void * | const,
|  | size_t |
| ) |  | `[inline, virtual]`

Read raw byte buffer from input stream.

Implements Gaudi::IDataConnection.

Definition at line 61 of file PoolDbDataConnection.h.

      {  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()

Implements Gaudi::IDataConnection.

Definition at line 67 of file PoolDbDataConnection.h.

      {  return -1;                                                              }

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

Access to POOL transaction handle.

Definition at line 51 of file PoolDbDataConnection.h.

    {     return m_transaction;        }

virtual StatusCode PoolDbDataConnection::write | ( | const void * | ,
|  | int |
| ) |  | `[inline, virtual]`

Write raw byte buffer to output stream.

Implements Gaudi::IDataConnection.

Definition at line 64 of file PoolDbDataConnection.h.

      {  return StatusCode::FAILURE;                                             }

## Member Data Documentation

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.

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.

int PoolDbDataConnection::m_type`[protected]`

Definition at line 31 of file PoolDbDataConnection.h.

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

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines