Gaudi Framework, version v20r2

Generated: 18 Jul 2008

PoolDbTupleCallback.cpp

Go to the documentation of this file.
00001 // $Id: PoolDbTupleCallback.cpp,v 1.4 2008/01/17 13:20:52 marcocle Exp $
00002 //------------------------------------------------------------------------------
00003 //
00004 // Implementation of class :  PoolDbTupleCallback
00005 //
00006 // Author :                   Markus Frank
00007 //
00008 //------------------------------------------------------------------------------
00009 #include "GaudiPoolDb/PoolDbTupleCallback.h"
00010 #include "GaudiKernel/INTuple.h"
00011 #include "GaudiKernel/ISelectStatement.h"
00012 
00013 #include "StorageSvc/DbType.h"
00014 #include "StorageSvc/DbSelect.h"
00015 #include "StorageSvc/DbColumn.h"
00016 #include "StorageSvc/DbTypeInfo.h"
00017 #include "StorageSvc/DbDatabase.h"
00018 #include "StorageSvc/DbInstanceCount.h"
00019 
00020 static pool::DbInstanceCount::Counter* s_count = 
00021   pool::DbInstanceCount::getCounter(typeid(PoolDbTupleCallback));
00022 
00024 PoolDbTupleCallback::PoolDbTupleCallback(DataObject* pObj)
00025 : pool::DbDefaultDataHandler(),
00026   pool::DbObjectCallBack(0), 
00027   m_iter(0), m_cntH(pool::POOL_StorageType)
00028 {
00029   m_refCount = 1;
00030   setObject(pObj);
00031   s_count->increment();
00032 }
00033 
00035 PoolDbTupleCallback::~PoolDbTupleCallback()  
00036 {
00037   pool::deletePtr(m_iter);
00038   s_count->decrement();
00039   const pool::DbTypeInfo* typ = (const pool::DbTypeInfo*)shape();
00040   if ( typ ) typ->deleteRef();
00041 }
00042 
00044 pool::DataCallBack* PoolDbTupleCallback::clone() const     
00045 {
00046   PoolDbTupleCallback* cb = const_cast<PoolDbTupleCallback*>(this);
00047   cb->m_refCount++;
00048   return cb;
00049 }
00050 
00052 void PoolDbTupleCallback::release()
00053 {
00054   if ( --m_refCount <= 0 ) {
00055     delete this;
00056   }
00057 }
00058 
00060 void PoolDbTupleCallback::configure(const INTuple* pTuple, 
00061                                     const pool::DbTypeInfo* typ,
00062                                     const pool::DbContainer& cntH)  
00063 {
00064   pool::DbTypeInfo::Columns::const_iterator ic;
00065   const INTuple::ItemContainer& items = pTuple->items();
00066   const pool::DbTypeInfo::Columns& cols = typ->columns();
00067   size_t colsize = cols.size();
00068   m_map.resize(items.size()+1,-1);
00069   for(size_t item_no = 0; item_no < items.size(); ++item_no ) {
00070     int icc = 0;
00071     m_map[item_no] = -1;
00072     const std::string& itm_nam = items[item_no]->name();
00073     for (ic=cols.begin(); ic != cols.end(); ++ic, ++icc )  {
00074       if ( (*ic)->name() == itm_nam )  {
00075         m_map[item_no] = icc;
00076         break;
00077       }
00078     }
00079   }
00080   m_addr.resize(colsize);
00081   m_addr[colsize-1] = &m_stream;
00082   m_links.resize(m_map.size());
00083   m_plinks.resize(m_map.size());
00084   for(size_t i = 0; i < m_map.size(); ++i )  {
00085     m_plinks[i] = &m_links[i];
00086   }
00087   m_cntH = cntH;
00088   typ->addRef();
00089   setShape(typ);
00090 }
00091 
00092 pool::DbSelect* 
00093 PoolDbTupleCallback::select(ISelectStatement* sel)  {
00094   pool::deletePtr(m_iter);
00095   if ( m_cntH.isValid() )  {
00096     std::string criteria = (sel && (sel->type() & ISelectStatement::STRING))
00097       ? sel->criteria() : std::string("");
00098     m_iter = new pool::DbSelect( criteria );
00099     pool::DbDatabase dbH = m_cntH.containedIn();
00100     m_iter->start(dbH, m_cntH.name());
00101   }
00102   return m_iter;
00103 }
00104 
00106 pool::DbStatus 
00107 PoolDbTupleCallback::start (CallType /* action_type */, 
00108                             void*    /* pObj        */, 
00109                             void**   /* context     */)
00110 {
00111   return pool::Success;
00112 }
00113 
00115 pool::DbStatus PoolDbTupleCallback::end(CallType /* action_type */, 
00116                                         void*    /* context     */) 
00117 {
00118   return pool::Success;
00119 }
00120 
00122 pool::DbStatus 
00123 PoolDbTupleCallback::bind(CallType                 action_type,
00124                           const pool::DbColumn* /* col_ident */,
00125                           int                      col_number,
00126                           void*                 /* context   */,
00127                           void**                   data_pointer)
00128 {
00129   switch(action_type)  {
00130   case GET:
00131     *data_pointer = m_addr[col_number];
00132     break;
00133   case PUT:
00134     *data_pointer = m_addr[col_number];
00135     break;
00136   }
00137   return pool::Success;
00138 }
00139 

Generated at Fri Jul 18 11:59:23 2008 for Gaudi Framework, version v20r2 by Doxygen version 1.5.1 written by Dimitri van Heesch, © 1997-2004