| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

# PoolDbStatCnv.cpp

Go to the documentation of this file.

    00001 // $Id: PoolDbStatCnv.cpp,v 1.6 2008/10/27 16:41:33 marcocle Exp $
    00002 //------------------------------------------------------------------------------
    00003 //
    00004 // Implementation of class :  PoolDbStatCnv
    00005 //
    00006 // Author :                   Markus Frank
    00007 //
    00008 //------------------------------------------------------------------------------
    00009 #ifdef __ICC
    00010 // disable icc remark #2259: non-pointer conversion from "X" to "Y" may lose significant bits
    00011 //   TODO: To be removed, coming from CORAL
    00012 #pragma warning(disable:2259)
    00013 #endif
    00014
    00015 // Include files
    00016 #include "GaudiPoolDb/PoolDbStatCnv.h"
    00017 #include "GaudiPoolDb/IPoolDbMgr.h"
    00018 #include "GaudiPoolDb/PoolDbNTupleDescriptor.h"
    00019
    00020 #include "GaudiKernel/NTuple.h"
    00021 #include "GaudiKernel/IRegistry.h"
    00022 #include "GaudiKernel/IDataProviderSvc.h"
    00023 #include "GaudiKernel/CnvFactory.h"
    00024 #include "StorageSvc/DbReflex.h"
    00025 #include "StorageSvc/DbTypeInfo.h"
    00026 #include "StorageSvc/DbObjectCallBack.h"
    00027
    00028 #include <memory>
    00029
    00030 // Standard Constructor
    00031 PoolDbStatCnv::PoolDbStatCnv (long typ,
    00032                               const CLID& clid,
    00033                               ISvcLocator* svc)
    00034 : PoolDbBaseCnv(typ, clid, svc)
    00035 {
    00036 }
    00037
    00038 // Retrieve the name of the container a given object is placed into
    00039 const std::string PoolDbStatCnv::containerName(IRegistry* pReg) const {
    00040   const std::string& path = pReg->identifier();
    00041   long loc = path.find('/',1);
    00042   std::string local = "<local>";
    00043   if ( loc > 0 )  {
    00044     loc = path.find('/',++loc);
    00045     if ( loc > 0 )  {
    00046       local += path.substr(loc,path.length()-loc);
    00047     }
    00048   }
    00049   return local;
    00050 }
    00051
    00052 const std::string PoolDbStatCnv::fileName(IRegistry* pReg) const {
    00053   std::string path = topLevel(pReg);
    00054   DataObject* pObj = 0;
    00055   dataProvider()->retrieveObject(path, pObj);
    00056   if ( pObj )  {
    00057     NTuple::File* fptr = dynamic_cast<NTuple::File*>(pObj);
    00058     if ( fptr )  {
    00059       return fptr->name();
    00060     }
    00061   }
    00062   return "";
    00063 }
    00064
    00066 const std::string PoolDbStatCnv::topLevel(IRegistry* pReg) const
    00067 {
    00068   if ( pReg )    {
    00069     std::string path = pReg->identifier();
    00070     size_t idx = path.find('/', 1);
    00071     if ( idx != std::string::npos )  {
    00072       idx = path.find('/', idx+1);
    00073       if ( idx != std::string::npos )  {
    00074         path = path.substr(0, idx);
    00075       }
    00076       return path;
    00077     }
    00078   }
    00079   return "";
    00080 }
    00081
    00082 StatusCode PoolDbStatCnv::saveDescription(const std::string&  path,
    00083                                           const std::string&  ident,
    00084                                           const std::string&  desc,
    00085                                           const std::string&  opt,
    00086                                           const pool::Guid&   guid,
    00087                                           const CLID&         clid,
    00088                                           const std::string&  openMode)
    00089 {
    00090   ROOT::Reflex::Type cl = pool::DbReflex::forTypeInfo(typeid(PoolDbNTupleDescriptor));
    00091   const pool::DbTypeInfo* info = pool::DbTypeInfo::create(cl.Name(ROOT::Reflex::SCOPED));
    00092   if ( info )  {
    00093     StatusCode status = m_dbMgr->connectOutput(path, openMode);
    00094     if ( status.isSuccess() )  {
    00095       std::auto_ptr<PoolDbNTupleDescriptor> dsc(new PoolDbNTupleDescriptor());
    00096       dsc->description = desc;
    00097       dsc->optional    = opt;
    00098       dsc->container   = ident;
    00099       dsc->guid        = guid.toString();
    00100       dsc->clid        = clid;
    00101       pool::DataCallBack* call=new pool::DbObjectCallBack(cl);
    00102       call->setShape(info);
    00103       call->setObject(dsc.release());
    00104       status = m_dbMgr->markWrite(call,"GaudiStatisticsDescription");
    00105       if ( status.isSuccess() ) {
    00106         status = m_dbMgr->commitOutput(path, true);
    00107       }
    00108     }
    00109     return status;
    00110   }
    00111   return StatusCode::FAILURE;
    00112 }

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