| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# PoolDbIOHandler< T > Class Template Reference

`#include <PoolDbIOHandler.h>`

List of all members.

## Detailed Description

### template<class T>
class PoolDbIOHandler< T >

Definition at line 14 of file PoolDbIOHandler.h.

## Public Member Functions
| PoolDbIOHandler (const TypeH &typ, TClass *c)
| Initializing constructor.
virtual | ~PoolDbIOHandler ()
| Standard destructor.
virtual void | operator() (TBuffer &b, void *obj)
| ROOT I/O callback.
virtual void | get (TBuffer &b, void *obj)
| Callback for reading the object.
virtual void | put (TBuffer &b, void *obj)
| Callback for writing the object.
template<>
void | get (TBuffer &b, void *obj)
template<>
void | put (TBuffer &b, void *obj)
template<>
void | get (TBuffer &b, void *obj)
template<>
void | put (TBuffer &b, void *obj)
template<>
void | get (TBuffer &b, void *obj)
template<>
void | put (TBuffer &b, void *obj)
template<>
void | get (TBuffer &b, void *obj)
template<>
void | put (TBuffer &b, void *obj)
## Protected Types
typedef ROOT::Reflex::Type | TypeH
## Protected Attributes
TypeH | m_type
| LCG Reflection type.
TClass * | m_root
| ROOT persistent class description.

## Member Typedef Documentation

template<class T>

typedef ROOT::Reflex::Type PoolDbIOHandler< T >::TypeH`[protected]`

Definition at line 16 of file PoolDbIOHandler.h.

## Constructor & Destructor Documentation

template<class T>

PoolDbIOHandler< T >::PoolDbIOHandler | ( | const TypeH & | typ,
|  | TClass * | c |
| ) |  |  | `[inline]`

Initializing constructor.

Definition at line 23 of file PoolDbIOHandler.h.

    00023 : m_type(typ), m_root(c) {  }

template<class T>

virtual PoolDbIOHandler< T >::~PoolDbIOHandler | ( |  | ) | `[inline, virtual]`

Standard destructor.

Definition at line 26 of file PoolDbIOHandler.h.

    00026 {  }

## Member Function Documentation

template<class T>

void PoolDbIOHandler< T >::operator() | ( | TBuffer & | b,
|  | void * | obj |
| ) |  |  | `[inline, virtual]`

ROOT I/O callback.

Definition at line 67 of file PoolDbIOHandler.cpp.

    00067                                                           {
    00068   try {
    00069     if ( b.IsReading() )   {
    00070       get(b,obj);
    00071     }
    00072     else  {
    00073       put(b,obj);
    00074     }
    00075   }
    00076   catch( const std::exception& e )    {
    00077     std::string err = "Class:" + std::string(m_root->GetName()) + "> Exception in object I/O";
    00078     err += e.what();
    00079     throw std::runtime_error(err);
    00080   }
    00081   catch( ... )    {
    00082     std::string err = "Class:" + std::string(m_root->GetName()) + "> Exception in object I/O";
    00083     throw std::runtime_error(err);
    00084   }
    00085 }

template<class T>

virtual void PoolDbIOHandler< T >::get | ( | TBuffer & | b,
|  | void * | obj |
| ) |  |  | `[virtual]`

Callback for reading the object.

Parameters:

  | obj | [IN] Pointer to user object.

template<class T>

virtual void PoolDbIOHandler< T >::put | ( | TBuffer & | b,
|  | void * | obj |
| ) |  |  | `[virtual]`

Callback for writing the object.

Parameters:

  | obj | [IN] Pointer to user object.

template<>

void PoolDbIOHandler< SmartRefBase >::get | ( | TBuffer & | b,
|  | void * | obj |
| ) |  |  | `[inline]`

