Gaudi Framework, version v23r9

Home   Generated: Thu Jul 18 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
RootHistCnv::RConverter Class Reference

Root Converter. More...

#include <RConverter.h>

Inheritance diagram for RootHistCnv::RConverter:
Inheritance graph
[legend]
Collaboration diagram for RootHistCnv::RConverter:
Collaboration graph
[legend]

Public Member Functions

virtual StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAddr)
 Convert the transient object to the requested representation.
 
long repSvcType () const
 Retrieve the class type of the data store the converter uses.
 
StatusCode error (const std::string &msg)
 
StatusCode regTFile (const std::string, const TFile *)
 
StatusCode findTFile (const std::string, TFile *&)
 
std::string diskDirectory (const std::string &loc)
 
std::string directory (const std::string &loc)
 
void setDirectory (const std::string &loc)
 
void setDiskDirectory (const std::string &loc)
 
StatusCode createDirectory (const std::string &loc)
 
StatusCode createDiskDirectory (const std::string &loc)
 
std::string getDirectory ()
 
std::string convertId (const std::string &) const
 
- Public Member Functions inherited from Converter
virtual StatusCode initialize ()
 Initialize the converter.
 
virtual StatusCode finalize ()
 Initialize the converter.
 
virtual StatusCode setDataProvider (IDataProviderSvc *svc)
 Set Data provider service.
 
virtual SmartIF
< IDataProviderSvc > & 
dataProvider () const
 Get Data provider service.
 
virtual StatusCode setConversionSvc (IConversionSvc *svc)
 Set conversion service the converter is connected to.
 
virtual SmartIF< IConversionSvc > & conversionSvc () const
 Get conversion service the converter is connected to.
 
virtual StatusCode setAddressCreator (IAddressCreator *creator)
 Set address creator facility.
 
virtual SmartIF
< IAddressCreator > & 
addressCreator () const
 Retrieve address creator facility.
 
virtual const CLIDobjType () const
 Retrieve the class type of objects the converter produces.
 
virtual long i_repSvcType () const
 Retrieve the class type of the data store the converter uses.
 
virtual StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
 Create the transient representation of an object.
 
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the created transient object.
 
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject)
 Update the transient object from the other representation.
 
virtual StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the references of an updated transient object.
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
 
virtual StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the converted representation of a transient object.
 
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the references of an already converted object.
 
 Converter (long storage_type, const CLID &class_type, ISvcLocator *svc=0)
 Standard Constructor.
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist.
 
template<class T >
StatusCode service (const std::string &type, const std::string &name, T *&psvc) const
 Access a service by name, type creating it if it doesn't already exist.
 
SmartIF< IServiceservice (const std::string &name, const bool createIf=true) const
 Return a pointer to the service identified by name (or "type/name")
 

Static Public Member Functions

static long storageType ()
 Inquire storage type.
 

Protected Member Functions

 RConverter (const CLID &clid, ISvcLocator *svc)
 Standard constructor.
 
virtual ~RConverter ()
 Standard destructor.
 
virtual StatusCode readObject (IOpaqueAddress *pAddr, DataObject *&refpObj)
 Create the transient representation of an object.
 
virtual TObject * createPersistent (DataObject *pObj)
 Create the persistent representation of an object.
 
StatusCode createAddress (DataObject *pObject, TDirectory *pDir, TObject *pTObject, IOpaqueAddress *&refpAddr)
 Create address of the transient object according to the requested representation.
 
StatusCode createAddress (const std::string &rzdir, const CLID &clid, long id, TObject *pTobj, IOpaqueAddress *&refpAddress)
 
StatusCode createAddress (const std::string &rzdir, const CLID &clid, const std::string &title, TObject *pTobj, IOpaqueAddress *&refpAddress)
 
TDirectory * changeDirectory (DataObject *pObject)
 Switch to object directory (=Parent directory)
 
