| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# HbookCnv::HNTupleCnv Class Reference

`#include <HNTupleCnv.h>`

Inheritance diagram for HbookCnv::HNTupleCnv:

[legend]
Collaboration diagram for HbookCnv::HNTupleCnv:

[legend]
List of all members.

## Detailed Description

NTuple converter class definition.

Description: Definition of the converter for Ntuples using HBOOK

Dependencies:

- Base class: Gaudi/Kernel/Converter.h

History :

          +---------+----------------------------------------------+--------+
          |    Date |                 Comment                      | Who    |
          +---------+----------------------------------------------+--------+
          | 21/10/99| Initial version.                             | MF     |
          +---------+----------------------------------------------+--------+

Author: M.Frank Version: 1.0

Definition at line 52 of file HNTupleCnv.h.

## Public Member Functions
virtual StatusCode | initialize ()
| Initialize the converter.
virtual StatusCode | finalize ()
| Finalize the converter.
virtual StatusCode | createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
| Create the transient representation of an object.
virtual StatusCode | updateObj (IOpaqueAddress *pAddress, DataObject *refpObject)
| Update the transient object from the other representation.
virtual StatusCode | createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
| Convert the transient object to the requested representation.
virtual StatusCode | updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
| Update the converted representation of a transient object.
## Protected Member Functions
| HNTupleCnv (ISvcLocator *svc, const CLID &clid)
| Standard constructor.
virtual | ~HNTupleCnv ()
| Standard destructor.
virtual StatusCode | load (long id, INTuple *&refpObject)=0
| Create the transient representation of an object.
virtual StatusCode | book (long idh, const std::string &loc, INTuple *pObject)=0
| Book the N tuple.
virtual StatusCode | writeData (long idh, INTuple *pObject)=0
| Write N tuple data.
virtual StatusCode | readData (long idh, INTuple *pObject, long ievt)=0
| Read N tuple data.
## Protected Attributes
INTupleSvc * | m_ntupleSvc
| Reference to N tuple service.

## Constructor & Destructor Documentation

HbookCnv::HNTupleCnv::HNTupleCnv | ( | ISvcLocator * | svc,
|  | const CLID & | clid |
| ) |  |  | `[protected]`

Standard constructor.

Definition at line 28 of file HNTupleCnv.cpp.

    00029 : HConverter(clid, svc), m_ntupleSvc(0)         {
    00030 }

HbookCnv::HNTupleCnv::~HNTupleCnv | ( |  | ) | `[protected, virtual]`

Standard destructor.

Definition at line 33 of file HNTupleCnv.cpp.

    00033                                             {
    00034 }

## Member Function Documentation

StatusCode HbookCnv::HNTupleCnv::initialize | ( |  | ) | `[virtual]`

Initialize the converter.

Reimplemented from Converter.

Definition at line 37 of file HNTupleCnv.cpp.

References Converter::dataProvider(), IID_INTupleSvc, Converter::initialize(), StatusCode::isSuccess(), m_ntupleSvc, and IInterface::queryInterface().

    00037                                             {
    00038   StatusCode status = Converter::initialize();
    00039   if ( status.isSuccess() )   {
    00040     status = dataProvider()->queryInterface(IID_INTupleSvc, (void**)&m_ntupleSvc);
    00041   }
    00042   return status;
    00043 }

StatusCode HbookCnv::HNTupleCnv::finalize | ( |  | ) | `[virtual]`

Finalize the converter.

Reimplemented from Converter.

Definition at line 46 of file HNTupleCnv.cpp.

References Converter::finalize(), m_ntupleSvc, and IInterface::release().

    00046                                             {
    00047   if ( m_ntupleSvc != 0 )     {
    00048     m_ntupleSvc->release();
    00049   }
    00050   m_ntupleSvc = 0;
    00051   return Converter::finalize();
    00052 }

StatusCode HbookCnv::HNTupleCnv::createObj | ( | IOpaqueAddress * | pAddress,
|  | DataObject *& | refpObject |
| ) |  |  | `[virtual]`

Create the transient representation of an object.

Reimplemented from Converter.

Definition at line 70 of file HNTupleCnv.cpp.

