| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# HDirectoryCnv.cpp

Go to the documentation of this file.

    00001 // $Id: HDirectoryCnv.cpp,v 1.8 2006/01/10 20:11:14 hmd Exp $
    00002 #define HBOOKCNV_HDIRECTORYCNV_CPP
    00003
    00004
    00005 // Include files
    00006 #include "GaudiKernel/xtoa.h"
    00007 #include "GaudiKernel/ClassID.h"
    00008 #include "GaudiKernel/SmartIF.h"
    00009 #include "GaudiKernel/IRegistry.h"
    00010 #include "GaudiKernel/CnvFactory.h"
    00011 #include "GaudiKernel/IOpaqueAddress.h"
    00012 #include "GaudiKernel/IDataProviderSvc.h"
    00013 #include "GaudiKernel/IDataManagerSvc.h"
    00014 #include "GaudiKernel/NTuple.h"
    00015
    00016 #include <stdio.h>
    00017
    00018 #include "HbookDef.h"
    00019 #include "HDirectoryCnv.h"
    00020
    00021 //------------------------------------------------------------------------------
    00022 //
    00023 // Implementation of class :  HbookCnv::HDirectoryCnv
    00024 //
    00025 // Author :                   Pavel Binko
    00026 //
    00027 //------------------------------------------------------------------------------
    00028
    00029
    00030 // Instantiation of a static factory class used by clients to create
    00031 // instances of this service
    00032 DECLARE_NAMESPACE_CONVERTER_FACTORY(HbookCnv,HDirectoryCnv)
    00033
    00034 HbookCnv::HDirectoryCnv::HDirectoryCnv(ISvcLocator* svc)
    00035  : HConverter(CLID_StatisticsDirectory, svc)                 {
    00036 }
    00037
    00038
    00039 HbookCnv::HDirectoryCnv::HDirectoryCnv(ISvcLocator* svc, const CLID& clid)
    00040  : HConverter(clid, svc)                 {
    00041 }
    00042
    00043
    00045 HbookCnv::HDirectoryCnv::~HDirectoryCnv()                                         {
    00046 }
    00047
    00049 const CLID& HbookCnv::HDirectoryCnv::classID()      {
    00050   return CLID_StatisticsDirectory;
    00051 }
    00052
    00054 StatusCode HbookCnv::HDirectoryCnv::createObj(IOpaqueAddress* /* pAddress */, DataObject*& refpObject)  {
    00055   refpObject = new NTuple::Directory();
    00056   return StatusCode::SUCCESS;
    00057 }
    00058
    00059
    00061 StatusCode HbookCnv::HDirectoryCnv::createRep(DataObject* pObject, IOpaqueAddress*& refpAddress)  {
    00062   if ( pObject )    {
    00063     IRegistry* pRegistry = pObject->registry();
    00064     if ( pRegistry )   {
    00065       std::string loc = m_prefix + pRegistry->identifier();
    00066       if ( createDirectory(loc).isSuccess() )   {
    00067         setDirectory(loc);
    00068         setDiskDirectory(loc);
    00069         return createAddress(loc, objType(), pRegistry->name(), refpAddress);
    00070       }
    00071     }
    00072   }
    00073   refpAddress = 0;
    00074   return StatusCode::FAILURE;
    00075 }
    00076
    00077
    00079 StatusCode HbookCnv::HDirectoryCnv::updateRep( IOpaqueAddress* /* pAddress */ , DataObject* pObject)  {
    00080   if ( pObject )    {
    00081     IRegistry* pRegistry = pObject->registry();
    00082     if ( pRegistry )   {
    00083       std::string loc = m_prefix + pRegistry->identifier();
    00084       if ( createDirectory(loc).isSuccess() )   {
    00085         setDirectory(loc);
    00086         return StatusCode::SUCCESS;
    00087       }
    00088     }
    00089   }
    00090   return StatusCode::FAILURE;
    00091 }
    00092
    00093
    00094 StatusCode HbookCnv::HDirectoryCnv::fillObjRefs(IOpaqueAddress* /* pAddress */,
    00095                                                 DataObject* pObject)   {
    00096   IRegistry* pReg = pObject->registry();
    00097   // Strip of store name to get the top level RZ directory
    00098   std::string full = m_prefix + pReg->identifier();
    00099   std::string lloc = full.substr(full.find('/',1),full.length());
    00100   std::string loc  = "/" + lloc;
    00101   std::string pawc = "//PAWC" + lloc;
    00102   long idh = 0;
    00103   ::HMDIR(pawc, "S");
    00104   ::HCDIR(loc, " ");
    00105   while( 1 )    {
    00106     std::string type = " ", title = "";
    00107     long icycle = 99999, ioff = 0;
    00108     IOpaqueAddress* pA = 0;
    00109     CLID clid = CLID_NULL;
    00110     char leaf_name[32];
    00111     ::HLNEXT(idh, type, title, "12ND");
    00112     if ( idh == 0 || title.length() == 0 ) break;
    00113     sprintf(leaf_name, "/%ld", idh);
    00114
    00115     switch ( type[0] )    {
    00116     case 'D':
    00117       createAddress(full, CLID_StatisticsDirectory, title, pA);
    00118       break;
    00119     case '1':
    00120       title = leaf_name;
    00121       createAddress(full, CLID_H1D, idh, pA);
    00122       break;
    00123     case '2':
    00124       title = leaf_name;
    00125       createAddress(full, CLID_H2D, idh, pA);
    00126       break;
    00127     case 'N':
    00128       ::HRIN( idh, icycle, ioff);
    00129       clid = (1 == ::NTUPLETYPE(idh)) ? CLID_ColumnWiseTuple : CLID_RowWiseTuple;
    00130       createAddress(full, clid, idh, pA);
    00131       title = leaf_name;
    00132       break;
    00133     default:
    00134       break;
    00135     }
    00136     if ( 0 != pA )    {
    00137       SmartIF<IDataManagerSvc> registrator(dataProvider());
    00138       registrator->registerAddress(pReg, title, pA);
    00139     }
    00140   }
    00141   return StatusCode::SUCCESS;
    00142 }