Gaudi Framework, version v22r0

Home   Generated: 9 Feb 2011

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

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

PoolDbNTupleCnv::~PoolDbNTupleCnv (  )  [virtual]

Standard destructor.

Definition at line 228 of file PoolDbNTupleCnv.cpp.

00228                                    {
00229 }


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Wed Feb 9 16:31:37 2011 for Gaudi Framework, version v22r0 by Doxygen version 1.6.2 written by Dimitri van Heesch, © 1997-2004