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