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

# PoolDbNTupleCnv Class Reference

`#include <PoolDb/PoolDbNTupleCnv.h>`

Inheritance diagram for PoolDbNTupleCnv:

[legend]
Collaboration diagram for PoolDbNTupleCnv:

[legend]
List of all members.

## Detailed Description

NTuple converter class definition.

Description: Definition of the generic converter for row wise and column wise Ntuples.

Author:
  M.Frank

Version:
  1.0

Definition at line 30 of file PoolDbNTupleCnv.h.

## Public Member Functions
| PoolDbNTupleCnv (long typ, const CLID &clid, ISvcLocator *svc)
  | Parameters:
  | clid | [IN] Class ID of the object type to be converted.
virtual | ~PoolDbNTupleCnv ()
| Standard destructor.
virtual StatusCode | createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
| Converter overrides: Convert the transient object to the requested representation.
virtual StatusCode | fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
  | Parameters:
  | pAddress | [IN] Valid pointer to the object's opaque address
virtual StatusCode | createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
| Converter overrides: Update the references of an updated transient object.
virtual StatusCode | fillObjRefs (IOpaqueAddress *, DataObject *)
| Converter overrides: Update the references of an updated transient object.
virtual StatusCode | updateObj (IOpaqueAddress *pAddress, DataObject *pObject)
| Update the transient object: NTuples end here when reading records.
virtual StatusCode | updateObjRefs (IOpaqueAddress *, DataObject *)
| Converter overrides: Update the references of an updated transient object.
virtual StatusCode | updateRep (IOpaqueAddress *, DataObject *)
| Converter overrides: Update the converted representation of a transient object.
virtual StatusCode | updateRepRefs (IOpaqueAddress *, DataObject *)
| Converter overrides: Update the converted representation of a transient object.
## Protected Member Functions
StatusCode | bindRead (INTuple *pTuple, PoolDbTupleCallback *call)
  | Parameters:
  | pTuple | [IN] Pointer to N-tuple structure
StatusCode | readData (INTuple *pTuple, PoolDbTupleCallback *call)
  | Parameters:
  | pTuple | [IN] Pointer to N-tuple structure
StatusCode | bindWrite (INTuple *pTuple, PoolDbTupleCallback *call)
  | Parameters:
  | pTuple | [IN] Pointer to N-tuple structure

## Constructor & Destructor Documentation

PoolDbNTupleCnv::PoolDbNTupleCnv | ( | long | typ,
|  | const CLID & | clid,
|  | ISvcLocator * | svc |
| ) |  |  |

Parameters:

  | clid | [IN] Class ID of the object type to be converted.

Parameters:

  | db | [IN] Pointer to POOL database interface
  | svc | [IN] Pointer to Gaudi service locator

Returns:
  Reference to PoolDbNTupleCnv object

Definition at line 221 of file PoolDbNTupleCnv.cpp.

References PoolDbBaseCnv::m_class.

    00222 : PoolDbStatCnv(typ, clid, svc)
    00223 {
    00224   m_class = 0;
    00225 }

PoolDbNTupleCnv::~PoolDbNTupleCnv | ( |  | ) | `[virtual]`

Standard destructor.

Definition at line 227 of file PoolDbNTupleCnv.cpp.

    00227                                    {
    00228 }

## Member Function Documentation

StatusCode PoolDbNTupleCnv::bindRead | ( | INTuple * | pTuple,
|  | PoolDbTupleCallback * | call |
| ) |  |  | `[protected]`

Parameters:

  | pTuple | [IN] Pointer to N-tuple structure

Parameters:

  | call | [IN] Pointer to N-tuple callback structure

Returns:
  StatusCode indicating success or failure

Definition at line 662 of file PoolDbNTupleCnv.cpp.

References PoolDbTupleCallback::addresses(), count(), INTuple::items(), PoolDbTupleCallback::links(), PoolDbTupleCallback::mapping(), DataTypeInfo::OBJECT_ADDR, and S_OK.

Referenced by updateObj().

    00664 {
    00665   typedef INTuple::ItemContainer Cont;
    00666   int cnt = 0;
    00667   //pool::DbBlob&                  s       = cb->stream();
    00668   std::vector<void*>&            addr    = cb->addresses();
    00669   std::vector<PoolDbTokenWrap*>& links   = cb->links();
    00670   const std::vector<int>&        mapping = cb->mapping();
    00671   Cont&                          items   = nt->items();
    00672   for (Cont::iterator i = items.begin(); i != items.end(); ++i, ++cnt )   {
    00673     int count = mapping[cnt];
    00674     if ( count >= 0 )  {
    00675       char* buf = (char*)(*i)->buffer();
    00676       switch( (*i)->type() )   {
    00677         case DataTypeInfo::OBJECT_ADDR:
    00678           addr[count] = &links[cnt];
    00679           break;
    00680         default:
    00681           addr[count] = buf;
    00682           break;
    00683       }
    00684     }
    00685   }
    00686   return S_OK;
    00687 }

StatusCode PoolDbNTupleCnv::readData | ( | INTuple * | pTuple,
|  | PoolDbTupleCallback * | call |
| ) |  |  | `[protected]`

Parameters:

  | pTuple | [IN] Pointer to N-tuple structure

Parameters:

  | call | [IN] Pointer to N-tuple callback structure

Returns:
  StatusCode indicating success or failure

Definition at line 689 of file PoolDbNTupleCnv.cpp.

