| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Public Member Functions | Protected Types | Protected Attributes

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

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

    {  }

## Member Function Documentation

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

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

Definition at line 100 of file PoolDbIOHandler.cpp.

                                                                 {
      UInt_t start, count;
      SmartRefBase* ref = (SmartRefBase*)obj;
      Version_t version = b.ReadVersion(&start, &count, m_root);
      m_root->ReadBuffer(b, obj, version, start, count);
      switch( ref->objectType() ) {
       case SmartRefBase::DATAOBJECT:
        {
          SmartRef<DataObject>* r = (SmartRef<DataObject>*)obj;
          (*r)(getCurrentDataObject());
        }
        break;
      case SmartRefBase::CONTAINEDOBJECT:
       {
         SmartRef<ContainedObject>* r = (SmartRef<ContainedObject>*)obj;
         (*r)(getCurrentDataObject());
       }
       break;
      default:
        std::cout << "Hit uninitialized smartRef!!!!" << std::endl;
        break;
      }
    }

template<>

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

Definition at line 243 of file PoolDbIOHandler.cpp.

                                                          {
      Token* t = (Token*)obj;
      DataCallBack* caller = DbDataHandlerGuard::caller();
      Int_t file_version = ((TFile*)b.GetParent())->GetVersion();
      if ( file_version >= 40000 ) {
        getOID_40000(b, m_root, t->oid());
      }
      else {
        UInt_t start, count, tmp;
        Version_t vsn = b.ReadVersion(&start, &count, m_root);
        switch(vsn)  {
        case 2:
          b >> tmp;
          b.ReadFastArray(&t->oid().first, 2);
          b >> tmp;
          break;
        default:
          b.SetBufferOffset(start+4);
          b.ReadFastArray(&t->oid().first, 2);
          break;
        }
      }
      if (caller) caller->notify(DataCallBack::GET,DataCallBack::TOKEN,m_type,obj,&t->oid());
    }

template<>

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

Definition at line 279 of file PoolDbIOHandler.cpp.

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

template<>

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

Definition at line 192 of file PoolDbIOHandler.cpp.

                                                                    {
      UInt_t start, count;
      Version_t version = b.ReadVersion(&start, &count, m_root);
      m_root->ReadBuffer(b, obj, version, start, count);
      ContainedObject* p = (ContainedObject*)obj;
      p->setParent((ObjectContainerBase*)getCurrentDataObject());
    }

template<class T >

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

ROOT I/O callback.

Definition at line 79 of file PoolDbIOHandler.cpp.

                                                              {
      try {
        if ( b.IsReading() )   {
          get(b,obj);
        }
        else  {
          put(b,obj);
        }
      }
      catch( const std::exception& e )    {
        std::string err = "Class:" + std::string(m_root->GetName()) + "> Exception in object I/O";
        err += e.what();
        throw std::runtime_error(err);
      }
      catch( ... )    {
        std::string err = "Class:" + std::string(m_root->GetName()) + "> Exception in object I/O";
        throw std::runtime_error(err);
      }
    }

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 >::put | ( | TBuffer & | b,
|  | void * | obj
| ) |  |

Definition at line 125 of file PoolDbIOHandler.cpp.

                                                                 {
      SmartRefBase* ref = (SmartRefBase*)obj;
      SmartRef<DataObject>* r1 = (SmartRef<DataObject>*)ref;
      DataObject* curr = getCurrentDataObject();
      DataObject* pDO  = r1->data();
      int hint = r1->hintID();
      int link = r1->linkID();
      if ( pDO )  {
        switch( ref->objectType() ) {
        case SmartRefBase::CONTAINEDOBJECT:
          {
            SmartRef<ContainedObject>* r2 = (SmartRef<ContainedObject>*)ref;
            ContainedObject* p = r2->data();
            if ( p )  {
              const ObjectContainerBase* parent = p->parent();
              if ( parent )  {
                link = p->index();
                pDO  = const_cast<ObjectContainerBase*>(parent);
                break;
              }
            }
          }
          pDO = 0;
          std::cout << "PoolDbIOHandler<SmartRefBase>::onWrite> "
                    << "Found invalid smart reference with object "
                    << "having no parent."
                    << std::endl;
          throw std::runtime_error("PoolDbIOHandler<SmartRefBase>::onWrite> "
                                   "Found invalid smart reference with object "
                                   "having no parent.");
          break;
        case SmartRefBase::DATAOBJECT:
          link = StreamBuffer::INVALID;
          break;
        default:
          break;
        }
        //if ( pDO == last_link_object && last_link_hint == -1 )  {
        //  std::cout << "PoolDbIOHandler<SmartRefBase>::onWrite> "
        //            << "Found invalid smart reference."
        //            << std::endl;
        //}
        if ( pDO == last_link_object )  {
          ref->set(curr, last_link_hint, link);
          m_root->WriteBuffer(b, obj);
          return;
        }
        else {
          LinkManager* mgr = curr->linkMgr();
          IRegistry*   reg = pDO->registry();
          if ( reg && mgr )  {
            hint = mgr->addLink(reg->identifier(), pDO);
            last_link_hint   = hint;
            last_link_object = pDO;
          }
        }
      }
      //if ( hint == StreamBuffer::INVALID )  {
      //  std::cout << "PoolDbIOHandler<SmartRefBase>::onWrite> "
      //            << "Found invalid smart reference."
      //            << std::endl;
      //}
      ref->set(curr, hint, link);
      m_root->WriteBuffer(b, obj);
    }

template<>

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

Definition at line 269 of file PoolDbIOHandler.cpp.

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

template<>

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

Definition at line 288 of file PoolDbIOHandler.cpp.

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

template<>

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

Definition at line 201 of file PoolDbIOHandler.cpp.

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

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

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