| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# 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)
  | Parameters:
  | obj | [IN] Pointer to user object.
virtual void | put (TBuffer &b, void *obj)
  | Parameters:
  | obj | [IN] Pointer to user 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 |
| ) |  |  | `[virtual]`

ROOT I/O callback.

Definition at line 79 of file PoolDbIOHandler.cpp.

References PoolDbIOHandler< T >::get(), PoolDbIOHandler< T >::m_root, PoolDbIOHandler< T >::put(), and std::exception::what().

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

template<class T>

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

Parameters:

  | obj | [IN] Pointer to user object.

Referenced by PoolDbIOHandler< T >::operator()().

template<class T>

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

Parameters:

  | obj | [IN] Pointer to user object.

Referenced by PoolDbIOHandler< T >::operator()().

template<>

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

Definition at line 100 of file PoolDbIOHandler.cpp.

References SmartRefBase::CONTAINEDOBJECT, count(), std::cout, SmartRefBase::DATAOBJECT, std::endl(), PoolDbIOHandler< T >::m_root, and SmartRefBase::objectType().

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

template<>

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

Definition at line 125 of file PoolDbIOHandler.cpp.

References LinkManager::addLink(), SmartRefBase::CONTAINEDOBJECT, std::cout, SmartRef< TYPE >::data(), SmartRefBase::DATAOBJECT, std::endl(), SmartRef< TYPE >::hintID(), IRegistry::identifier(), ContainedObject::index(), StreamBuffer::INVALID, last_link_hint, last_link_object, SmartRef< TYPE >::linkID(), DataObject::linkMgr(), PoolDbIOHandler< T >::m_root, SmartRefBase::objectType(), ContainedObject::parent(), DataObject::registry(), s_currObj, and SmartRefBase::set().

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

template<>

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

Definition at line 195 of file PoolDbIOHandler.cpp.

References count(), PoolDbIOHandler< T >::m_root, s_currObj, and ContainedObject::setParent().

    00195                                                                 {
    00196   UInt_t start, count;
    00197   Version_t version = b.ReadVersion(&start, &count, m_root);
    00198   m_root->ReadBuffer(b, obj, version, start, count);
    00199   ContainedObject* p = (ContainedObject*)obj;
    00200   p->setParent((ObjectContainerBase*)*s_currObj);
    00201 }

template<>

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

Definition at line 204 of file PoolDbIOHandler.cpp.

References PoolDbIOHandler< T >::m_root.

    00204                                                                 {
    00205   m_root->WriteBuffer(b, obj);
    00206 }

template<>

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

Definition at line 233 of file PoolDbIOHandler.cpp.

References count(), getOID_40000(), PoolDbIOHandler< T >::m_root, PoolDbIOHandler< T >::m_type, pool::DataCallBack::notify(), and pool::Token::oid().

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

template<>

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

Definition at line 259 of file PoolDbIOHandler.cpp.

References count(), std::pair< _T1, _T2 >::first, PoolDbIOHandler< T >::m_root, PoolDbIOHandler< T >::m_type, and pool::DataCallBack::notify().

    00259                                                       {
    00260   Token::OID_t* poid = &(((Token*)obj)->oid());
    00261   UInt_t count = b.WriteVersion(m_root, true);
    00262   DataCallBack* caller = DbDataHandlerGuard::caller();
    00263   if (caller) caller->notify(DataCallBack::PUT,DataCallBack::TOKEN,m_type,obj,poid);
    00264   b.WriteFastArray(&poid->first, 2);
    00265   b.SetByteCount(count, true);
    00266 }

template<>

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

Definition at line 269 of file PoolDbIOHandler.cpp.

References std::pair< _T1, _T2 >::first, getOID_40000(), PoolDbIOHandler< T >::m_root, PoolDbIOHandler< T >::m_type, and pool::DataCallBack::notify().

    00269                                                           {
    00270   Token::OID_t oid(~0x0,~0x0);
    00271   DataCallBack* caller = DbDataHandlerGuard::caller();
    00272   Int_t file_version = ((TFile*)b.GetParent())->GetVersion();
    00273   (file_version >= 40000) ? getOID_40000(b, m_root,oid) : b.ReadFastArray(&oid.first, 2);
    00274   if (caller) caller->notify(DataCallBack::GET,DataCallBack::REFERENCE,m_type,obj,&oid);
    00275 }

template<>

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

Definition at line 278 of file PoolDbIOHandler.cpp.

References count(), std::pair< _T1, _T2 >::first, PoolDbIOHandler< T >::m_root, PoolDbIOHandler< T >::m_type, and pool::DataCallBack::notify().

    00278                                                           {
    00279   UInt_t count = b.WriteVersion(m_root, true);
    00280   DataCallBack* caller = DbDataHandlerGuard::caller();
    00281   Token::OID_t oid(~0x0, ~0x0);
    00282   if (caller) caller->notify(DataCallBack::PUT,DataCallBack::REFERENCE,m_type,obj,&oid);
    00283   b.WriteFastArray(&oid.first, 2);
    00284   b.SetByteCount(count, true);
    00285 }

## Member Data Documentation

template<class T>

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

LCG Reflection type.

Definition at line 18 of file PoolDbIOHandler.h.

Referenced by PoolDbIOHandler< T >::get(), and PoolDbIOHandler< T >::put().

template<class T>

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

ROOT persistent class description.

Definition at line 20 of file PoolDbIOHandler.h.

Referenced by PoolDbIOHandler< T >::get(), PoolDbIOHandler< T >::operator()(), and PoolDbIOHandler< T >::put().

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

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