References std::vector< _Tp, _Alloc >::begin(), DataTypeInfo::BOOL, DataTypeInfo::CHAR, count(), MSG::DEBUG, DataTypeInfo::DOUBLE, std::vector< _Tp, _Alloc >::end(), endmsg(), DataTypeInfo::FLOAT, DataTypeInfo::INT, INTuple::items(), PoolDbTupleCallback::links(), load(), DataTypeInfo::LONG, PoolDbTupleCallback::mapping(), Converter::msgSvc(), DataTypeInfo::NTCHAR, DataTypeInfo::OBJECT_ADDR, DataTypeInfo::POINTER, Gaudi::Units::s, S_OK, DataTypeInfo::SHORT, PoolDbTupleCallback::stream(), DataTypeInfo::STRING, DataTypeInfo::UCHAR, DataTypeInfo::UINT, DataTypeInfo::ULONG, DataTypeInfo::UNKNOWN, and DataTypeInfo::USHORT.

Referenced by updateObj().

    00691 {
    00692   typedef INTuple::ItemContainer Cont;
    00693   int cnt = 0;
    00694   pool::DbBlob&                  s       = cb->stream();
    00695   std::vector<PoolDbTokenWrap*>& links   = cb->links();
    00696   const std::vector<int>&        mapping = cb->mapping();
    00697   INTuple::ItemContainer&        items   = nt->items();
    00698   for (Cont::iterator i = items.begin(); i != items.end(); ++i, ++cnt )   {
    00699     int count = mapping[cnt];
    00700     int typ   = (*i)->type();
    00701     if(count < 0 || typ == DataTypeInfo::OBJECT_ADDR || typ == DataTypeInfo::POINTER)  {
    00702       char* buf = (char*)(*i)->buffer();
    00703       int sc = 11;
    00704       switch( (*i)->type() )   {
    00705       case DataTypeInfo::UCHAR:       sc=load<unsigned char> (s,buf); break;
    00706       case DataTypeInfo::USHORT:      sc=load<unsigned short>(s,buf); break;
    00707       case DataTypeInfo::UINT:        sc=load<unsigned int>  (s,buf); break;
    00708       case DataTypeInfo::ULONG:       sc=load<unsigned long> (s,buf); break;
    00709       case DataTypeInfo::CHAR:        sc=load<char>          (s,buf); break;
    00710       case DataTypeInfo::SHORT:       sc=load<short>         (s,buf); break;
    00711       case DataTypeInfo::INT:         sc=load<int>           (s,buf); break;
    00712       case DataTypeInfo::LONG:        sc=load<long>          (s,buf); break;
    00713       case DataTypeInfo::BOOL:        sc=load<bool>          (s,buf); break;
    00714       case DataTypeInfo::FLOAT:       sc=load<float>         (s,buf); break;
    00715       case DataTypeInfo::DOUBLE:      sc=load<double>        (s,buf); break;
    00716       case DataTypeInfo::STRING:      sc=load<std::string>   (s,buf); break;
    00717       case DataTypeInfo::NTCHAR:      sc=load<char*>         (s,buf); break;
    00718       case DataTypeInfo::OBJECT_ADDR: sc=load(buf,links[count]);      break;
    00719       case DataTypeInfo::POINTER:                                     break;
    00720       case DataTypeInfo::UNKNOWN:                                     break;
    00721       default:                                                        break;
    00722       }
    00723       if ( 0 != sc )  {
    00724         MsgStream log(msgSvc(), "PoolDbNTupleCnv");
    00725         log << MSG::DEBUG;
    00726         switch (sc)  {
    00727           case 10:
    00728             log << "CANNOT Set Ntuple token: dynamic_cast<GenericAddress*> is NULL";
    00729           break;
    00730           case 11:
    00731               log << "CANNOT Set Ntuple token: invalid address buffer";
    00732           break;
    00733         }
    00734         log << endmsg;
    00735       }
    00736     }
    00737   }
    00738   return S_OK;
    00739 }

StatusCode PoolDbNTupleCnv::bindWrite | ( | INTuple * | pTuple,
|  | PoolDbTupleCallback * | call |
| ) |  |  | `[protected]`

Parameters:

  | pTuple | [IN] Pointer to N-tuple structure

Parameters:

  | call | [IN] Pointer to N-tuple callback structure

Returns:
  StatusCode indicating success or failure

Definition at line 742 of file PoolDbNTupleCnv.cpp.

References PoolDbTupleCallback::addresses(), b, std::vector< _Tp, _Alloc >::begin(), DataTypeInfo::BOOL, DataTypeInfo::CHAR, count(), DataTypeInfo::DOUBLE, std::vector< _Tp, _Alloc >::end(), DataTypeInfo::FLOAT, DataTypeInfo::INT, INTuple::items(), PoolDbTupleCallback::links(), DataTypeInfo::LONG, PoolDbTupleCallback::mapping(), DataTypeInfo::NTCHAR, DataTypeInfo::OBJECT_ADDR, DataTypeInfo::POINTER, Gaudi::Units::s, S_OK, save(), DataTypeInfo::SHORT, PoolDbTupleCallback::stream(), DataTypeInfo::STRING, DataTypeInfo::UCHAR, DataTypeInfo::UINT, DataTypeInfo::ULONG, DataTypeInfo::UNKNOWN, DataTypeInfo::USHORT, and pool::DbBlob::WRITING.