Definition at line 88 of file PoolDbIOHandler.cpp.

    00088                                                              {
    00089   UInt_t start, count;
    00090   SmartRefBase* ref = (SmartRefBase*)obj;
    00091   Version_t version = b.ReadVersion(&start, &count, m_root);
    00092   m_root->ReadBuffer(b, obj, version, start, count);
    00093   switch( ref->objectType() ) {
    00094    case SmartRefBase::DATAOBJECT:
    00095     {
    00096       SmartRef<DataObject>* r = (SmartRef<DataObject>*)obj;
    00097       (*r)(getCurrentDataObject());
    00098     }
    00099     break;
    00100   case SmartRefBase::CONTAINEDOBJECT:
    00101    {
    00102      SmartRef<ContainedObject>* r = (SmartRef<ContainedObject>*)obj;
    00103      (*r)(getCurrentDataObject());
    00104    }
    00105    break;
    00106   default:
    00107     std::cout << "Hit uninitialized smartRef!!!!" << std::endl;
    00108     break;
    00109   }
    00110 }

template<>

void PoolDbIOHandler< SmartRefBase >::put | ( | TBuffer & | b,
|  | void * | obj |
| ) |  |  | `[inline]`

Definition at line 113 of file PoolDbIOHandler.cpp.

    00113                                                              {
    00114   SmartRefBase* ref = (SmartRefBase*)obj;
    00115   SmartRef<DataObject>* r1 = (SmartRef<DataObject>*)ref;
    00116   DataObject* curr = getCurrentDataObject();
    00117   DataObject* pDO  = r1->data();
    00118   int hint = r1->hintID();
    00119   int link = r1->linkID();
    00120   if ( pDO )  {
    00121     switch( ref->objectType() ) {
    00122     case SmartRefBase::CONTAINEDOBJECT:
    00123       {
    00124         SmartRef<ContainedObject>* r2 = (SmartRef<ContainedObject>*)ref;
    00125         ContainedObject* p = r2->data();
    00126         if ( p )  {
    00127           const ObjectContainerBase* parent = p->parent();
    00128           if ( parent )  {
    00129             link = p->index();
    00130             pDO  = const_cast<ObjectContainerBase*>(parent);
    00131             break;
    00132           }
    00133         }
    00134       }
    00135       pDO = 0;
    00136       std::cout << "PoolDbIOHandler<SmartRefBase>::onWrite> "
    00137                 << "Found invalid smart reference with object "
    00138                 << "having no parent."
    00139                 << std::endl;
    00140       throw std::runtime_error("PoolDbIOHandler<SmartRefBase>::onWrite> "
    00141                                "Found invalid smart reference with object "
    00142                                "having no parent.");
    00143       break;
    00144     case SmartRefBase::DATAOBJECT:
    00145       link = StreamBuffer::INVALID;
    00146       break;
    00147     default:
    00148       break;
    00149     }
    00150     //if ( pDO == last_link_object && last_link_hint == -1 )  {
    00151     //  std::cout << "PoolDbIOHandler<SmartRefBase>::onWrite> "
    00152     //            << "Found invalid smart reference."
    00153     //            << std::endl;
    00154     //}
    00155     if ( pDO == last_link_object )  {
    00156       ref->set(curr, last_link_hint, link);
    00157       m_root->WriteBuffer(b, obj);
    00158       return;
    00159     }
    00160     else if ( pDO ) {
    00161       LinkManager* mgr = curr->linkMgr();
    00162       IRegistry*   reg = pDO->registry();
    00163       if ( reg && mgr )  {
    00164         hint = mgr->addLink(reg->identifier(), pDO);
    00165         last_link_hint   = hint;
    00166         last_link_object = pDO;
    00167       }
    00168     }
    00169     else {
    00170       hint = link = StreamBuffer::INVALID;
    00171     }
    00172   }
    00173   //if ( hint == StreamBuffer::INVALID )  {
    00174   //  std::cout << "PoolDbIOHandler<SmartRefBase>::onWrite> "
    00175   //            << "Found invalid smart reference."
    00176   //            << std::endl;
    00177   //}
    00178   ref->set(curr, hint, link);
    00179   m_root->WriteBuffer(b, obj);
    00180 }

template<>

void PoolDbIOHandler< ContainedObject >::get | ( | TBuffer & | b,
|  | void * | obj |
| ) |  |  | `[inline]`

Definition at line 183 of file PoolDbIOHandler.cpp.

    00183                                                                 {
    00184   UInt_t start, count;
    00185   Version_t version = b.ReadVersion(&start, &count, m_root);
    00186   m_root->ReadBuffer(b, obj, version, start, count);
    00187   ContainedObject* p = (ContainedObject*)obj;
    00188   p->setParent((ObjectContainerBase*)getCurrentDataObject());
    00189 }