References MSG::DEBUG, HPRINT, IRegistry::identifier(), IOpaqueAddress::ipar(), StatusCode::isSuccess(), load(), Converter::msgSvc(), HbookCnv::HConverter::readObject(), and IOpaqueAddress::registry().

    00070                                                                                             {
    00071   long id = pAddress->ipar()[0];
    00072   IRegistry* pReg = pAddress->registry();
    00073   StatusCode status = readObject( pReg->identifier(), id );
    00074   if ( status.isSuccess() )   {
    00075     MsgStream log(msgSvc(), "HbookNTupleCnv");
    00076     INTuple* nt = 0;
    00077     log << MSG::DEBUG;
    00078     if ( log.isActive() ) ::HPRINT (id);
    00079     status = load(id, nt);
    00080     refpObject = dynamic_cast<DataObject*>(nt);
    00081   }
    00082   return status;
    00083 }

StatusCode HbookCnv::HNTupleCnv::updateObj | ( | IOpaqueAddress * | pAddress,
|  | DataObject * | refpObject |
| ) |  |  | `[virtual]`

Update the transient object from the other representation.

Reimplemented from Converter.

Definition at line 55 of file HNTupleCnv.cpp.

References StatusCode::FAILURE, IOpaqueAddress::ipar(), IOpaqueAddress::par(), readData(), HbookCnv::HConverter::setDirectory(), and HbookCnv::HConverter::setDiskDirectory().

    00055                                                                                         {
    00056   StatusCode status = StatusCode::FAILURE;
    00057   try   {
    00058     unsigned long* info = (unsigned long*)pAddress->ipar();
    00059     const std::string& dir = pAddress->par()[0];
    00060     setDiskDirectory(dir);
    00061     setDirectory(dir);
    00062     status = readData(info[0], dynamic_cast<INTuple*>(pObject), info[1]++);
    00063   }
    00064   catch (...)   {
    00065   }
    00066   return status;
    00067 }

StatusCode HbookCnv::HNTupleCnv::createRep | ( | DataObject * | pObject,
|  | IOpaqueAddress *& | refpAddress |
| ) |  |  | `[virtual]`

Convert the transient object to the requested representation.

Reimplemented from HbookCnv::HConverter.

Definition at line 86 of file HNTupleCnv.cpp.

References IRegistry::address(), book(), HbookCnv::HConverter::createAddress(), HbookCnv::HConverter::createDirectory(), HbookCnv::HConverter::diskDirectory(), endreq(), StatusCode::FAILURE, IRegistry::identifier(), StatusCode::isSuccess(), Converter::msgSvc(), IRegistry::name(), Converter::objType(), DataObject::registry(), std::basic_string< _CharT, _Traits, _Alloc >::rfind(), HbookCnv::HConverter::setDirectory(), HbookCnv::HConverter::setDiskDirectory(), std::basic_string< _CharT, _Traits, _Alloc >::substr(), MSG::WARNING, and writeData().

Referenced by updateRep().

    00086                                                                                      {
    00087   pAddr = 0;
    00088   try   {
    00089     typedef std::pair<std::string,long> hID;
    00090     typedef std::map< hID, bool > hIDMap;
    00091     static hIDMap usedIDs;
    00092     IRegistry* pReg = pObject->registry();
    00093     INTuple* pTuple = dynamic_cast<INTuple*>(pObject);
    00094     // Get address again....it does not change
    00095     pAddr = pReg->address();
    00096     if ( 0 == pAddr )    {
    00097       char* stop = 0;
    00098       const std::string& regName = pReg->identifier();
    00099       const std::string rzLoc = regName.substr(0, regName.rfind('/'));
    00100       long id = ::strtol(pReg->name().c_str()+1, &stop, 10);
    00101       if ( 0 >= id || usedIDs.find(hID(rzLoc,id)) != usedIDs.end() )
    00102       {
    00103         MsgStream msg(msgSvc(), "HNTupleCnv");
    00104         if ( 0 >= id )
    00105         {
    00106           msg << MSG::WARNING
    00107               << "Ntuple ID " << pReg->identifier()
    00108               << "' is an invalid HBOOK identifier" << endreq;
    00109         }
    00110         else
    00111         {
    00112           // ID is already used
    00113           msg << MSG::WARNING << "Ntuple ID '" << pReg->identifier()
    00114               << "' is already used" << endreq;
    00115         }
    00116         id = 1001;
    00117         while ( usedIDs.find(hID(rzLoc,id)) != usedIDs.end() ) { ++id; }
    00118         const std::string root = pReg->identifier().substr(0,pReg->identifier().rfind('/'));
    00119         msg << MSG::WARNING
    00120             << "  -> Adjusting PERSISTENT ID to '" << root << "/" << id << "'" << endreq;
    00121       }
    00122       usedIDs[hID(rzLoc,id)] = true;
    00123       StatusCode status = createDirectory(rzLoc);
    00124       if ( !status.isSuccess() )   {
    00125         return status;
    00126       }
    00127       setDirectory(rzLoc);
    00128       setDiskDirectory(rzLoc);
    00129       status = book(id, diskDirectory(rzLoc), pTuple);
    00130       if ( !status.isSuccess() )   {
    00131         return status;
    00132       }
    00133       status = createAddress( rzLoc, objType(), id, pAddr );
    00134       if ( !status.isSuccess() )   {
    00135         return status;
    00136       }
    00137     }
    00138     setDirectory(pAddr->par()[0]);
    00139     return writeData(pAddr->ipar()[0], pTuple);
    00140   }
    00141   catch (...)   {
    00142   }
    00143   return StatusCode::FAILURE;
    00144 }

