| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# PoolDbAddress.cpp

Go to the documentation of this file.

    00001 // $Id: PoolDbAddress.cpp,v 1.8 2008/01/17 13:20:52 marcocle Exp $
    00002 //====================================================================
    00003 //      PoolDbAddress implementation
    00004 //--------------------------------------------------------------------
    00005 //
    00006 //      Package    : System ( The LHCb Offline System)
    00007 //
    00008 //  Description: Pool opaque address implementation
    00009 //
    00010 //      Author     : M.Frank
    00011 //====================================================================
    00012
    00013 // Framework include files
    00014 #include "GaudiPoolDb/PoolDbAddress.h"
    00015 #include "StorageSvc/DataCallBack.h"
    00016 #include "StorageSvc/DbInstanceCount.h"
    00017 // C++ include files
    00018 #include <stdexcept>
    00019 #include <iostream>
    00020
    00021 static pool::DbInstanceCount::Counter* s_count =
    00022   pool::DbInstanceCount::getCounter(typeid(PoolDbAddress));
    00023
    00025 PoolDbAddress::PoolDbAddress(pool::Token* aToken)
    00026   : m_refCount(0), m_pRegistry(0), m_handler(0), m_token(aToken)
    00027 {
    00028   s_count->increment();
    00029   if ( m_token )  {
    00030     m_token->addRef();
    00031     return;
    00032   }
    00033   throw std::runtime_error("Invalid token (NULL) passed to PoolDbAddress");
    00034 }
    00035
    00037 PoolDbAddress::~PoolDbAddress()
    00038 {
    00039   pool::releasePtr(m_handler);
    00040   s_count->decrement();
    00041   unsigned int cnt = m_token->release();
    00042   if ( cnt != 0 ) {
    00043     if ( !(m_token->contID() == "/Event"      ||
    00044            m_token->contID() == "/FileRecords" ||
    00045            m_token->contID() == "/RunRecords" ||
    00046            clID() == CLID_RowWiseTuple        ||
    00047            clID() == CLID_ColumnWiseTuple ) )  {
    00048       std::cout << "PoolDbAddress::~PoolDbAddress> Token: " << cnt
    00049                 << "  " << m_token->dbID() << " :: "
    00050                 << m_token->contID() << std::endl
    00051                 << "Possible memory leak." << std::endl;
    00052     }
    00053   }
    00054 }
    00055
    00057 unsigned long PoolDbAddress::release()
    00058 {
    00059   int cnt = --m_refCount;
    00060   if ( 0 == cnt )   {
    00061     delete this;
    00062   }
    00063   return cnt;
    00064 }
    00065
    00067 const std::string* PoolDbAddress::par() const
    00068 {
    00069   m_par[0] = m_token->dbID();
    00070   m_par[1] = m_token->contID();
    00071   return m_par;
    00072 }
    00073
    00075 const unsigned long* PoolDbAddress::ipar() const
    00076 {
    00077   m_ipar[0] = m_token->oid().first;
    00078   m_ipar[1] = m_token->oid().second;
    00079   return m_ipar;
    00080 }
    00081
    00082 void PoolDbAddress::setHandler(pool::DataCallBack* h)
    00083 {
    00084   pool::releasePtr(m_handler);
    00085   m_handler = h;
    00086 }
    00087
    00088 bool PoolDbAddress::isValid()  const  {
    00089   const pool::Token::OID_t& oid = m_token->oid();
    00090   return oid.first != -1 && oid.second != -1;
    00091 }