- Protected Member Functions inherited from Converter
virtual ~Converter ()
 Standard Destructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
SmartIF< IMessageSvc > & msgSvc () const
 Retrieve pointer to message service.
 
SmartIF< IMessageSvc > & messageService () const
 
SmartIF< IDataManagerSvc > & dataManager () const
 Get Data Manager service.
 

Additional Inherited Members

- Public Types inherited from implements1< IConverter >
typedef implements1 base_class
 Typedef to this class.
 
typedef extend_interfaces1
< IConverter
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 

Detailed Description

Root Converter.

Author
Charles Leggett

Definition at line 36 of file RConverter.h.

Constructor & Destructor Documentation

RootHistCnv::RConverter::RConverter ( const CLID clid,
ISvcLocator svc 
)
inlineprotected

Standard constructor.

Definition at line 61 of file RConverter.h.

: Converter(storageType(), clid, svc) { }
virtual RootHistCnv::RConverter::~RConverter ( )
inlineprotectedvirtual

Standard destructor.

Definition at line 64 of file RConverter.h.

{ }

Member Function Documentation

TDirectory * RootHistCnv::RConverter::changeDirectory ( DataObject pObject)
protected

Switch to object directory (=Parent directory)

Definition at line 236 of file RConverter.cpp.

{
if ( pObject ) {
IRegistry* pReg = pObject->registry();
if ( pReg ) {
if ( dataMgr.isValid() ) {
IRegistry* pParentReg = 0;
StatusCode status = dataMgr->objectParent(pReg, pParentReg);
if ( status.isSuccess() ) {
IOpaqueAddress* pParAddr = pParentReg->address();
if ( pParAddr ) {
TDirectory* pParentDir = (TDirectory*)pParAddr->ipar()[0];
if ( pParentDir ) {
gDirectory->cd(pParentDir->GetPath());
return pParentDir;
}
}
}
}
}
}
return 0;
}
std::string RootHistCnv::RConverter::convertId ( const std::string id) const

Definition at line 370 of file RConverter.cpp.

{
bool forced = false;
if ( id.size() > 0 && isdigit(id[0]) ) {
try {
tmp.assign(SmartIF<IProperty>(conversionSvc())->getProperty( "ForceAlphaIds"));
forced = (bool)tmp;
}
catch ( ... ) { }
}
if (forced ) return std::string("h") + id;
else return id;
}
StatusCode RootHistCnv::RConverter::createAddress ( DataObject pObject,
TDirectory *  pDir,
TObject *  pTObject,
IOpaqueAddress *&  refpAddr 
)
protected

Create address of the transient object according to the requested representation.

Definition at line 171 of file RConverter.cpp.

{
// Get address again....it does not change
IRegistry* pReg = pObj->registry();
if ( 0 != pReg ) {
refpAddr = pReg->address();
if ( 0 == refpAddr ) {
refpAddr = new RootObjAddress(repSvcType(),
pReg->name(),
"",
(unsigned long)(pDir),
(unsigned long)(pTObj),
pTObj);
}
}
}
StatusCode RootHistCnv::RConverter::createAddress ( const std::string rzdir,
const CLID clid,
long  id,
TObject *  pTobj,
IOpaqueAddress *&  refpAddress 
)
protected

Definition at line 218 of file RConverter.cpp.

{
std::ostringstream obj; obj << id;
StatusCode status = createAddress(rzdir, clid, obj.str(), pTobj, refpAddress);
if ( status.isSuccess() ) {
unsigned long* ipar = (unsigned long*)refpAddress->ipar();
ipar[0] = id;
}
return status;
}
StatusCode RootHistCnv::RConverter::createAddress ( const std::string rzdir,
const CLID clid,
const std::string title,
TObject *  pTobj,
IOpaqueAddress *&  refpAddress 
)
protected

Definition at line 197 of file RConverter.cpp.