StatusCode HbookCnv::HNTupleCnv::updateRep | ( | IOpaqueAddress * | pAddress,
|  | DataObject * | pObject |
| ) |  |  | `[virtual]`

Update the converted representation of a transient object.

Reimplemented from Converter.

Definition at line 147 of file HNTupleCnv.cpp.

References createRep(), endreq(), StatusCode::FAILURE, IRegistry::identifier(), MSG::INFO, IOpaqueAddress::ipar(), Converter::msgSvc(), DataObject::registry(), IOpaqueAddress::registry(), std::basic_string< _CharT, _Traits, _Alloc >::rfind(), std::basic_string< _CharT, _Traits, _Alloc >::substr(), MSG::WARNING, and HbookCnv::HConverter::writeObject().

    00148 {
    00149   MsgStream log(msgSvc(), "HNTupleCnv");
    00150   if ( 0 != pAddress )    {
    00151     IRegistry* pDir = pAddress->registry();
    00152     if ( 0 != pDir )    {
    00153       const std::string& regName = pDir->identifier();
    00154       const std::string loc = regName.substr(0, regName.rfind('/'));
    00155       long id = pAddress->ipar()[0];
    00156       log << MSG::INFO << "Saving:" << regName << " with ID:" << id << endreq;
    00157       return writeObject( loc, id );
    00158     }
    00159   }
    00160   else {
    00161     log << MSG::WARNING << "empty ntuple: "
    00162         << pObject->registry()->identifier() << endreq;
    00163     return ( createRep(pObject,pAddress) );
    00164   }
    00165   return StatusCode::FAILURE;
    00166 }

virtual StatusCode HbookCnv::HNTupleCnv::load | ( | long | id,
|  | INTuple *& | refpObject |
| ) |  |  | `[protected, pure virtual]`

Create the transient representation of an object.

Implemented in HbookCnv::HCWNTupleCnv, and HbookCnv::HRWNTupleCnv.

Referenced by createObj().

virtual StatusCode HbookCnv::HNTupleCnv::book | ( | long | idh,
|  | const std::string & | loc,
|  | INTuple * | pObject |
| ) |  |  | `[protected, pure virtual]`

Book the N tuple.

Implemented in HbookCnv::HCWNTupleCnv, and HbookCnv::HRWNTupleCnv.

Referenced by createRep().

virtual StatusCode HbookCnv::HNTupleCnv::writeData | ( | long | idh,
|  | INTuple * | pObject |
| ) |  |  | `[protected, pure virtual]`

Write N tuple data.

Implemented in HbookCnv::HCWNTupleCnv, and HbookCnv::HRWNTupleCnv.

Referenced by createRep().

virtual StatusCode HbookCnv::HNTupleCnv::readData | ( | long | idh,
|  | INTuple * | pObject,
|  | long | ievt |
| ) |  |  | `[protected, pure virtual]`

Read N tuple data.

Implemented in HbookCnv::HCWNTupleCnv, and HbookCnv::HRWNTupleCnv.

Referenced by updateObj().

## Member Data Documentation

INTupleSvc* HbookCnv::HNTupleCnv::m_ntupleSvc`[protected]`

Reference to N tuple service.

Definition at line 85 of file HNTupleCnv.h.

Referenced by finalize(), initialize(), HbookCnv::HRWNTupleCnv::load(), and HbookCnv::HCWNTupleCnv::load().

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/HbookCnv/v14r13/src/HNTupleCnv.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/HbookCnv/v14r13/src/HNTupleCnv.cpp