#include <RootIOBaseCnv.h>
Inheritance diagram for RootIOBaseCnv:
Public Types | |
INVALID_ADDRESS | |
INVALID_OBJECT | |
NO_MEMORY | |
BAD_STORAGE_TYPE | |
NO_SOURCE_OBJECT | |
ICONVERSIONSVC_LAST_ERROR | |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
enum | Status |
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 RootIOBaseObject * | getBaseInputObject ()=0 |
virtual const RootIOBaseObject * | getBaseOutputObject ()=0 |
RootIOBaseCnv * | otherConverter (int clID) |
Look up another converter based on the class ID on which it operates. | |
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface) |
virtual unsigned long | addRef () |
virtual unsigned long | release () |
virtual StatusCode | setDataProvider (IDataProviderSvc *svc) |
virtual IDataProviderSvc * | dataProvider () const |
virtual StatusCode | setConversionSvc (IConversionSvc *svc) |
virtual IConversionSvc * | conversionSvc () const |
virtual StatusCode | setAddressCreator (IAddressCreator *creator) |
virtual IAddressCreator * | addressCreator () const |
virtual const CLID & | objType () const |
virtual long | i_repSvcType () const |
virtual StatusCode | updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) |
virtual StatusCode | updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) |
virtual StatusCode | updateRep (IOpaqueAddress *pAddress, DataObject *pObject) |
virtual StatusCode | updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) |
StatusCode | service (const std::string &name, T *&psvc, bool createIf=false) const |
StatusCode | service (const std::string &type, const std::string &name, T *&psvc) const |
virtual RootInputStream * | makeInputStream (const RootInputAddress &ria)=0 |
Make a new input stream for this object and based on the given address. | |
virtual RootOutputStream * | makeOutputStream (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 () |
static const InterfaceID & | interfaceID () |
Public Attributes | |
INVALID_ADDRESS | |
INVALID_OBJECT | |
NO_MEMORY | |
BAD_STORAGE_TYPE | |
NO_SOURCE_OBJECT | |
ICONVERSIONSVC_LAST_ERROR | |
Protected Member Functions | |
ISvcLocator * | serviceLocator () const |
IMessageSvc * | msgSvc () const |
IMessageSvc * | messageService () const |
IDataManagerSvc * | dataManager () const |
Protected Attributes | |
IRootIOSvc * | m_rioSvc |
Pointer to the IRootIOSvc interface of RootIOCnvSvc. | |
IConversionSvc * | m_cnvSvc |
Pointer to the conversion service interface of RootIOCnvSvc. | |
RootInputStream * | m_ris |
Current RootInputStream, set just before PerObjectToTranObject() is called. |
bv@bnl.gov Sun Jun 29 10:40:18 2008
Definition at line 26 of file RootIOBaseCnv.h.
RootIOBaseCnv::RootIOBaseCnv | ( | const CLID & | clid, | |
ISvcLocator * | svc | |||
) |
Definition at line 7 of file RootIOBaseCnv.cc.
00008 : Converter(ROOT_StorageType,clid,svc) 00009 , m_rioSvc(0) 00010 { 00011 }
RootIOBaseCnv::~RootIOBaseCnv | ( | ) | [virtual] |
static unsigned char RootIOBaseCnv::storageType | ( | ) | [inline, static] |
Storage type and class ID.
Definition at line 35 of file RootIOBaseCnv.h.
00035 { 00036 return ROOT_StorageType; 00037 }
virtual long RootIOBaseCnv::repSvcType | ( | ) | const [inline, virtual] |
Class type.
Implements Converter.
Definition at line 40 of file RootIOBaseCnv.h.
00040 { 00041 return ROOT_StorageType; 00042 }
StatusCode RootIOBaseCnv::initialize | ( | ) | [virtual] |
Converter interface.
Reimplemented from Converter.
Definition at line 17 of file RootIOBaseCnv.cc.
00018 { 00019 StatusCode sc = Converter::initialize(); 00020 if (sc.isFailure()) return sc; 00021 00022 MsgStream log(msgSvc(), "RootIOBaseCnv"); 00023 00024 IService* isvc=0; 00025 sc = serviceLocator()->service("RootIOCnvSvc", isvc, false); 00026 if (sc.isFailure()) { 00027 log << MSG::ERROR << "Conversion service RootIOCnvSvc" 00028 << " could not be retrieved" << endreq; 00029 return sc; 00030 } 00031 isvc->addRef(); 00032 00033 sc = isvc->queryInterface(IRootIOSvc::interfaceID(), (void**)&m_rioSvc); 00034 if (sc.isFailure()) { 00035 log << MSG::ERROR << "Conversion service RootIOCnvSvc" 00036 << " does not implement IRootIOCnvSvc" << endreq; 00037 return sc; 00038 } 00039 00040 sc = isvc->queryInterface(IConversionSvc::interfaceID(),(void**)&m_cnvSvc); 00041 if (sc.isFailure()) { 00042 log << MSG::ERROR 00043 << "RootIOCnvSvc does not implement IConversionSvc" << endreq; 00044 return sc; 00045 } 00046 00047 return sc; 00048 }
StatusCode RootIOBaseCnv::finalize | ( | ) | [virtual] |
Reimplemented from Converter.
Definition at line 142 of file RootIOBaseCnv.cc.
00143 { 00144 return StatusCode::SUCCESS; 00145 }
StatusCode RootIOBaseCnv::createObj | ( | IOpaqueAddress * | addr, | |
DataObject *& | dat | |||
) | [virtual] |
Convert the persistent object to transient.
IMPLEMENTED, sub class should not override.
Reimplemented from Converter.
Definition at line 51 of file RootIOBaseCnv.cc.
00052 { 00053 MsgStream log(msgSvc(), "RootIOBaseCnv::createObj"); 00054 log << MSG::DEBUG << "createObj " << objType() << endreq; 00055 00056 RootInputAddress* ria = dynamic_cast<RootInputAddress*>(addr); 00057 if (!ria) { 00058 log << MSG::ERROR << "was not given a RootInputAddress" << endreq; 00059 return StatusCode::FAILURE; 00060 } 00061 00062 RootInputStream* ris = ria->stream(); 00063 if (!ris) { 00064 log << MSG::ERROR << "RootInputAddress did not have stream" << endreq; 00065 return StatusCode::FAILURE; 00066 } 00067 00068 // Read in persistent object unless already done so. 00069 if (!ria->readIsDone()) { 00070 bool okay = false; 00071 int fileNumber = ria->fileNumber(); 00072 00073 // Set entry but don't read. 00074 if (fileNumber == -1) { 00075 log << MSG::DEBUG << "setEntry(" << ria->entry() <<")"<< endreq; 00076 okay = ris->setEntry(ria->entry(),false); 00077 } 00078 else { 00079 log << MSG::DEBUG << "setFileEntry(" << fileNumber 00080 <<","<< ria->entry() <<")"<< endreq; 00081 okay = ris->setFileEntry(fileNumber,ria->entry(),false); 00082 if (!okay) { 00083 log << MSG::ERROR << "failed to set " << objType() 00084 << " entry to " << ria->entry() << " fileNumber=" << fileNumber 00085 << endreq; 00086 return StatusCode::FAILURE; 00087 } 00088 } 00089 00090 // Now read 00091 okay = ris->read(); 00092 if (!okay) { 00093 log << MSG::ERROR << "failed to read " << objType() 00094 << " entry " << ria->entry() 00095 << endreq; 00096 return StatusCode::FAILURE; 00097 } 00098 ria->readDone(); 00099 } 00100 00101 m_ris = ris; 00102 return PerObjectToTranObject(dat); 00103 }
StatusCode RootIOBaseCnv::createRep | ( | DataObject * | pObject, | |
IOpaqueAddress *& | refpAddress | |||
) | [virtual] |
Convert the transient object to the requested representation.
IMPLEMENTED, sub class should not override
Reimplemented from Converter.
Definition at line 105 of file RootIOBaseCnv.cc.
00107 { 00108 00109 // Purpose and Method: Convert the transient object to ROOT 00110 00111 MsgStream log(msgSvc(), "RootIOBaseCnv"); 00112 log << MSG::DEBUG << "createRep " << objType() << endreq; 00113 00114 // get the corresponding address 00115 RootOutputAddress *roa = 0; 00116 StatusCode sc = m_rioSvc->createAddress(obj,roa); 00117 addr = roa; 00118 00119 // do the real conversion in the derived converter 00120 sc = TranObjectToPerObject(*obj,*roa); 00121 if (sc.isFailure()) { 00122 log << MSG::ERROR << "Could not transform object" << endreq; 00123 return sc; 00124 } 00125 00126 return StatusCode::SUCCESS; 00127 }
StatusCode RootIOBaseCnv::fillRepRefs | ( | IOpaqueAddress * | pAddress, | |
DataObject * | pObject | |||
) | [virtual] |
Resolve the references of the converted object.
UNIMPLEMENTED (empty), subclass may override.
Reimplemented from Converter.
Definition at line 129 of file RootIOBaseCnv.cc.
00130 { 00131 MsgStream log(msgSvc(), "RootIOBaseCnv"); 00132 log << MSG::DEBUG << "fillRepRefs " << objType() << endreq; 00133 00134 return StatusCode::SUCCESS; 00135 }
StatusCode RootIOBaseCnv::fillObjRefs | ( | IOpaqueAddress * | pAddress, | |
DataObject * | pObject | |||
) | [virtual] |
Resolve the references of the converted object.
UNIMPLEMENTED (empty), subclass may override.
Reimplemented from Converter.
Definition at line 137 of file RootIOBaseCnv.cc.
00138 { 00139 return StatusCode::SUCCESS; 00140 }
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.
00149 { 00150 RootOutputStream* ros = m_rioSvc->outputStream(roa); 00151 if (!ros) return StatusCode::FAILURE; 00152 //int entries = ros->entries(); 00153 int entries = ros->fileEntries(); 00154 bool okay = ros->write(); 00155 if (okay) return entries; 00156 return -1; 00157 }
virtual const RootIOBaseObject* RootIOBaseCnv::getBaseInputObject | ( | ) | [pure virtual] |
Implemented in RootIOTypedCnv< PerType, TranType >.
virtual const RootIOBaseObject* RootIOBaseCnv::getBaseOutputObject | ( | ) | [pure virtual] |
Implemented in RootIOTypedCnv< PerType, TranType >.
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.
00161 { 00162 MsgStream log(msgSvc(), "RootIOBaseCnv::otherConverter"); 00163 00164 IConversionSvc* cnvSvc = this->conversionSvc(); 00165 if (!cnvSvc) { 00166 log << MSG::WARNING 00167 << "Failed to get conversion service" << endreq; 00168 return 0; 00169 } 00170 IConverter* cnv = cnvSvc->converter(clID); 00171 if (!cnv) { 00172 log << MSG::WARNING 00173 << "Failed to get converter for class ID #" << clID << endreq; 00174 return 0; 00175 } 00176 00177 RootIOBaseCnv* base = dynamic_cast<RootIOBaseCnv*>(cnv); 00178 if (!base) { 00179 log << MSG::WARNING 00180 << "Failed to dynamic_cast converter to RootIOBaseCnv" << endreq; 00181 } 00182 return base; 00183 }
static const InterfaceID& IRootIOCnv::interfaceID | ( | ) | [inline, static, inherited] |
Reimplemented from IInterface.
Definition at line 19 of file IRootIOCnv.h.
00019 { 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 >.
IRootIOSvc* RootIOBaseCnv::m_rioSvc [protected] |
IConversionSvc* RootIOBaseCnv::m_cnvSvc [protected] |
Pointer to the conversion service interface of RootIOCnvSvc.
Definition at line 99 of file RootIOBaseCnv.h.
RootInputStream* RootIOBaseCnv::m_ris [protected] |
Current RootInputStream, set just before PerObjectToTranObject() is called.
Definition at line 103 of file RootIOBaseCnv.h.