{
RootObjAddress* pA = new RootObjAddress(repSvcType(),
clid,
rzdir,
title,
0,
0,
pTObj );
refpAddress = pA;
}
StatusCode RootHistCnv::RConverter::createDirectory ( const std::string loc)

Definition at line 26 of file RConverter.cpp.

{
MsgStream log(msgSvc(), "RConverter::createDir");
// Get rid of leading /NTUPLES
full = diskDirectory( loc );
int p,i;
std::string fil,cur,s;
TDirectory *gDir;
gDir = gDirectory;
TFile *tf;
if ( findTFile(loc,tf).isSuccess() ) {
tf->cd();
}
i = 1;
if ( (p=full.find(":",0)) != -1 ) {
fil = full.substr(0,p);
i = p+1;
fil += ":/";
gDirectory->cd(fil.c_str());
}
while ( (p = full.find("/",i)) != -1) {
s = full.substr(i,p-i);
lpath.push_back(s);
i = p+1;
}
lpath.push_back( full.substr(i,full.length()-i) );
if ( full.substr(0,1) == "/") {
gDirectory->cd("/");
}
for(litr=lpath.begin(); litr!=lpath.end(); ++litr) {
cur = *litr;
if (! gDirectory->GetKey(litr->c_str()) ) {
gDirectory->mkdir(litr->c_str());
}
gDirectory->cd(litr->c_str());
}
gDirectory = gDir;
}
StatusCode RootHistCnv::RConverter::createDiskDirectory ( const std::string loc)
TObject * RootHistCnv::RConverter::createPersistent ( DataObject pObj)
protectedvirtual

Create the persistent representation of an object.

Reimplemented in RootHistCnv::RHistogramCnv< T, S, Q >.

Definition at line 302 of file RConverter.cpp.

{
return 0;
}
StatusCode RootHistCnv::RConverter::createRep ( DataObject pObj,
IOpaqueAddress *&  refpAddr 
)
virtual

Convert the transient object to the requested representation.

Reimplemented from Converter.

Reimplemented in RootHistCnv::RNTupleCnv, RootHistCnv::RFileCnv, RootHistCnv::RDirectoryCnv, and RootHistCnv::DirectoryCnv.

Definition at line 264 of file RConverter.cpp.

{
pAddr = 0;
try {
TDirectory* pParentDir = changeDirectory(pObject);
if ( pParentDir ) {
TObject* pTObj = createPersistent(pObject);
if ( pTObj ) {
pTObj->Write();
delete pTObj;
return createAddress(pObject, pParentDir, 0, pAddr);
}
}
}
catch (...) {
}
MsgStream log (msgSvc(), "RConverter");
log << MSG::ERROR << "Failed to create persistent Object!" << endmsg;
}
std::string RootHistCnv::RConverter::directory ( const std::string loc)

Definition at line 113 of file RConverter.cpp.

{
return ( diskDirectory(loc) );
}
std::string RootHistCnv::RConverter::diskDirectory ( const std::string loc)

Definition at line 81 of file RConverter.cpp.

{
// Get rid of leading /NTUPLES/{INPUT_STREAM} or /stat/{INPUT_STREAM}
long lf1 = loc.find("/NTUPLES/");
long lf2 = loc.find("/stat/");
long ll;
if (lf1 != -1) {
ll = loc.find("/",lf1+9);
} else if (lf2 != -1) {
ll = loc.find("/",lf2+6);
} else {
MsgStream log(msgSvc(), "RConverter");
log << MSG::ERROR << "diskDirectory(" << loc << ")"
<< " --> no leading /NTUPLES/ or /stat/" << endmsg;
return loc;
}
// dir = loc.substr(ll+8,loc.length()-ll-8);
if (ll == -1) {
dir = "/";
} else {
dir = loc.substr(ll,loc.length()-ll);
}
return dir;
}
StatusCode RootHistCnv::RConverter::error ( const std::string msg)

Definition at line 386 of file RConverter.cpp.

