Gaudi Framework, version v21r8

Home   Generated: 17 Mar 2010

PoolDbNTupleCnv Class Reference

NTuple converter class definition. More...

#include <PoolDb/PoolDbNTupleCnv.h>

Inheritance diagram for PoolDbNTupleCnv:

Inheritance graph
[legend]
Collaboration diagram for PoolDbNTupleCnv:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 PoolDbNTupleCnv (long typ, const CLID &clid, ISvcLocator *svc)
 Standard constructor.
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)
 Resolve the references of the converted object.
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)
 Callback to bind N-tuple data for reading.
StatusCode readData (INTuple *pTuple, PoolDbTupleCallback *call)
 Callback to extract N-tuple data which needed to be put into BLOBs.
StatusCode bindWrite (INTuple *pTuple, PoolDbTupleCallback *call)
 Callback to bind N-tuple data for writing.


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.


Constructor & Destructor Documentation

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

Standard constructor.

Parameters:
clid [IN] Class ID of the object type to be converted.
db [IN] Pointer to POOL database interface
svc [IN] Pointer to Gaudi service locator
Returns:
Reference to PoolDbNTupleCnv object

Definition at line 210 of file PoolDbNTupleCnv.cpp.

00211 : PoolDbStatCnv(typ, clid, svc)
00212 {
00213   m_class = 0;
00214 }

PoolDbNTupleCnv::~PoolDbNTupleCnv (  )  [virtual]

Standard destructor.

Definition at line 216 of file PoolDbNTupleCnv.cpp.

00216                                    {
00217 }


Member Function Documentation

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

Callback to bind N-tuple data for reading.

Parameters:
pTuple [IN] Pointer to N-tuple structure
call [IN] Pointer to N-tuple callback structure
Returns:
StatusCode indicating success or failure

Definition at line 649 of file PoolDbNTupleCnv.cpp.

00651 {
00652   typedef INTuple::ItemContainer Cont;
00653   int cnt = 0;
00654   //pool::DbBlob&                  s       = cb->stream();
00655   std::vector<void*>&            addr    = cb->addresses();
00656   std::vector<PoolDbTokenWrap*>& links   = cb->links();
00657   const std::vector<int>&        mapping = cb->mapping();
00658   Cont&                          items   = nt->items();
00659   for (Cont::iterator i = items.begin(); i != items.end(); ++i, ++cnt )   {
00660     int count = mapping[cnt];
00661     if ( count >= 0 )  {
00662       char* buf = (char*)(*i)->buffer();
00663       switch( (*i)->type() )   {
00664         case DataTypeInfo::OBJECT_ADDR:
00665           addr[count] = &links[cnt];
00666           break;
00667         default:
00668           addr[count] = buf;
00669           break;
00670       }
00671     }
00672   }
00673   return S_OK;
00674 }

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

Callback to extract N-tuple data which needed to be put into BLOBs.

Parameters:
pTuple [IN] Pointer to N-tuple structure
call [IN] Pointer to N-tuple callback structure
Returns:
StatusCode indicating success or failure

Definition at line 676 of file PoolDbNTupleCnv.cpp.

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

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

Callback to bind N-tuple data for writing.

Parameters:
pTuple [IN] Pointer to N-tuple structure
call [IN] Pointer to N-tuple callback structure
Returns:
StatusCode indicating success or failure

Definition at line 729 of file PoolDbNTupleCnv.cpp.

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

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

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

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 398 of file PoolDbNTupleCnv.cpp.

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

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

Resolve the references of the converted 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 609 of file PoolDbNTupleCnv.cpp.

00610 {
00611   INTuple* pTuple = dynamic_cast<INTuple*>(pObj);
00612   if ( pTuple )  {
00613     IRegistry* pRegistry = pObj->registry();
00614     if ( 0 != pRegistry )  {
00615       pAddr = pRegistry->address();
00616       PoolDbAddress* pdbA = dynamic_cast<PoolDbAddress*>(pAddr);
00617       if ( 0 != pdbA )  {
00618         PoolDbTupleCallback* cb = dynamic_cast<PoolDbTupleCallback*>(pdbA->handler());
00619         if ( cb )  {
00620           const pool::DbTypeInfo* typH = dynamic_cast<const pool::DbTypeInfo*>(cb->shape());
00621           if ( typH )  {
00622             if ( bindWrite(pTuple, cb).isSuccess() )  {
00623               std::string path = fileName(pRegistry);
00624               std::string cntName = containerName(pRegistry);
00625               if ( !m_dbMgr->connectOutput(path, "UPDATE").isSuccess() )  {
00626                 MsgStream log(msgSvc(), "PoolDbNTupleCnv");
00627                 log << MSG::ERROR << "Error: connectOutput(path, UPDATE)" << endmsg;
00628                 return S_FAIL;
00629               }
00630               if ( m_dbMgr->markWrite(cb->clone(), cntName, &pdbA).isSuccess() ) {
00631                             if ( m_dbMgr->commitOutput(path, true).isSuccess() )  {
00632                               typedef INTuple::ItemContainer Cont;
00633                               Cont& it = pTuple->items();
00634                               for(Cont::iterator i = it.begin(); i != it.end(); ++i)  {
00635                                 (*i)->reset();
00636                               }
00637                               return S_OK;
00638                             }
00639               }
00640             }
00641           }
00642         }
00643       }
00644     }
00645   }
00646   return S_FAIL;
00647 }

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 221 of file PoolDbNTupleCnv.cpp.

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

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.

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 359 of file PoolDbNTupleCnv.cpp.

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

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.

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.

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.

00165   {  return StatusCode::SUCCESS;                                      }


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

Generated at Wed Mar 17 18:18:58 2010 for Gaudi Framework, version v21r8 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004