Referenced by fillRepRefs().

    00743 {
    00744   int cnt = 0;
    00745   pool::DbBlob&                  s       = cb->stream();
    00746   std::vector<void*>&            addr    = cb->addresses();
    00747   std::vector<PoolDbTokenWrap*>& links   = cb->links();
    00748   const std::vector<int>&        mapping = cb->mapping();
    00749   const INTuple::ItemContainer&  items   = nt->items();
    00750   INTuple::ItemContainer::const_iterator i;
    00751
    00752   s.setMode(pool::DbBlob::WRITING);
    00753   for(i = items.begin(); i != items.end(); ++i, ++cnt )   {
    00754     char* b     = (char*)(*i)->buffer();
    00755     int   len   = (*i)->filled();
    00756     long  ndim  = (*i)->ndim();
    00757     int   count = mapping[cnt];
    00758     void* ptr = 0;
    00759     switch( (*i)->type() )  {
    00760     case DataTypeInfo::UCHAR:       ptr=save<unsigned char >(s,b,len,ndim>0); break;
    00761     case DataTypeInfo::USHORT:      ptr=save<unsigned short>(s,b,len,ndim>0); break;
    00762     case DataTypeInfo::UINT:        ptr=save<unsigned int  >(s,b,len,ndim>0); break;
    00763     case DataTypeInfo::ULONG:       ptr=save<unsigned long >(s,b,len,ndim>0); break;
    00764     case DataTypeInfo::CHAR:        ptr=save<char          >(s,b,len,ndim>0); break;
    00765     case DataTypeInfo::SHORT:       ptr=save<short         >(s,b,len,ndim>0); break;
    00766     case DataTypeInfo::INT:         ptr=save<int           >(s,b,len,ndim>0); break;
    00767     case DataTypeInfo::LONG:        ptr=save<long          >(s,b,len,ndim>0); break;
    00768     case DataTypeInfo::BOOL:        ptr=save<bool          >(s,b,len,ndim>0); break;
    00769     case DataTypeInfo::FLOAT:       ptr=save<float         >(s,b,len,ndim>0); break;
    00770     case DataTypeInfo::DOUBLE:      ptr=save<double        >(s,b,len,ndim>0); break;
    00771     case DataTypeInfo::STRING:      ptr=save<std::string   >(s,b,len,ndim>0); break;
    00772     case DataTypeInfo::NTCHAR:      ptr=save<char*         >(s,b,len,ndim>0); break;
    00773     case DataTypeInfo::POINTER:     ptr=*(void**)b;                           break;
    00774     case DataTypeInfo::OBJECT_ADDR: ptr=save(b,links[count]);                 break;
    00775     case DataTypeInfo::UNKNOWN:                                               break;
    00776     default:                     /* Do we have to take some action here ? */  break;
    00777     }
    00778     if ( count >= 0 )  {
    00779       addr[count] = ptr;
    00780     }
    00781   }
    00782   return S_OK;
    00783 }

StatusCode PoolDbNTupleCnv::createRep | ( | DataObject * | pObject,
|  | IOpaqueAddress *& | refpAddress |
| ) |  |  | `[virtual]`

Converter overrides: Convert the transient object to the requested representation.

Parameters:

  | pObject | [IN] Valid pointer to DataObject
  | refpAddress | [OUT] Location to store pointer to the object's opaque address

Returns:
  Status code indicating success or failure

Reimplemented from PoolDbBaseCnv.

Definition at line 409 of file PoolDbNTupleCnv.cpp.