template<>

void PoolDbIOHandler< ContainedObject >::put | ( | TBuffer & | b,
|  | void * | obj |
| ) |  |  | `[inline]`

Definition at line 192 of file PoolDbIOHandler.cpp.

    00192                                                                 {
    00193   m_root->WriteBuffer(b, obj);
    00194 }

template<>

void PoolDbIOHandler< Token >::get | ( | TBuffer & | b,
|  | void * | obj |
| ) |  |  | `[inline]`

Definition at line 221 of file PoolDbIOHandler.cpp.

    00221                                                       {
    00222   Token* t = (Token*)obj;
    00223   DataCallBack* caller = DbDataHandlerGuard::caller();
    00224   Int_t file_version = ((TFile*)b.GetParent())->GetVersion();
    00225   if ( file_version >= 40000 ) {
    00226     getOID_40000(b, m_root, t->oid());
    00227   }
    00228   else {
    00229     UInt_t start, count, tmp;
    00230     Version_t vsn = b.ReadVersion(&start, &count, m_root);
    00231     switch(vsn)  {
    00232     case 2:
    00233       b >> tmp;
    00234       b.ReadFastArray(&t->oid().first, 2);
    00235       b >> tmp;
    00236       break;
    00237     default:
    00238       b.SetBufferOffset(start+4);
    00239       b.ReadFastArray(&t->oid().first, 2);
    00240       break;
    00241     }
    00242   }
    00243   if (caller) caller->notify(DataCallBack::GET,DataCallBack::TOKEN,m_type,obj,&t->oid());
    00244 }

template<>

void PoolDbIOHandler< Token >::put | ( | TBuffer & | b,
|  | void * | obj |
| ) |  |  | `[inline]`

Definition at line 247 of file PoolDbIOHandler.cpp.

    00247                                                       {
    00248   Token::OID_t* poid = &(((Token*)obj)->oid());
    00249   UInt_t count = b.WriteVersion(m_root, true);
    00250   DataCallBack* caller = DbDataHandlerGuard::caller();
    00251   if (caller) caller->notify(DataCallBack::PUT,DataCallBack::TOKEN,m_type,obj,poid);
    00252   b.WriteFastArray(&poid->first, 2);
    00253   b.SetByteCount(count, true);
    00254 }

template<>

void PoolDbIOHandler< Reference >::get | ( | TBuffer & | b,
|  | void * | obj |
| ) |  |  | `[inline]`

Definition at line 257 of file PoolDbIOHandler.cpp.

    00257                                                           {
    00258   Token::OID_t oid(~0x0,~0x0);
    00259   DataCallBack* caller = DbDataHandlerGuard::caller();
    00260   Int_t file_version = ((TFile*)b.GetParent())->GetVersion();
    00261   (file_version >= 40000) ? getOID_40000(b, m_root,oid) : b.ReadFastArray(&oid.first, 2);
    00262   if (caller) caller->notify(DataCallBack::GET,DataCallBack::REFERENCE,m_type,obj,&oid);
    00263 }

template<>

void PoolDbIOHandler< Reference >::put | ( | TBuffer & | b,
|  | void * | obj |
| ) |  |  | `[inline]`

Definition at line 266 of file PoolDbIOHandler.cpp.

    00266                                                           {
    00267   UInt_t count = b.WriteVersion(m_root, true);
    00268   DataCallBack* caller = DbDataHandlerGuard::caller();
    00269   Token::OID_t oid(~0x0, ~0x0);
    00270   if (caller) caller->notify(DataCallBack::PUT,DataCallBack::REFERENCE,m_type,obj,&oid);
    00271   b.WriteFastArray(&oid.first, 2);
    00272   b.SetByteCount(count, true);
    00273 }

## Member Data Documentation

template<class T>

TypeH PoolDbIOHandler< T >::m_type`[protected]`

LCG Reflection type.

Definition at line 18 of file PoolDbIOHandler.h.

template<class T>

TClass* PoolDbIOHandler< T >::m_root`[protected]`

ROOT persistent class description.

Definition at line 20 of file PoolDbIOHandler.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiPoolDb/GaudiPoolDb/PoolDbIOHandler.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiPoolDb/src/PoolDbIOHandler.cpp