![]() |
|
|
Generated: 24 Nov 2008 |
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 clID() == CLID_RowWiseTuple || 00045 clID() == CLID_ColumnWiseTuple ) ) { 00046 std::cout << "PoolDbAddress::~PoolDbAddress> Token: " << cnt 00047 << " " << m_token->dbID() << " :: " 00048 << m_token->contID() << std::endl 00049 << "Possible memory leak." << std::endl; 00050 } 00051 } 00052 } 00053 00055 unsigned long PoolDbAddress::release() 00056 { 00057 int cnt = --m_refCount; 00058 if ( 0 == cnt ) { 00059 delete this; 00060 } 00061 return cnt; 00062 } 00063 00065 const std::string* PoolDbAddress::par() const 00066 { 00067 m_par[0] = m_token->dbID(); 00068 m_par[1] = m_token->contID(); 00069 return m_par; 00070 } 00071 00073 const unsigned long* PoolDbAddress::ipar() const 00074 { 00075 m_ipar[0] = m_token->oid().first; 00076 m_ipar[1] = m_token->oid().second; 00077 return m_ipar; 00078 } 00079 00080 void PoolDbAddress::setHandler(pool::DataCallBack* h) 00081 { 00082 pool::releasePtr(m_handler); 00083 m_handler = h; 00084 } 00085 00086 bool PoolDbAddress::isValid() const { 00087 const pool::Token::OID_t& oid = m_token->oid(); 00088 return oid.first != -1 && oid.second != -1; 00089 }