References IRegistry::address(), pool::DbColumn::BLOB, pool::DbColumn::BOOL, DataTypeInfo::BOOL, pool::DbColumn::CHAR, DataTypeInfo::CHAR, DataObject::clID(), cntH, IPoolDbMgr::commitOutput(), IPoolDbMgr::connectContainer(), PoolDbStatCnv::containerName(), std::cout, pool::DbTypeInfo::createEx(), INTupleItem::dim(), pool::DbColumn::DOUBLE, DataTypeInfo::DOUBLE, std::endl(), endreq(), MSG::ERROR, PoolDbStatCnv::fileName(), pool::DbColumn::FLOAT, DataTypeInfo::FLOAT, genMD5(), INTupleItem::hasIndex(), INTupleItem::index(), INTupleItem::indexItem(), pool::DbColumn::INT, DataTypeInfo::INT, StatusCode::isSuccess(), INTuple::items(), INTupleItem::length(), pool::DbColumn::LONG, DataTypeInfo::LONG, PoolDbBaseCnv::m_dbMgr, Converter::msgSvc(), IRegistry::name(), INTupleItem::name(), INTupleItem::ndim(), pool::DbColumn::NTCHAR, DataTypeInfo::NTCHAR, DataTypeInfo::OBJECT_ADDR, pool::Token::oid(), Gaudi::Utils::Histos::path(), DataTypeInfo::POINTER, pool::DbColumn::POINTER, POOL_StorageType, std::vector< _Tp, _Alloc >::push_back(), putRange(), pool::RECREATE, DataObject::registry(), pool::Token::release(), S_FAIL, S_OK, PoolDbStatCnv::saveDescription(), pool::DbColumn::SHORT, DataTypeInfo::SHORT, DataTypeInfo::size(), std::vector< _Tp, _Alloc >::size(), pool::DbColumn::STRING, DataTypeInfo::STRING, INTuple::title(), INTupleItem::type(), INTupleItem::typeName(), pool::typeName(), pool::DbColumn::UCHAR, DataTypeInfo::UCHAR, pool::DbColumn::UINT, DataTypeInfo::UINT, pool::DbColumn::ULONG, DataTypeInfo::ULONG, IPoolDbMgr::UNKNOWN, DataTypeInfo::UNKNOWN, pool::UPDATE, pool::DbColumn::USHORT, and DataTypeInfo::USHORT.

    00409                                                                     {
    00410   IRegistry* pRegistry = pObj->registry();
    00411   if ( 0 != pRegistry )  {
    00412     pAddr = pRegistry->address();
    00413     PoolDbAddress* pdbA = dynamic_cast<PoolDbAddress*>(pAddr);
    00414     if ( 0 == pdbA )  {
    00415       const INTuple* nt  = dynamic_cast<const INTuple*>(pObj);
    00416       std::string    loc = containerName(pObj->registry());
    00417       if ( 0 != nt )  {
    00418         const INTuple::ItemContainer& items = nt->items();
    00419         std::vector<const pool::DbColumn*> cols;
    00420         std::vector<int> item_map(items.size()+1,-1);
    00421         std::ostringstream os;
    00422         int pool_type = 0;
    00423         size_t item_no;
    00424         os << nt->title()<<';'<<pObj->clID()<<';'<<items.size()<< ';';
    00425         for(item_no = 0; item_no < items.size(); ++item_no ) {
    00426           pool::DbColumn* col = 0;
    00427           INTupleItem* it = items[item_no];
    00428           os << '{'
    00429              << it->name()      << ';'
    00430              << it->type()      << ';'
    00431              << it->length()    << ';'
    00432              << it->ndim()      << ';'
    00433              << it->hasIndex()  << ';';
    00434           if ( it->hasIndex() )   {
    00435             os << it->index() << ';';
    00436             INTupleItem* itm = it->indexItem();
    00437             switch( itm->type() )    {
    00438             case DataTypeInfo::UCHAR:
    00439               putRange(os, dynamic_cast<NTuple::_Data<unsigned char>*>(itm));
    00440               break;
    00441             case DataTypeInfo::USHORT:
    00442               putRange(os, dynamic_cast<NTuple::_Data<unsigned short>*>(itm));
    00443               break;
    00444             case DataTypeInfo::UINT:
    00445               putRange(os, dynamic_cast<NTuple::_Data<unsigned int>*>(itm));
    00446               break;
    00447             case DataTypeInfo::ULONG:
    00448               putRange(os, dynamic_cast<NTuple::_Data<unsigned long>*>(itm));
    00449               break;
    00450             case DataTypeInfo::CHAR:
    00451               putRange(os, dynamic_cast<NTuple::_Data<char>*>(itm));
    00452               break;
    00453             case DataTypeInfo::SHORT:
    00454               putRange(os, dynamic_cast<NTuple::_Data<short>*>(itm));
    00455               break;
    00456             case DataTypeInfo::INT:
    00457               putRange(os, dynamic_cast<NTuple::_Data<int>*>(itm));
    00458               break;
    00459             case DataTypeInfo::LONG:
    00460               putRange(os, dynamic_cast<NTuple::_Data<long>*>(itm));
    00461               break;
    00462             default: {
    00463               MsgStream err(msgSvc(), "NTuple:"+pRegistry->name());
    00464               err << MSG::ERROR << "Column " << it->index()
    00465                   << " is not a valid index column!" << endreq;
    00466               return S_FAIL;
    00467               }
    00468             }
    00469           }
    00470           for ( long k = 0; k < it->ndim(); k++ )  {
    00471             os << it->dim(k) << ';';
    00472           }
    00473           switch(it->type())  {
    00474             case DataTypeInfo::STRING:
    00475               pool_type = pool::DbColumn::STRING;
    00476               os << 0 << ';' << 0 << ';';
    00477               break;
    00478             case DataTypeInfo::NTCHAR:
    00479               pool_type = pool::DbColumn::NTCHAR;
    00480               os << 0 << ';' << 0 << ';';
    00481               break;
    00482             case DataTypeInfo::OBJECT_ADDR:
    00483               if ( it->length() == 1 )  {
    00484                 col = new pool::DbColumn(it->name(),
    00485                                          pool::typeName(typeid(PoolDbTokenWrap)),
    00486                                          pool::DbColumn::POINTER,
    00487                                          0);
    00488                 item_map[item_no] = cols.size();
    00489                 cols.push_back(col);
    00490               }
    00491               os << 0 << ';' << 0 << ';';
    00492               break;
    00493             case DataTypeInfo::POINTER:
    00494               if ( it->length() == 1 )  {
    00495                 ROOT::Reflex::Type typ = ROOT::Reflex::Type::ByName(it->typeName());
    00496                 col = new pool::DbColumn(it->name(),
    00497                                          typ.Name(ROOT::Reflex::SCOPED),
    00498                                          pool::DbColumn::POINTER,
    00499                                          0);
    00500                 item_map[item_no] = cols.size();
    00501                 cols.push_back(col);
    00502                 os << 0 << ';' << 0 << ';';
    00503               }
    00504               break;
    00505             case DataTypeInfo::UCHAR:
    00506               pool_type = pool::DbColumn::UCHAR;
    00507               putRange(os, dynamic_cast<NTuple::_Data<unsigned char>*>(it));
    00508               goto MakeCol;
    00509             case DataTypeInfo::USHORT:
    00510               pool_type = pool::DbColumn::USHORT;
    00511               putRange(os, dynamic_cast<NTuple::_Data<unsigned short>*>(it));
    00512               goto MakeCol;
    00513             case DataTypeInfo::UINT:
    00514               pool_type = pool::DbColumn::UINT;
    00515               putRange(os, dynamic_cast<NTuple::_Data<unsigned int>*>(it));
    00516               goto MakeCol;
    00517             case DataTypeInfo::ULONG:
    00518               pool_type = pool::DbColumn::ULONG;
    00519               putRange(os, dynamic_cast<NTuple::_Data<unsigned long>*>(it));
    00520               goto MakeCol;
    00521             case DataTypeInfo::CHAR:
    00522               pool_type = pool::DbColumn::CHAR;
    00523               putRange(os, dynamic_cast<NTuple::_Data<char>*>(it));
    00524               goto MakeCol;
    00525             case DataTypeInfo::SHORT:
    00526               pool_type = pool::DbColumn::SHORT;
    00527               putRange(os, dynamic_cast<NTuple::_Data<short>*>(it));
    00528               goto MakeCol;
    00529             case DataTypeInfo::INT:
    00530               pool_type = pool::DbColumn::INT;
    00531               putRange(os, dynamic_cast<NTuple::_Data<int>*>(it));
    00532               goto MakeCol;
    00533             case DataTypeInfo::LONG:
    00534               pool_type = pool::DbColumn::LONG;
    00535               putRange(os, dynamic_cast<NTuple::_Data<long>*>(it));
    00536               goto MakeCol;
    00537             case DataTypeInfo::BOOL:
    00538               pool_type = pool::DbColumn::BOOL;
    00539               putRange(os, dynamic_cast<NTuple::_Data<bool>*>(it));
    00540               goto MakeCol;
    00541             case DataTypeInfo::FLOAT:
    00542               pool_type = pool::DbColumn::FLOAT;
    00543               putRange(os, dynamic_cast<NTuple::_Data<float>*>(it));
    00544               goto MakeCol;
    00545             case DataTypeInfo::DOUBLE:
    00546               pool_type = pool::DbColumn::DOUBLE;
    00547               putRange(os, dynamic_cast<NTuple::_Data<double>*>(it));
    00548               goto MakeCol;
    00549   MakeCol:
    00550               if ( it->length() == 1 )  {
    00551                 pool::DbColumn* col = new pool::DbColumn(it->name(),
    00552                                                          pool_type,
    00553                                                          0,
    00554                                                          DataTypeInfo::size(it->type()));
    00555                 item_map[item_no] = cols.size();
    00556                 cols.push_back(col);
    00557               }
    00558               // Everything else CANNOT be identified using SQL
    00559             break;
    00560             case DataTypeInfo::UNKNOWN:
    00561             default:
    00562               std::cout << "Create item[FAIL]]: " << it->name()
    00563                         << " Typ:" << it->type() << std::endl;
    00564               break;
    00565           }
    00566           os << '}';
    00567         }
    00568         item_map[item_no] = cols.size();
    00569         pool::DbColumn* col =
    00570           new pool::DbColumn("BlobData",
    00571                              pool::DbColumn::BLOB,
    00572                              0,
    00573                              DataTypeInfo::size(pool::DbColumn::BLOB));
    00574         cols.push_back(col);
    00575         pool::Guid guid;
    00576         std::string cntName = containerName(pRegistry);
    00577         std::string path    = fileName(pRegistry);
    00578         genMD5(os.str(), &guid);
    00579         const pool::DbTypeInfo* typH = pool::DbTypeInfo::createEx(guid, cols);
    00580         StatusCode sc = saveDescription(path,
    00581                                         cntName,
    00582                                         os.str(),
    00583                                         typH->toString(),
    00584                                         guid,
    00585                                         pObj->clID(),
    00586                                         "UPDATE");
    00587         if ( sc.isSuccess() )  {
    00588           // Check if the database container can be connected
    00589           pool::DbContainer cntH(POOL_StorageType);
    00590           StatusCode sc =
    00591             m_dbMgr->connectContainer(IPoolDbMgr::UNKNOWN,
    00592                                       path,
    00593                                       cntName,
    00594                                       pool::RECREATE|pool::UPDATE,
    00595                                       typH,
    00596                                       cntH);
    00597           if ( sc.isSuccess() )  {
    00598             PoolDbTupleCallback* hdlr = new PoolDbTupleCallback(pObj);
    00599             pool::Token*         tok = new pool::Token(cntH.token());
    00600             PoolDbAddress*       add = new PoolDbAddress(tok);
    00601             hdlr->configure(nt, typH, cntH);
    00602             tok->oid().second = 0;
    00603             tok->release();
    00604             pAddr = add;
    00605             add->setHandler(hdlr);
    00606             return m_dbMgr->commitOutput(path, true);
    00607           }
    00608           return S_FAIL;
    00609         }
    00610         return sc;
    00611       }
    00612     }
    00613     else  {
    00614       return S_OK;
    00615     }
    00616   }
    00617   return S_FAIL;
    00618 }

