| # Gaudi Framework, version v22r0 |

Home |  | Generated: 9 Feb 2011

# PoolDbIOHandler< T > Class Template Reference

`#include <PoolDbIOHandler.h>`

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

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

Definition at line 260 of file PoolDbIOHandler.cpp.

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

template<>

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

Definition at line 224 of file PoolDbIOHandler.cpp.

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

template<>

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

Definition at line 186 of file PoolDbIOHandler.cpp.

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

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

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

ROOT I/O callback.

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

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

Definition at line 269 of file PoolDbIOHandler.cpp.

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

template<>

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

Definition at line 250 of file PoolDbIOHandler.cpp.

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

template<>

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

Definition at line 195 of file PoolDbIOHandler.cpp.

    00195                                                                 {
    00196   m_root->WriteBuffer(b, obj);
    00197 }

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 {
    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   }
    00176   //if ( hint == StreamBuffer::INVALID )  {
    00177   //  std::cout << "PoolDbIOHandler<SmartRefBase>::onWrite> "
    00178   //            << "Found invalid smart reference."
    00179   //            << std::endl;
    00180   //}
    00181   ref->set(curr, hint, link);
    00182   m_root->WriteBuffer(b, obj);
    00183 }

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.

## Member Data Documentation

template<class T>

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

ROOT persistent class description.

Definition at line 20 of file PoolDbIOHandler.h.

template<class T>

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

LCG Reflection type.

Definition at line 18 of file PoolDbIOHandler.h.

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

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines