/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Static Public Member Functions | Protected Attributes
RootIOBaseCnv Class Reference

Base class for RootIO converters. More...

#include <RootIOBaseCnv.h>

Inheritance diagram for RootIOBaseCnv:
Inheritance graph
[legend]
Collaboration diagram for RootIOBaseCnv:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RootIOBaseCnv (const CLID &clid, ISvcLocator *svc)
virtual ~RootIOBaseCnv ()
virtual long repSvcType () const
 Class type.
virtual StatusCode initialize ()
 Converter interface.
virtual StatusCode finalize ()
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&dat)
 Convert the persistent object to transient.
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Convert the transient object to the requested representation.
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
virtual StatusCode TranObjectToPerObject (DataObject &dat, const RootOutputAddress &roa)=0
 Do the concrete conversion from TDS to ROOT Subclass must implement.
virtual StatusCode PerObjectToTranObject (DataObject *&dat)=0
 Do the concrete conversion from ROOT to TDS Subclass must implement and set dat = new object.
int commit (const RootOutputAddress &roa)
 Should be called after createRep() and fillRepRefs(), returns the entry number or -1 on error.
virtual const RootIOBaseObjectgetBaseInputObject ()=0
virtual const RootIOBaseObjectgetBaseOutputObject ()=0
RootIOBaseCnvotherConverter (int clID)
 Look up another converter based on the class ID on which it operates.
virtual RootInputStreammakeInputStream (const RootInputAddress &ria)=0
 Make a new input stream for this object and based on the given address.
virtual RootOutputStreammakeOutputStream (const RootOutputAddress &roa)=0
 Make a new output stream for this object and based on the given address.

Static Public Member Functions

static unsigned char storageType ()
 Storage type and class ID.
static const InterfaceID & interfaceID ()

Protected Attributes

IRootIOSvcm_rioSvc
 Pointer to the IRootIOSvc interface of RootIOCnvSvc.
IConversionSvc * m_cnvSvc
 Pointer to the conversion service interface of RootIOCnvSvc.
RootInputStreamm_ris
 Current RootInputStream, set just before PerObjectToTranObject() is called.

Detailed Description

Base class for RootIO converters.

bv@bnl.gov Sun Jun 29 10:40:18 2008

Definition at line 26 of file RootIOBaseCnv.h.


Constructor & Destructor Documentation

RootIOBaseCnv::RootIOBaseCnv ( const CLID &  clid,
ISvcLocator *  svc 
)

Definition at line 7 of file RootIOBaseCnv.cc.

    : Converter(ROOT_StorageType,clid,svc)
    , m_rioSvc(0)
{
}
RootIOBaseCnv::~RootIOBaseCnv ( ) [virtual]

Definition at line 13 of file RootIOBaseCnv.cc.

{
}

Member Function Documentation

static unsigned char RootIOBaseCnv::storageType ( ) [inline, static]

Storage type and class ID.

Definition at line 35 of file RootIOBaseCnv.h.

                                       {
        return ROOT_StorageType; 
    }
virtual long RootIOBaseCnv::repSvcType ( ) const [inline, virtual]

Class type.

Definition at line 40 of file RootIOBaseCnv.h.

                                    {
        return ROOT_StorageType; 
    }
StatusCode RootIOBaseCnv::initialize ( ) [virtual]

Converter interface.

Definition at line 17 of file RootIOBaseCnv.cc.

{
    StatusCode sc = Converter::initialize();
    if (sc.isFailure()) return sc;

    MsgStream log(msgSvc(), "RootIOBaseCnv");

    IService* isvc=0;
    sc = serviceLocator()->service("RootIOCnvSvc", isvc, false);
    if (sc.isFailure()) {
        log << MSG::ERROR << "Conversion service RootIOCnvSvc"
            << " could not be retrieved" << endreq;
        return sc;
    }
    isvc->addRef();

    sc = isvc->queryInterface(IRootIOSvc::interfaceID(), (void**)&m_rioSvc);
    if (sc.isFailure()) {
        log << MSG::ERROR << "Conversion service RootIOCnvSvc"
            << " does not implement IRootIOCnvSvc" << endreq;
        return sc;
    }

    sc = isvc->queryInterface(IConversionSvc::interfaceID(),(void**)&m_cnvSvc);
    if (sc.isFailure()) {
        log << MSG::ERROR 
            << "RootIOCnvSvc does not implement IConversionSvc" << endreq;
        return sc;
    }    

    return sc;
}
StatusCode RootIOBaseCnv::finalize ( ) [virtual]

Definition at line 142 of file RootIOBaseCnv.cc.

{
    return StatusCode::SUCCESS;
}
StatusCode RootIOBaseCnv::createObj ( IOpaqueAddress *  addr,
DataObject *&  dat 
) [virtual]

Convert the persistent object to transient.

IMPLEMENTED, sub class should not override.

Definition at line 51 of file RootIOBaseCnv.cc.

{
    MsgStream log(msgSvc(), "RootIOBaseCnv::createObj");
    log << MSG::DEBUG << "createObj " << objType() << endreq;

    RootInputAddress* ria = dynamic_cast<RootInputAddress*>(addr);
    if (!ria) {
        log << MSG::ERROR << "was not given a RootInputAddress" << endreq;
        return StatusCode::FAILURE;
    }
    
    RootInputStream* ris = ria->stream();
    if (!ris) {
        log << MSG::ERROR << "RootInputAddress did not have stream" << endreq;
        return StatusCode::FAILURE;
    }

    // Read in persistent object unless already done so.
    if (!ria->readIsDone()) {
        bool okay = false;
        int fileNumber = ria->fileNumber();

        // Set entry but don't read.
        if (fileNumber == -1) {
            log << MSG::DEBUG << "setEntry(" << ria->entry() <<")"<< endreq;
            okay = ris->setEntry(ria->entry(),false);
        }
        else {
            log << MSG::DEBUG << "setFileEntry(" << fileNumber 
                <<","<< ria->entry() <<")"<< endreq;
            okay = ris->setFileEntry(fileNumber,ria->entry(),false);
            if (!okay) {
                log << MSG::ERROR << "failed to set " << objType() 
                    << " entry to " << ria->entry() << " fileNumber=" << fileNumber
                    << endreq;
                return StatusCode::FAILURE;
            }
        }

        // Now read
        okay = ris->read();
        if (!okay) {
            log << MSG::ERROR << "failed to read " << objType() 
                << " entry " << ria->entry()
                << endreq;
            return StatusCode::FAILURE;
        }
        ria->readDone();
    }

    m_ris = ris;
    return PerObjectToTranObject(dat);
}
StatusCode RootIOBaseCnv::createRep ( DataObject *  pObject,
IOpaqueAddress *&  refpAddress 
) [virtual]

Convert the transient object to the requested representation.

IMPLEMENTED, sub class should not override

Definition at line 105 of file RootIOBaseCnv.cc.

{

    // Purpose and Method: Convert the transient object to ROOT

    MsgStream log(msgSvc(), "RootIOBaseCnv");
    log << MSG::DEBUG << "createRep " << objType() << endreq;

    // get the corresponding address 
    RootOutputAddress *roa = 0;
    StatusCode sc = m_rioSvc->createAddress(obj,roa);
    addr = roa;
    
    //  do the real conversion in the derived converter
    sc = TranObjectToPerObject(*obj,*roa);
    if (sc.isFailure()) {
        log << MSG::ERROR << "Could not transform object" << endreq;
        return sc;
    }

    return StatusCode::SUCCESS;
}
StatusCode RootIOBaseCnv::fillRepRefs ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
) [virtual]

Resolve the references of the converted object.

UNIMPLEMENTED (empty), subclass may override.

Definition at line 129 of file RootIOBaseCnv.cc.

{
    MsgStream log(msgSvc(), "RootIOBaseCnv");
    log << MSG::DEBUG << "fillRepRefs " << objType() << endreq;

    return StatusCode::SUCCESS;
}
StatusCode RootIOBaseCnv::fillObjRefs ( IOpaqueAddress *  pAddress,
DataObject *  pObject 
) [virtual]

Resolve the references of the converted object.

UNIMPLEMENTED (empty), subclass may override.

Definition at line 137 of file RootIOBaseCnv.cc.

{
    return StatusCode::SUCCESS;
}
virtual StatusCode RootIOBaseCnv::TranObjectToPerObject ( DataObject &  dat,
const RootOutputAddress roa 
) [pure virtual]

Do the concrete conversion from TDS to ROOT Subclass must implement.

Implemented in RootIOTypedCnv< PerType, TranType >.

virtual StatusCode RootIOBaseCnv::PerObjectToTranObject ( DataObject *&  dat) [pure virtual]

Do the concrete conversion from ROOT to TDS Subclass must implement and set dat = new object.

Implemented in RootIOTypedCnv< PerType, TranType >.

int RootIOBaseCnv::commit ( const RootOutputAddress roa)

Should be called after createRep() and fillRepRefs(), returns the entry number or -1 on error.

Definition at line 148 of file RootIOBaseCnv.cc.

{
    RootOutputStream* ros = m_rioSvc->outputStream(roa);
    if (!ros) return StatusCode::FAILURE;
    //int entries = ros->entries();
    int entries = ros->fileEntries();
    bool okay = ros->write();
    if (okay) return entries;
    return -1;
}
virtual const RootIOBaseObject* RootIOBaseCnv::getBaseInputObject ( ) [pure virtual]
virtual const RootIOBaseObject* RootIOBaseCnv::getBaseOutputObject ( ) [pure virtual]
RootIOBaseCnv * RootIOBaseCnv::otherConverter ( int  clID)

Look up another converter based on the class ID on which it operates.

Definition at line 160 of file RootIOBaseCnv.cc.

{
    MsgStream log(msgSvc(), "RootIOBaseCnv::otherConverter");

    IConversionSvc* cnvSvc = this->conversionSvc();
    if (!cnvSvc) {
        log << MSG::WARNING
            << "Failed to get conversion service" << endreq;
        return 0;
    }
    IConverter* cnv = cnvSvc->converter(clID);
    if (!cnv) {
        log << MSG::WARNING
            << "Failed to get converter for class ID #" << clID << endreq;
        return 0;
    }

    RootIOBaseCnv* base = dynamic_cast<RootIOBaseCnv*>(cnv);
    if (!base) {
        log << MSG::WARNING
            << "Failed to dynamic_cast converter to RootIOBaseCnv" << endreq;
    }
    return base;
}
static const InterfaceID& IRootIOCnv::interfaceID ( ) [inline, static, inherited]

Definition at line 19 of file IRootIOCnv.h.

{ return IID_IRootIOCnv; }
virtual RootInputStream* IRootIOCnv::makeInputStream ( const RootInputAddress ria) [pure virtual, inherited]

Make a new input stream for this object and based on the given address.

Implemented in RootIOTypedCnv< PerType, TranType >.

virtual RootOutputStream* IRootIOCnv::makeOutputStream ( const RootOutputAddress roa) [pure virtual, inherited]

Make a new output stream for this object and based on the given address.

Implemented in RootIOTypedCnv< PerType, TranType >.


Member Data Documentation

Pointer to the IRootIOSvc interface of RootIOCnvSvc.

Definition at line 96 of file RootIOBaseCnv.h.

IConversionSvc* RootIOBaseCnv::m_cnvSvc [protected]

Pointer to the conversion service interface of RootIOCnvSvc.

Definition at line 99 of file RootIOBaseCnv.h.

Current RootInputStream, set just before PerObjectToTranObject() is called.

Definition at line 103 of file RootIOBaseCnv.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:58:18 for RootIOSvc by doxygen 1.7.4