StatusCode PoolDbNTupleCnv::fillRepRefs | ( | IOpaqueAddress * | pAddress,
|  | DataObject * | pObject |
| ) |  |  | `[virtual]`

Parameters:

  | pAddress | [IN] Valid pointer to the object's opaque address

Parameters:

  | pObject | [IN] Valid pointer to DataObject

Returns:
  Status code indicating success or failure

Reimplemented from PoolDbBaseCnv.

Definition at line 622 of file PoolDbNTupleCnv.cpp.

References IRegistry::address(), bindWrite(), PoolDbTupleCallback::clone(), IPoolDbMgr::commitOutput(), IPoolDbMgr::connectOutput(), PoolDbStatCnv::containerName(), endmsg(), MSG::ERROR, PoolDbStatCnv::fileName(), PoolDbAddress::handler(), StatusCode::isSuccess(), PoolDbBaseCnv::m_dbMgr, IPoolDbMgr::markWrite(), Converter::msgSvc(), Gaudi::Utils::Histos::path(), DataObject::registry(), S_FAIL, S_OK, and pool::DbObjectCallBack::shape().

    00623 {
    00624   INTuple* pTuple = dynamic_cast<INTuple*>(pObj);
    00625   if ( pTuple )  {
    00626     IRegistry* pRegistry = pObj->registry();
    00627     if ( 0 != pRegistry )  {
    00628       pAddr = pRegistry->address();
    00629       PoolDbAddress* pdbA = dynamic_cast<PoolDbAddress*>(pAddr);
    00630       if ( 0 != pdbA )  {
    00631         PoolDbTupleCallback* cb = dynamic_cast<PoolDbTupleCallback*>(pdbA->handler());
    00632         if ( cb )  {
    00633           const pool::DbTypeInfo* typH = dynamic_cast<const pool::DbTypeInfo*>(cb->shape());
    00634           if ( typH )  {
    00635             if ( bindWrite(pTuple, cb).isSuccess() )  {
    00636               std::string path = fileName(pRegistry);
    00637               std::string cntName = containerName(pRegistry);
    00638               if ( !m_dbMgr->connectOutput(path, "UPDATE").isSuccess() )  {
    00639                 MsgStream log(msgSvc(), "PoolDbNTupleCnv");
    00640                 log << MSG::ERROR << "Error: connectOutput(path, UPDATE)" << endmsg;
    00641                 return S_FAIL;
    00642               }
    00643               if ( m_dbMgr->markWrite(cb->clone(), cntName, &pdbA).isSuccess() ) {
    00644                             if ( m_dbMgr->commitOutput(path, true).isSuccess() )  {
    00645                               typedef INTuple::ItemContainer Cont;
    00646                               Cont& it = pTuple->items();
    00647                               for(Cont::iterator i = it.begin(); i != it.end(); ++i)  {
    00648                                 (*i)->reset();
    00649                               }
    00650                               return S_OK;
    00651                             }
    00652               }
    00653             }
    00654           }
    00655         }
    00656       }
    00657     }
    00658   }
    00659   return S_FAIL;
    00660 }