{
MsgStream log(msgSvc(), "RootHistCnv");
}
StatusCode RootHistCnv::RConverter::findTFile ( const std::string  id,
TFile *&  tfile 
)

Definition at line 331 of file RConverter.cpp.

{
MsgStream log(msgSvc(), "RConverter");
tfile = 0;
// make sure we only get first two parts of id
int i1,i2,i3;
i1 = id.find("/",0);
if (i1 != 0) {
log << MSG::ERROR << "Directory name does not start with \"/\": "
<< id << endmsg;
}
i2 = id.find("/",i1+1);
if (i2 == -1) {
log << MSG::ERROR << "Directory name has only one part: " << id << endmsg;
}
i3 = id.find("/",i2+1);
if (i3 == -1) {
idm = id;
} else {
idm = id.substr(0,i3);
}
imap = s_fileMap.find(idm);
if ( imap == s_fileMap.end() ) {
}
tfile = (*imap).second;
}
std::string RootHistCnv::RConverter::getDirectory ( )

Definition at line 162 of file RConverter.cpp.

{
std::string dir = gDirectory->GetPath();
return (dir);
}
StatusCode RootHistCnv::RConverter::readObject ( IOpaqueAddress pAddr,
DataObject *&  refpObj 
)
protectedvirtual

Create the transient representation of an object.

Definition at line 289 of file RConverter.cpp.

{
// MsgStream log(msgSvc(), "RConverter::readObject");
// log << MSG::WARNING << pAddr->par()[0] << " <> " << pAddr->par()[1]
// << " <> "
// << pAddr->ipar()[0] << " <> " << pAddr->ipar()[1] << " <> "
// << pAddr->registry()->identifier() << endmsg;
}
StatusCode RootHistCnv::RConverter::regTFile ( const std::string  id,
const TFile *  tfile 
)

Definition at line 309 of file RConverter.cpp.

{
MsgStream log(msgSvc(), "RConverter");
imap = s_fileMap.find(id);
if ( imap != s_fileMap.end() ) {
log << MSG::ERROR << "cannot register TTree " << id
<< ": already exists" << endmsg;
}
s_fileMap[id] = const_cast<TFile*>(tfile);
}
long RootHistCnv::RConverter::repSvcType ( ) const
inlinevirtual

Retrieve the class type of the data store the converter uses.

Returns
Class type information about the source data store type the converter will use to retrieve the information.

Implements IConverter.

Definition at line 43 of file RConverter.h.

{ return i_repSvcType(); }
void RootHistCnv::RConverter::setDirectory ( const std::string loc)

Definition at line 120 of file RConverter.cpp.

{
MsgStream log(msgSvc(), "RConverter");
std::string full, id;
TFile *tf;
full = diskDirectory( loc );
// get associated TFile
if ( findTFile(loc,tf).isSuccess() ) {
tf->cd();
} else {
log << MSG::ERROR << "error getting TFile name " << loc << endmsg;
}
int p,i=1;
std::string cur,sdir;
gDirectory->cd("/");
while ( (p = full.find("/",i)) != -1) {
sdir = full.substr(i,p-i);
if (! gDirectory->GetKey(sdir.c_str()) ) {
log << MSG::ERROR << "cannot cd to " << full << " from "
<< gDirectory->GetPath() << endmsg;
return;
}
gDirectory->cd(sdir.c_str());
i = p+1;
}
gDirectory->cd( full.substr(i,full.length()-i).c_str() );
}
void RootHistCnv::RConverter::setDiskDirectory ( const std::string loc)

Definition at line 155 of file RConverter.cpp.

{
}
static long RootHistCnv::RConverter::storageType ( )
inlinestatic

Inquire storage type.

Definition at line 42 of file RConverter.h.

{ return ROOT_StorageType; }

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

Generated at Thu Jul 18 2013 12:18:16 for Gaudi Framework, version v23r9 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004