| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Member Functions | Protected Member Functions

# PoolDbNTupleCnv Class Reference

NTuple converter class definition. More...

`#include <PoolDb/PoolDbNTupleCnv.h>`

Inheritance diagram for PoolDbNTupleCnv:
[legend]
Collaboration diagram for PoolDbNTupleCnv:
[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.

    : PoolDbStatCnv(typ, clid, svc)
    {
      m_class = 0;
    }

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

Standard destructor.

Definition at line 228 of file PoolDbNTupleCnv.cpp.

                                       {
    }

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

    {
      typedef INTuple::ItemContainer Cont;
      int cnt = 0;
      //pool::DbBlob&                  s       = cb->stream();
      std::vector<void*>&            addr    = cb->addresses();
      std::vector<PoolDbTokenWrap*>& links   = cb->links();
      const std::vector<int>&        mapping = cb->mapping();
      Cont&                          items   = nt->items();
      for (Cont::iterator i = items.begin(); i != items.end(); ++i, ++cnt )   {
        int count = mapping[cnt];
        if ( count >= 0 )  {
          char* buf = (char*)(*i)->buffer();
          switch( (*i)->type() )   {
            case DataTypeInfo::OBJECT_ADDR:
              addr[count] = &links[cnt];
              break;
            default:
              addr[count] = buf;
              break;
          }
        }
      }
      return S_OK;
    }

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.

    {
      int cnt = 0;
      pool::DbBlob&                  s       = cb->stream();
      std::vector<void*>&            addr    = cb->addresses();
      std::vector<PoolDbTokenWrap*>& links   = cb->links();
      const std::vector<int>&        mapping = cb->mapping();
      const INTuple::ItemContainer&  items   = nt->items();
      INTuple::ItemContainer::const_iterator i;

      s.setMode(pool::DbBlob::WRITING);
      for(i = items.begin(); i != items.end(); ++i, ++cnt )   {
        char* b     = (char*)(*i)->buffer();
        int   len   = (*i)->filled();
        long  ndim  = (*i)->ndim();
        int   count = mapping[cnt];
        void* ptr = 0;
        switch( (*i)->type() )  {
        case DataTypeInfo::UCHAR:       ptr=save<unsigned char >(s,b,len,ndim>0); break;
        case DataTypeInfo::USHORT:      ptr=save<unsigned short>(s,b,len,ndim>0); break;
        case DataTypeInfo::UINT:        ptr=save<unsigned int  >(s,b,len,ndim>0); break;
        case DataTypeInfo::ULONG:       ptr=save<unsigned long >(s,b,len,ndim>0); break;
        case DataTypeInfo::CHAR:        ptr=save<char          >(s,b,len,ndim>0); break;
        case DataTypeInfo::SHORT:       ptr=save<short         >(s,b,len,ndim>0); break;
        case DataTypeInfo::INT:         ptr=save<int           >(s,b,len,ndim>0); break;
        case DataTypeInfo::LONG:        ptr=save<long          >(s,b,len,ndim>0); break;
        case DataTypeInfo::BOOL:        ptr=save<bool          >(s,b,len,ndim>0); break;
        case DataTypeInfo::FLOAT:       ptr=save<float         >(s,b,len,ndim>0); break;
        case DataTypeInfo::DOUBLE:      ptr=save<double        >(s,b,len,ndim>0); break;
        case DataTypeInfo::STRING:      ptr=save<std::string   >(s,b,len,ndim>0); break;
        case DataTypeInfo::NTCHAR:      ptr=save<char*         >(s,b,len,ndim>0); break;
        case DataTypeInfo::POINTER:     ptr=*(void**)b;                           break;
        case DataTypeInfo::OBJECT_ADDR: ptr=save(b,links[count]);                 break;
        case DataTypeInfo::UNKNOWN:                                               break;
        default:                     /* Do we have to take some action here ? */  break;
        }
        if ( count >= 0 )  {
          addr[count] = ptr;
        }
      }
      return S_OK;
    }

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.

    {
      StatusCode status = S_FAIL;
      PoolDbAddress* pdbA = dynamic_cast<PoolDbAddress*>(pAddress);
      if ( 0 != pdbA )  {
        const pool::Token* tok = pdbA->token();
        if ( tok )  {
          pool::DbContainer cntH(tok->technology());
          status = m_dbMgr->connect(tok->dbID(),tok->contID(),cntH);
          if ( status.isSuccess() ) {
            std::string par_val, par_guid, par_typ;
            std::auto_ptr<pool::DbSelect> iter(m_dbMgr->createSelect("*", tok->dbID(), "GaudiStatisticsDescription"));
            if ( iter.get() )  {
              pool::Token* token;
              ROOT::Reflex::Type typ = pool::DbReflex::forTypeName("PoolDbNTupleDescriptor");
              pool::DbObjectCallBack* call = new pool::DbObjectCallBack(typ);
              while( iter->next(token).isSuccess() )  {
                typedef pool::DbObjectHandle<pool::DbObject> ObjH;
                pool::DbContainer& cH = iter->container();
                if ( ObjH::openEx(cH, *token, call, pool::READ).isSuccess() )  {
                  PoolDbNTupleDescriptor* ref = (PoolDbNTupleDescriptor*)call->object();
                  if ( ref->container == tok->contID() )  {
                    par_val  = ref->description;
                    par_typ  = ref->optional;
                    par_guid = ref->guid;
                    token->release();
                    call->release();
                    call = 0;
                    delete ref;
                    break;
                  }
                  delete ref;
                }
                token->release();
              }
              if ( call ) call->release();
            }
            if ( !par_val.empty() && !par_guid.empty() && !par_typ.empty() )
            {
              SmartIF<INTupleSvc> ntupleSvc(dataProvider());
              if ( ntupleSvc.isValid() )  {
                char c;
                CLID clid;
                int siz, typ;
                std::string title;
                NTuple::Tuple* nt = 0;
                std::istringstream is(par_val);
                std::getline(is, title, ';') >> clid >> c >> siz >> c;
                status = ntupleSvc->create(clid, title, nt);
                for ( int j = 0; j < siz && status.isSuccess(); j++ ) {
                  is >> c;
                  std::getline(is, title, ';') >> typ >> c;
                  switch ( typ )    {
                  case DataTypeInfo::UCHAR:
                    status = createItem(nt, is, title, (unsigned char)0);
                    break;
                  case DataTypeInfo::USHORT:
                    status = createItem(nt, is, title, (unsigned short)0);
                    break;
                  case DataTypeInfo::UINT:
                    status = createItem(nt, is, title, (unsigned int)0);
                    break;
                  case DataTypeInfo::ULONG:
                    status = createItem(nt, is, title, (unsigned long)0);
                    break;
                  case DataTypeInfo::CHAR:
                    status = createItem(nt, is, title, char(0));
                    break;
                  case DataTypeInfo::SHORT:
                    status = createItem(nt, is, title, short(0));
                    break;
                  case DataTypeInfo::INT:
                    status = createItem(nt, is, title, int(0));
                    break;
                  case DataTypeInfo::LONG:
                    status = createItem(nt, is, title, long(0));
                    break;
                  case DataTypeInfo::BOOL:
                    status = createItem(nt, is, title, false);
                    break;
                  case DataTypeInfo::FLOAT:
                    status = createItem(nt, is, title, float(0.0));
                    break;
                  case DataTypeInfo::DOUBLE:
                    status = createItem(nt, is, title, double(0.0));
                    break;
                    /*
                  case DataTypeInfo::NTCHAR:
                  case DataTypeInfo::LONG_NTCHAR:
                    status =
                    createItem(nt, is, title, (char*)0);
                    break;
                  case DataTypeInfo::STRING:
                  case DataTypeInfo::LONG_STRING:
                    status =
                    createItem(nt, is, title, std::string(""));
                    break;
                    */
                  case DataTypeInfo::OBJECT_ADDR:
                    status = createItem(nt, is, title, (IOpaqueAddress*)0);
                    break;
                  case DataTypeInfo::POINTER:
                    status = createItem(nt, is, title, (void*)0);
                    break;
                  case DataTypeInfo::UNKNOWN:
                  default:
                    status = S_FAIL;
                    break;
                  }
                  if ( !status.isSuccess() )  {
                    MsgStream err(msgSvc(),"NTupleCnv");
                    err << MSG::FATAL
                        << "Error connecting (Unknown) column:" << j << endmsg
                        << par_val << endmsg;
                    return makeError("createObj[NTuple]> Cannot determine column!");
                  }
                }
                if ( status.isSuccess() )  {
                  PoolDbTupleCallback* hdlr = new PoolDbTupleCallback(nt);
                  const pool::DbTypeInfo* typ1 = pool::DbTypeInfo::fromString(par_typ);
                  hdlr->configure(nt, typ1, cntH);
                  pdbA->setHandler(hdlr);
                  refpObject  = nt;
                }
                else {
                  refpObject = 0;
                  if ( nt ) nt->release();
                }
              }
            }
          }
        }
      }
      return status;
    }

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.

                                                                        {
      IRegistry* pRegistry = pObj->registry();
      if ( 0 != pRegistry )  {
        pAddr = pRegistry->address();
        PoolDbAddress* pdbA = dynamic_cast<PoolDbAddress*>(pAddr);
        if ( 0 == pdbA )  {
          const INTuple* nt  = dynamic_cast<const INTuple*>(pObj);
          if ( 0 != nt )  {
            const INTuple::ItemContainer& items = nt->items();
            std::vector<const pool::DbColumn*> cols;
            std::vector<int> item_map(items.size()+1,-1);
            std::ostringstream os;
            int pool_type = 0;
            size_t item_no;
            os << nt->title()<<';'<<pObj->clID()<<';'<<items.size()<< ';';
            for(item_no = 0; item_no < items.size(); ++item_no ) {
              pool::DbColumn* col = 0;
              INTupleItem* it = items[item_no];
              os << '{'
                 << it->name()      << ';'
                 << it->type()      << ';'
                 << it->length()    << ';'
                 << it->ndim()      << ';'
                 << it->hasIndex()  << ';';
              if ( it->hasIndex() )   {
                os << it->index() << ';';
                INTupleItem* itm = it->indexItem();
                switch( itm->type() )    {
                case DataTypeInfo::UCHAR:
                  putRange(os, dynamic_cast<NTuple::_Data<unsigned char>*>(itm));
                  break;
                case DataTypeInfo::USHORT:
                  putRange(os, dynamic_cast<NTuple::_Data<unsigned short>*>(itm));
                  break;
                case DataTypeInfo::UINT:
                  putRange(os, dynamic_cast<NTuple::_Data<unsigned int>*>(itm));
                  break;
                case DataTypeInfo::ULONG:
                  putRange(os, dynamic_cast<NTuple::_Data<unsigned long>*>(itm));
                  break;
                case DataTypeInfo::CHAR:
                  putRange(os, dynamic_cast<NTuple::_Data<char>*>(itm));
                  break;
                case DataTypeInfo::SHORT:
                  putRange(os, dynamic_cast<NTuple::_Data<short>*>(itm));
                  break;
                case DataTypeInfo::INT:
                  putRange(os, dynamic_cast<NTuple::_Data<int>*>(itm));
                  break;
                case DataTypeInfo::LONG:
                  putRange(os, dynamic_cast<NTuple::_Data<long>*>(itm));
                  break;
                default: {
                  MsgStream err(msgSvc(), "NTuple:"+pRegistry->name());
                  err << MSG::ERROR << "Column " << it->index()
                      << " is not a valid index column!" << endmsg;
                  return S_FAIL;
                  }
                }
              }
              for ( long k = 0; k < it->ndim(); k++ )  {
                os << it->dim(k) << ';';
              }
              switch(it->type())  {
                case DataTypeInfo::STRING:
                  pool_type = pool::DbColumn::STRING;
                  os << 0 << ';' << 0 << ';';
                  break;
                case DataTypeInfo::NTCHAR:
                  pool_type = pool::DbColumn::NTCHAR;
                  os << 0 << ';' << 0 << ';';
                  break;
                case DataTypeInfo::OBJECT_ADDR:
                  if ( it->length() == 1 )  {
                    col = new pool::DbColumn(it->name(),
                                             pool::typeName(typeid(PoolDbTokenWrap)),
                                             pool::DbColumn::POINTER,
                                             0);
                    item_map[item_no] = cols.size();
                    cols.push_back(col);
                  }
                  os << 0 << ';' << 0 << ';';
                  break;
                case DataTypeInfo::POINTER:
                  if ( it->length() == 1 )  {
                    ROOT::Reflex::Type typ = ROOT::Reflex::Type::ByName(it->typeName());
                    col = new pool::DbColumn(it->name(),
                                             typ.Name(ROOT::Reflex::SCOPED),
                                             pool::DbColumn::POINTER,
                                             0);
                    item_map[item_no] = cols.size();
                    cols.push_back(col);
                    os << 0 << ';' << 0 << ';';
                  }
                  break;
                case DataTypeInfo::UCHAR:
                  pool_type = pool::DbColumn::UCHAR;
                  putRange(os, dynamic_cast<NTuple::_Data<unsigned char>*>(it));
                  goto MakeCol;
                case DataTypeInfo::USHORT:
                  pool_type = pool::DbColumn::USHORT;
                  putRange(os, dynamic_cast<NTuple::_Data<unsigned short>*>(it));
                  goto MakeCol;
                case DataTypeInfo::UINT:
                  pool_type = pool::DbColumn::UINT;
                  putRange(os, dynamic_cast<NTuple::_Data<unsigned int>*>(it));
                  goto MakeCol;
                case DataTypeInfo::ULONG:
                  pool_type = pool::DbColumn::ULONG;
                  putRange(os, dynamic_cast<NTuple::_Data<unsigned long>*>(it));
                  goto MakeCol;
                case DataTypeInfo::CHAR:
                  pool_type = pool::DbColumn::CHAR;
                  putRange(os, dynamic_cast<NTuple::_Data<char>*>(it));
                  goto MakeCol;
                case DataTypeInfo::SHORT:
                  pool_type = pool::DbColumn::SHORT;
                  putRange(os, dynamic_cast<NTuple::_Data<short>*>(it));
                  goto MakeCol;
                case DataTypeInfo::INT:
                  pool_type = pool::DbColumn::INT;
                  putRange(os, dynamic_cast<NTuple::_Data<int>*>(it));
                  goto MakeCol;
                case DataTypeInfo::LONG:
                  pool_type = pool::DbColumn::LONG;
                  putRange(os, dynamic_cast<NTuple::_Data<long>*>(it));
                  goto MakeCol;
                case DataTypeInfo::BOOL:
                  pool_type = pool::DbColumn::BOOL;
                  putRange(os, dynamic_cast<NTuple::_Data<bool>*>(it));
                  goto MakeCol;
                case DataTypeInfo::FLOAT:
                  pool_type = pool::DbColumn::FLOAT;
                  putRange(os, dynamic_cast<NTuple::_Data<float>*>(it));
                  goto MakeCol;
                case DataTypeInfo::DOUBLE:
                  pool_type = pool::DbColumn::DOUBLE;
                  putRange(os, dynamic_cast<NTuple::_Data<double>*>(it));
                  goto MakeCol;
      MakeCol:
                  if ( it->length() == 1 )  {
                    col = new pool::DbColumn(it->name(),
                                             pool_type,
                                             0,
                                             DataTypeInfo::size(it->type()));
                    item_map[item_no] = cols.size();
                    cols.push_back(col);
                  }
                  // Everything else CANNOT be identified using SQL
                break;
                case DataTypeInfo::UNKNOWN:
                default:
                  std::cout << "Create item[FAIL]]: " << it->name()
                            << " Typ:" << it->type() << std::endl;
                  break;
              }
              os << '}';
            }
            item_map[item_no] = cols.size();
            pool::DbColumn* col =
              new pool::DbColumn("BlobData",
                                 pool::DbColumn::BLOB,
                                 0,
                                 DataTypeInfo::size(pool::DbColumn::BLOB));
            cols.push_back(col);
            pool::Guid guid;
            std::string cntName = containerName(pRegistry);
            std::string path    = fileName(pRegistry);
            genMD5(os.str(), &guid);
            const pool::DbTypeInfo* typH = pool::DbTypeInfo::createEx(guid, cols);
            StatusCode sc = saveDescription(path,
                                            cntName,
                                            os.str(),
                                            typH->toString(),
                                            guid,
                                            pObj->clID(),
                                            "UPDATE");
            if ( sc.isSuccess() )  {
              // Check if the database container can be connected
              pool::DbContainer cntH(POOL_StorageType);
              sc = m_dbMgr->connectContainer(IPoolDbMgr::UNKNOWN,
                                             path,
                                             cntName,
                                             pool::RECREATE|pool::UPDATE,
                                             typH,
                                             cntH);
              if ( sc.isSuccess() )  {
                PoolDbTupleCallback* hdlr = new PoolDbTupleCallback(pObj);
                pool::Token*         tok = new pool::Token(cntH.token());
                PoolDbAddress*       add = new PoolDbAddress(tok);
                hdlr->configure(nt, typH, cntH);
                tok->oid().second = 0;
                tok->release();
                pAddr = add;
                add->setHandler(hdlr);
                return m_dbMgr->commitOutput(path, true);
              }
              return S_FAIL;
            }
            return sc;
          }
        }
        else  {
          return S_OK;
        }
      }
      return S_FAIL;
    }

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.

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

    {
      INTuple* pTuple = dynamic_cast<INTuple*>(pObj);
      if ( pTuple )  {
        IRegistry* pRegistry = pObj->registry();
        if ( 0 != pRegistry )  {
          pAddr = pRegistry->address();
          PoolDbAddress* pdbA = dynamic_cast<PoolDbAddress*>(pAddr);
          if ( 0 != pdbA )  {
            PoolDbTupleCallback* cb = dynamic_cast<PoolDbTupleCallback*>(pdbA->handler());
            if ( cb )  {
              const pool::DbTypeInfo* typH = dynamic_cast<const pool::DbTypeInfo*>(cb->shape());
              if ( typH )  {
                if ( bindWrite(pTuple, cb).isSuccess() )  {
                  std::string path = fileName(pRegistry);
                  std::string cntName = containerName(pRegistry);
                  if ( !m_dbMgr->connectOutput(path, "UPDATE").isSuccess() )  {
                    MsgStream log(msgSvc(), "PoolDbNTupleCnv");
                    log << MSG::ERROR << "Error: connectOutput(path, UPDATE)" << endmsg;
                    return S_FAIL;
                  }
                  if ( m_dbMgr->markWrite(cb->clone(), cntName, &pdbA).isSuccess() ) {
                                if ( m_dbMgr->commitOutput(path, true).isSuccess() )  {
                                  typedef INTuple::ItemContainer Cont;
                                  Cont& it = pTuple->items();
                                  for(Cont::iterator i = it.begin(); i != it.end(); ++i)  {
                                    (*i)->reset();
                                  }
                                  return S_OK;
                                }
                  }
                }
              }
            }
          }
        }
      }
      return S_FAIL;
    }

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.

    {
      typedef INTuple::ItemContainer Cont;
      int cnt = 0;
      pool::DbBlob&                  s       = cb->stream();
      std::vector<PoolDbTokenWrap*>& links   = cb->links();
      const std::vector<int>&        mapping = cb->mapping();
      INTuple::ItemContainer&        items   = nt->items();
      for (Cont::iterator i = items.begin(); i != items.end(); ++i, ++cnt )   {
        int count = mapping[cnt];
        int typ   = (*i)->type();
        if(count < 0 || typ == DataTypeInfo::OBJECT_ADDR || typ == DataTypeInfo::POINTER)  {
          char* buf = (char*)(*i)->buffer();
          int sc = 11;
          switch( (*i)->type() )   {
          case DataTypeInfo::UCHAR:       sc=load<unsigned char> (s,buf); break;
          case DataTypeInfo::USHORT:      sc=load<unsigned short>(s,buf); break;
          case DataTypeInfo::UINT:        sc=load<unsigned int>  (s,buf); break;
          case DataTypeInfo::ULONG:       sc=load<unsigned long> (s,buf); break;
          case DataTypeInfo::CHAR:        sc=load<char>          (s,buf); break;
          case DataTypeInfo::SHORT:       sc=load<short>         (s,buf); break;
          case DataTypeInfo::INT:         sc=load<int>           (s,buf); break;
          case DataTypeInfo::LONG:        sc=load<long>          (s,buf); break;
          case DataTypeInfo::BOOL:        sc=load<bool>          (s,buf); break;
          case DataTypeInfo::FLOAT:       sc=load<float>         (s,buf); break;
          case DataTypeInfo::DOUBLE:      sc=load<double>        (s,buf); break;
          case DataTypeInfo::STRING:      sc=load<std::string>   (s,buf); break;
          case DataTypeInfo::NTCHAR:      sc=load<char*>         (s,buf); break;
          case DataTypeInfo::OBJECT_ADDR: sc=load(buf,links[cnt]);        break;
          case DataTypeInfo::POINTER:     sc = 0;                         break;
          case DataTypeInfo::UNKNOWN:                                     break;
          default:                                                        break;
          }
          if ( 0 != sc )  {
            MsgStream log(msgSvc(), "PoolDbNTupleCnv");
            log << MSG::DEBUG;
            switch (sc)  {
              case 10:
                log << "CANNOT Set Ntuple token: dynamic_cast<GenericAddress*> is NULL";
              break;
              case 11:
                  log << "CANNOT Set Ntuple token: invalid address buffer";
              break;
            }
            log << endmsg;
          }
        }
      }
      return S_OK;
    }

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.

                                                                       {
      INTuple*       tupl = dynamic_cast<INTuple*>(pObj);
      PoolDbAddress* pdbA = dynamic_cast<PoolDbAddress*>(pAddr);
      if ( 0 != tupl && 0 != pdbA )  {
        PoolDbTupleCallback* hdlr = dynamic_cast<PoolDbTupleCallback*>(pdbA->handler());
        if ( 0 != hdlr ) {
          pool::DbSelect* it = hdlr->iterator();
          if ( 0 == it )  {
            it = hdlr->select(tupl->selector());
          }
          if ( it )  {
            pool::Token* t = 0;
            if ( hdlr->iterator()->next(t).isSuccess() )  {
              std::auto_ptr<pool::Token> next(t);
              // Now reload!
              if ( bindRead(tupl, hdlr).isSuccess() )  {
                // No support for SmartRefs<T> for N-tuples
                //pushCurrentDataObject((DataObject**)&pObj);
                if ( m_dbMgr->read(hdlr, *next.get()).isSuccess() )  {
                  if ( readData(tupl, hdlr).isSuccess() )  {
                    //popCurrentDataObject();
                    return S_OK;
                  }
                  //popCurrentDataObject();
                  return makeError("updateObj> Cannot interprete data.");
                }
                //popCurrentDataObject();
                return makeError("updateObj> Cannot read data.");
              }
              return makeError("updateObj> Cannot bind data.");
            }
          }
          return S_FAIL;
        }
        return makeError("updateObj> Token selection failed!");
      }
      return makeError("updateObj> Invalid Tuple reference.");
    }

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.

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

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

      {  return StatusCode::SUCCESS;                                      }

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

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

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