StatusCode PoolDbNTupleCnv::createObj | ( | IOpaqueAddress * | pAddress,
|  | DataObject *& | refpObject |
| ) |  |  | `[virtual]`

Converter overrides: Update the references of an updated transient object.

Parameters:

  | pAddress | [IN] Valid pointer to the object's opaque address
  | refpObject | [OUT] Location to store pointer to DataObject

Returns:
  Status code indicating success or failure

Reimplemented from PoolDbBaseCnv.

Definition at line 232 of file PoolDbNTupleCnv.cpp.

References DataTypeInfo::BOOL, c, DataTypeInfo::CHAR, cntH, IPoolDbMgr::connect(), PoolDbNTupleDescriptor::container, pool::Token::contID(), createItem(), IPoolDbMgr::createSelect(), Converter::dataProvider(), pool::Token::dbID(), PoolDbNTupleDescriptor::description, DataTypeInfo::DOUBLE, std::basic_string< _CharT, _Traits, _Alloc >::empty(), endmsg(), MSG::FATAL, DataTypeInfo::FLOAT, pool::DbReflex::forTypeName(), pool::DbTypeInfo::fromString(), std::auto_ptr< _Tp >::get(), std::getline(), PoolDbNTupleDescriptor::guid, IID_INTupleSvc, DataTypeInfo::INT, DataTypeInfo::LONG, PoolDbBaseCnv::m_dbMgr, PoolDbBaseCnv::makeError(), Converter::msgSvc(), pool::DbObjectCallBack::object(), DataTypeInfo::OBJECT_ADDR, PoolDbNTupleDescriptor::optional, DataTypeInfo::POINTER, pool::READ, DataObject::release(), pool::DataCallBack::release(), S_FAIL, PoolDbAddress::setHandler(), DataTypeInfo::SHORT, pool::Token::technology(), PoolDbAddress::token(), DataTypeInfo::UCHAR, DataTypeInfo::UINT, DataTypeInfo::ULONG, DataTypeInfo::UNKNOWN, and DataTypeInfo::USHORT.

    00233 {
    00234   StatusCode status = S_FAIL;
    00235   PoolDbAddress* pdbA = dynamic_cast<PoolDbAddress*>(pAddress);
    00236   if ( 0 != pdbA )  {
    00237     const pool::Token* tok = pdbA->token();
    00238     if ( tok )  {
    00239       pool::DbContainer cntH(tok->technology());
    00240       status = m_dbMgr->connect(tok->dbID(),tok->contID(),cntH);
    00241       if ( status.isSuccess() ) {
    00242         std::string par_val, par_guid, par_typ;
    00243         std::auto_ptr<pool::DbSelect> iter(m_dbMgr->createSelect("*", tok->dbID(), "GaudiStatisticsDescription"));
    00244         if ( iter.get() )  {
    00245           pool::Token* token;
    00246           ROOT::Reflex::Type typ = pool::DbReflex::forTypeName("PoolDbNTupleDescriptor");
    00247           pool::DbObjectCallBack* call = new pool::DbObjectCallBack(typ);
    00248           while( iter->next(token).isSuccess() )  {
    00249             typedef pool::DbObjectHandle<pool::DbObject> ObjH;
    00250             pool::DbContainer& cH = iter->container();
    00251             if ( ObjH::openEx(cH, *token, call, pool::READ).isSuccess() )  {
    00252               PoolDbNTupleDescriptor* ref = (PoolDbNTupleDescriptor*)call->object();
    00253               if ( ref->container == tok->contID() )  {
    00254                 par_val  = ref->description;
    00255                 par_typ  = ref->optional;
    00256                 par_guid = ref->guid;
    00257                 token->release();
    00258                 call->release();
    00259                 call = 0;
    00260                 delete ref;
    00261                 break;
    00262               }
    00263               delete ref;
    00264             }
    00265             token->release();
    00266           }
    00267           if ( call ) call->release();
    00268         }
    00269         if ( !par_val.empty() && !par_guid.empty() && !par_typ.empty() )
    00270         {
    00271           SmartIF<INTupleSvc> ntupleSvc(IID_INTupleSvc, dataProvider());
    00272           if ( ntupleSvc.isValid() )  {
    00273             char c;
    00274             CLID clid;
    00275             int siz, typ;
    00276             std::string title;
    00277             NTuple::Tuple* nt = 0;
    00278             std::istringstream is(par_val);
    00279             std::getline(is, title, ';') >> clid >> c >> siz >> c;
    00280             status = ntupleSvc->create(clid, title, nt);
    00281             for ( int j = 0; j < siz && status.isSuccess(); j++ ) {
    00282               is >> c;
    00283               std::getline(is, title, ';') >> typ >> c;
    00284               switch ( typ )    {
    00285               case DataTypeInfo::UCHAR:
    00286                 status = createItem(nt, is, title, (unsigned char)0);
    00287                 break;
    00288               case DataTypeInfo::USHORT:
    00289                 status = createItem(nt, is, title, (unsigned short)0);
    00290                 break;
    00291               case DataTypeInfo::UINT:
    00292                 status = createItem(nt, is, title, (unsigned int)0);
    00293                 break;
    00294               case DataTypeInfo::ULONG:
    00295                 status = createItem(nt, is, title, (unsigned long)0);
    00296                 break;
    00297               case DataTypeInfo::CHAR:
    00298                 status = createItem(nt, is, title, char(0));
    00299                 break;
    00300               case DataTypeInfo::SHORT:
    00301                 status = createItem(nt, is, title, short(0));
    00302                 break;
    00303               case DataTypeInfo::INT:
    00304                 status = createItem(nt, is, title, int(0));
    00305                 break;
    00306               case DataTypeInfo::LONG:
    00307                 status = createItem(nt, is, title, long(0));
    00308                 break;
    00309               case DataTypeInfo::BOOL:
    00310                 status = createItem(nt, is, title, false);
    00311                 break;
    00312               case DataTypeInfo::FLOAT:
    00313                 status = createItem(nt, is, title, float(0.0));
    00314                 break;
    00315               case DataTypeInfo::DOUBLE:
    00316                 status = createItem(nt, is, title, double(0.0));
    00317                 break;
    00318                 /*
    00319               case DataTypeInfo::NTCHAR:
    00320               case DataTypeInfo::LONG_NTCHAR:
    00321                 status =
    00322                 createItem(nt, is, title, (char*)0);
    00323                 break;
    00324               case DataTypeInfo::STRING:
    00325               case DataTypeInfo::LONG_STRING:
    00326                 status =
    00327                 createItem(nt, is, title, std::string(""));
    00328                 break;
    00329                 */
    00330               case DataTypeInfo::OBJECT_ADDR:
    00331                 status = createItem(nt, is, title, (IOpaqueAddress*)0);
    00332                 break;
    00333               case DataTypeInfo::POINTER:
    00334                 status = createItem(nt, is, title, (void*)0);
    00335                 break;
    00336               case DataTypeInfo::UNKNOWN:
    00337               default:
    00338                 status = S_FAIL;
    00339                 break;
    00340               }
    00341               if ( !status.isSuccess() )  {
    00342                 MsgStream err(msgSvc(),"NTupleCnv");
    00343                 err << MSG::FATAL
    00344                     << "Error connecting (Unknown) column:" << j << endmsg
    00345                     << par_val << endmsg;
    00346                 return makeError("createObj[NTuple]> Cannot determine column!");
    00347               }
    00348             }
    00349             if ( status.isSuccess() )  {
    00350               PoolDbTupleCallback* hdlr = new PoolDbTupleCallback(nt);
    00351               const pool::DbTypeInfo* typ = pool::DbTypeInfo::fromString(par_typ);
    00352               hdlr->configure(nt, typ, cntH);
    00353               pdbA->setHandler(hdlr);
    00354               refpObject  = nt;
    00355             }
    00356             else {
    00357               refpObject = 0;
    00358               if ( nt ) nt->release();
    00359             }
    00360           }
    00361         }
    00362       }
    00363     }
    00364   }
    00365   return status;
    00366 }

