| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

# 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   m_ipar[0]=m_ipar[1]=0;
    00030   if ( m_token )  {
    00031     m_token->addRef();
    00032     return;
    00033   }
    00034   throw std::runtime_error("Invalid token (NULL) passed to PoolDbAddress");
    00035 }
    00036
    00038 PoolDbAddress::~PoolDbAddress()
    00039 {
    00040   pool::releasePtr(m_handler);
    00041   s_count->decrement();
    00042   unsigned int cnt = m_token->release();
    00043   if ( cnt != 0 ) {
    00044     if ( !(m_token->contID() == "/Event"      ||
    00045            m_token->contID() == "/FileRecords" ||
    00046            m_token->contID() == "/RunRecords" ||
    00047            clID() == CLID_RowWiseTuple        ||
    00048            clID() == CLID_ColumnWiseTuple ) )  {
    00049       std::cout << "PoolDbAddress::~PoolDbAddress> Token: " << cnt
    00050                 << "  " << m_token->dbID() << " :: "
    00051                 << m_token->contID() << std::endl
    00052                 << "Possible memory leak." << std::endl;
    00053     }
    00054   }
    00055 }
    00056
    00058 unsigned long PoolDbAddress::release()
    00059 {
    00060   int cnt = --m_refCount;
    00061   if ( 0 == cnt )   {
    00062     delete this;
    00063   }
    00064   return cnt;
    00065 }
    00066
    00068 const std::string* PoolDbAddress::par() const
    00069 {
    00070   m_par[0] = m_token->dbID();
    00071   m_par[1] = m_token->contID();
    00072   return m_par;
    00073 }
    00074
    00076 const unsigned long* PoolDbAddress::ipar() const
    00077 {
    00078   m_ipar[0] = m_token->oid().first;
    00079   m_ipar[1] = m_token->oid().second;
    00080   return m_ipar;
    00081 }
    00082
    00083 void PoolDbAddress::setHandler(pool::DataCallBack* h)
    00084 {
    00085   pool::releasePtr(m_handler);
    00086   m_handler = h;
    00087 }
    00088
    00089 bool PoolDbAddress::isValid()  const  {
    00090   const pool::Token::OID_t& oid = m_token->oid();
    00091   return oid.first != -1 && oid.second != -1;
    00092 }

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