| # Gaudi Framework, version v21r9 |

Home |  | Generated: 3 May 2010

# PoolDbIOHandler< T > Class Template Reference

`#include <PoolDbIOHandler.h>`

Inheritance diagram for PoolDbIOHandler< T >:

[legend]
Collaboration diagram for PoolDbIOHandler< T >:

[legend]

List of all members.

## 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.

## Detailed Description

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

Definition at line 14 of file PoolDbIOHandler.h.

## 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.

Reimplemented from TClassStreamer.

Definition at line 73 of file PoolDbIOHandler.cpp.

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

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 94 of file PoolDbIOHandler.cpp.

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

template<>

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

Definition at line 119 of file PoolDbIOHandler.cpp.

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

template<>

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

Definition at line 189 of file PoolDbIOHandler.cpp.

    00189                                                                 {
    00190   UInt_t start, count;
    00191   Version_t version = b.ReadVersion(&start, &count, m_root);
    00192   m_root->ReadBuffer(b, obj, version, start, count);
    00193   ContainedObject* p = (ContainedObject*)obj;
    00194   p->setParent((ObjectContainerBase*)getCurrentDataObject());
    00195 }

template<>

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

Definition at line 198 of file PoolDbIOHandler.cpp.

    00198                                                                 {
    00199   m_root->WriteBuffer(b, obj);
    00200 }

template<>

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

Definition at line 227 of file PoolDbIOHandler.cpp.

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

template<>

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

Definition at line 253 of file PoolDbIOHandler.cpp.

    00253                                                       {
    00254   Token::OID_t* poid = &(((Token*)obj)->oid());
    00255   UInt_t count = b.WriteVersion(m_root, true);
    00256   DataCallBack* caller = DbDataHandlerGuard::caller();
    00257   if (caller) caller->notify(DataCallBack::PUT,DataCallBack::TOKEN,m_type,obj,poid);
    00258   b.WriteFastArray(&poid->first, 2);
    00259   b.SetByteCount(count, true);
    00260 }

template<>

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

Definition at line 263 of file PoolDbIOHandler.cpp.

    00263                                                           {
    00264   Token::OID_t oid(~0x0,~0x0);
    00265   DataCallBack* caller = DbDataHandlerGuard::caller();
    00266   Int_t file_version = ((TFile*)b.GetParent())->GetVersion();
    00267   (file_version >= 40000) ? getOID_40000(b, m_root,oid) : b.ReadFastArray(&oid.first, 2);
    00268   if (caller) caller->notify(DataCallBack::GET,DataCallBack::REFERENCE,m_type,obj,&oid);
    00269 }

template<>

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

Definition at line 272 of file PoolDbIOHandler.cpp.

    00272                                                           {
    00273   UInt_t count = b.WriteVersion(m_root, true);
    00274   DataCallBack* caller = DbDataHandlerGuard::caller();
    00275   Token::OID_t oid(~0x0, ~0x0);
    00276   if (caller) caller->notify(DataCallBack::PUT,DataCallBack::REFERENCE,m_type,obj,&oid);
    00277   b.WriteFastArray(&oid.first, 2);
    00278   b.SetByteCount(count, true);
    00279 }

## 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_v21r9/GaudiPoolDb/GaudiPoolDb/PoolDbIOHandler.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r9/GaudiPoolDb/src/PoolDbIOHandler.cpp