virtual StatusCode PoolDbNTupleCnv::fillObjRefs | ( | IOpaqueAddress * | ,
|  | DataObject * |  |
| ) |  |  | `[inline, virtual]`

Converter overrides: Update the references of an updated transient object.

Parameters:

  | pAddress | [IN] Valid pointer to the object's opaque address
  | pObject | [IN] Valid pointer to DataObject

Returns:
  Status code indicating success or failure

Reimplemented from PoolDbBaseCnv.

Definition at line 117 of file PoolDbNTupleCnv.h.

References StatusCode::SUCCESS.

    00119   {  return StatusCode::SUCCESS;                                      }

StatusCode PoolDbNTupleCnv::updateObj | ( | IOpaqueAddress * | pAddress,
|  | DataObject * | pObject |
| ) |  |  | `[virtual]`

Update the transient object: NTuples end here when reading records.

Parameters:

  | pAddress | [IN] Valid pointer to the object's opaque address
  | pObject | [IN] Valid pointer to DataObject

Returns:
  Status code indicating success or failure

Reimplemented from PoolDbBaseCnv.

Definition at line 370 of file PoolDbNTupleCnv.cpp.

References bindRead(), PoolDbTupleCallback::iterator(), PoolDbBaseCnv::m_dbMgr, PoolDbBaseCnv::makeError(), pool::DbSelect::next(), IPoolDbMgr::read(), readData(), S_FAIL, S_OK, PoolDbTupleCallback::select(), and INTuple::selector().

    00370                                                                    {
    00371   INTuple*       tupl = dynamic_cast<INTuple*>(pObj);
    00372   PoolDbAddress* pdbA = dynamic_cast<PoolDbAddress*>(pAddr);
    00373   if ( 0 != tupl && 0 != pdbA )  {
    00374     PoolDbTupleCallback* hdlr = dynamic_cast<PoolDbTupleCallback*>(pdbA->handler());
    00375     pool::DbSelect* it = hdlr->iterator();
    00376     if ( 0 == it )  {
    00377       it = hdlr->select(tupl->selector());
    00378     }
    00379     if ( it )  {
    00380       pool::Token* t = 0;
    00381       if ( hdlr->iterator()->next(t).isSuccess() )  {
    00382         std::auto_ptr<pool::Token> next(t);
    00383         // Now reload!
    00384         if ( bindRead(tupl, hdlr).isSuccess() )  {
    00385           // No support for SmartRefs<T> for N-tuples
    00386           //pushCurrentDataObject((DataObject**)&pObj);
    00387           if ( m_dbMgr->read(hdlr, *next.get()).isSuccess() )  {
    00388             if ( readData(tupl, hdlr).isSuccess() )  {
    00389               //popCurrentDataObject();
    00390               return S_OK;
    00391             }
    00392             //popCurrentDataObject();
    00393             return makeError("updateObj> Cannot interprete data.");
    00394           }
    00395           //popCurrentDataObject();
    00396           return makeError("updateObj> Cannot read data.");
    00397         }
    00398         return makeError("updateObj> Cannot bind data.");
    00399       }
    00400       return S_FAIL;
    00401     }
    00402     return makeError("updateObj> Token selection failed!");
    00403   }
    00404   return makeError("updateObj> Invalid Tuple reference.");
    00405 }

virtual StatusCode PoolDbNTupleCnv::updateObjRefs | ( | IOpaqueAddress * | ,
|  | DataObject * |  |
| ) |  |  | `[inline, virtual]`

Converter overrides: Update the references of an updated transient object.

Parameters:

  | pAddress | [IN] Valid pointer to the object's opaque address
  | pObject | [IN] Valid pointer to DataObject

Returns:
  Status code indicating success or failure

Reimplemented from PoolDbBaseCnv.

Definition at line 139 of file PoolDbNTupleCnv.h.

References StatusCode::SUCCESS.

    00141   {  return StatusCode::SUCCESS;                                      }

virtual StatusCode PoolDbNTupleCnv::updateRep | ( | IOpaqueAddress * | ,
|  | DataObject * |  |
| ) |  |  | `[inline, virtual]`

Converter overrides: Update the converted representation of a transient object.

Parameters:

  | pAddress | [IN] Valid pointer to the object's opaque address
  | pObject | [IN] Valid pointer to DataObject

Returns:
  Status code indicating success or failure

Reimplemented from PoolDbBaseCnv.

Definition at line 151 of file PoolDbNTupleCnv.h.

References StatusCode::SUCCESS.

    00153   {  return StatusCode::SUCCESS;                                      }

virtual StatusCode PoolDbNTupleCnv::updateRepRefs | ( | IOpaqueAddress * | ,
|  | DataObject * |  |
| ) |  |  | `[inline, virtual]`

Converter overrides: Update the converted representation of a transient object.

Parameters:

  | pAddress | [IN] Valid pointer to the object's opaque address
  | pObject | [IN] Valid pointer to DataObject

Returns:
  Status code indicating success or failure

Reimplemented from PoolDbBaseCnv.

Definition at line 163 of file PoolDbNTupleCnv.h.

References StatusCode::SUCCESS.

    00165   {  return StatusCode::SUCCESS;                                      }

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

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