|
Gaudi Framework, version v23r2p1 |
| Home | Generated: Fri Jun 29 2012 |
Description: More...
#include <src/RootCnvSvc.h>


Public Member Functions | |
| RootCnvSvc (const std::string &name, ISvcLocator *svc) | |
| Standard constructor. | |
| virtual | ~RootCnvSvc () |
| Standard destructor. | |
| virtual StatusCode | updateServiceState (IOpaqueAddress *) |
| Update state of the service. | |
| StatusCode | error (const std::string &msg) |
| Standard way to print errors. | |
| StatusCode | connectDatabase (const std::string &dataset, int mode, RootDataConnection **con) |
| Connect the output file to the service with open mode. | |
| virtual StatusCode | initialize () |
| ConversionSvc overload: initialize Db service. | |
| virtual StatusCode | finalize () |
| ConversionSvc overload: Finalize Db service. | |
| virtual IConverter * | createConverter (long typ, const CLID &wanted, const ICnvFactory *fac) |
| ConversionSvc overload: Create new Converter using factory. | |
| virtual void | loadConverter (DataObject *pObj) |
| ConversionSvc overload: Load the class (dictionary) for the converter. | |
| virtual StatusCode | connectOutput (const std::string &outputFile, const std::string &openMode) |
| Connect the output file to the service with open mode. | |
| virtual StatusCode | connectOutput (const std::string &outputFile) |
| Connect the output file to the service. | |
| virtual StatusCode | commitOutput (const std::string &outputFile, bool do_commit) |
| Commit pending output. | |
| virtual StatusCode | disconnect (const std::string &dbName) |
| Disconnect from an existing data stream. | |
| virtual StatusCode | createAddress (long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) |
| IAddressCreator implementation: Address creation. | |
| virtual StatusCode | createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress) |
| IAddressCreator implementation: Creates an address in string form to object form. | |
| virtual StatusCode | createNullRep (const std::string &path) |
| Insert null marker for not existent transient object. | |
| virtual StatusCode | createNullRef (const std::string &path) |
| Insert null marker for not existent transient object. | |
| virtual StatusCode | i__createRep (DataObject *pObj, IOpaqueAddress *&refpAddr) |
| Convert the transient object to the requested persistent representation. | |
| virtual StatusCode | i__fillRepRefs (IOpaqueAddress *pAddr, DataObject *pObj) |
| Resolve the references of the converted object. | |
| virtual StatusCode | i__createObj (IOpaqueAddress *pAddr, DataObject *&refpObj) |
| Create transient object from persistent data. | |
| virtual StatusCode | i__fillObjRefs (IOpaqueAddress *pAddr, DataObject *pObj) |
| Resolve the references of the created transient object. | |
Protected Member Functions | |
| TClass * | getClass (DataObject *pObject) |
| Helper: Get TClass for a given DataObject pointer. | |
| MsgStream & | log () const |
| Helper: Use message streamer. | |
Protected Attributes | |
| Gaudi::IIODataManager * | m_ioMgr |
| Reference to the I/O data manager. | |
| IIncidentSvc * | m_incidentSvc |
| Reference to incident service. | |
| Gaudi::RootDataConnection * | m_current |
| On writing: reference to active output stream. | |
| TClass * | m_classRefs |
| TClass pointer to reference class. | |
| TClass * | m_classDO |
| TClass pointer to DataObject class. | |
| RootConnectionSetup * | m_setup |
| Setup structure (ref-counted) and passed to data connections. | |
| std::string | m_currSection |
| Property: ROOT section name. | |
| bool | m_incidentEnabled |
| Property: Flag to enable incidents on FILE_OPEN. | |
| std::string | m_shareFiles |
| Property: Share files ? If set to YES, files will not be closed on finalize. | |
| std::string | m_recordName |
| Property: Records name to fire incident for file records. | |
| std::string | m_ioPerfStats |
| Property: Enable TTree IOperfStats if not empty; otherwise perf stat file name. | |
| std::string | m_compression |
| Property: Compression-algorithm:compression-level. | |
| std::set< std::string > | m_badFiles |
| Set with bad files/tables. | |
| MsgStream * | m_log |
| Message streamer. | |
Description:
RootCnvSvc class implementation definition.
Definition at line 46 of file RootCnvSvc.h.
| Gaudi::RootCnvSvc::RootCnvSvc | ( | const std::string & | name, |
| ISvcLocator * | svc | ||
| ) |
Standard constructor.
| RootCnvSvc::~RootCnvSvc | ( | ) | [virtual] |
Standard destructor.
Definition at line 79 of file RootCnvSvc.cpp.
| virtual StatusCode Gaudi::RootCnvSvc::commitOutput | ( | const std::string & | outputFile, |
| bool | do_commit | ||
| ) | [virtual] |
Commit pending output.
| outputFile | String containig output file |
| do_commit | if true commit the output and flush eventually pending items to the database if false, discard pending buffers. Note: The possibility to commit or rollback depends on the database technology used! |
Reimplemented from ConversionSvc.
| StatusCode Gaudi::RootCnvSvc::connectDatabase | ( | const std::string & | dataset, |
| int | mode, | ||
| RootDataConnection ** | con | ||
| ) |
Connect the output file to the service with open mode.
| dataset | String containig file name |
| mode | String containig opening mode |
| virtual StatusCode Gaudi::RootCnvSvc::connectOutput | ( | const std::string & | outputFile, |
| const std::string & | openMode | ||
| ) | [virtual] |
Connect the output file to the service with open mode.
| outputFile | String containig output file |
| openMode | String containig opening mode of the output file |
Reimplemented from ConversionSvc.
| virtual StatusCode Gaudi::RootCnvSvc::connectOutput | ( | const std::string & | outputFile ) | [virtual] |
Connect the output file to the service.
| outputFile | String containig output file |
Reimplemented from ConversionSvc.
| StatusCode RootCnvSvc::createAddress | ( | long | svc_type, |
| const CLID & | clid, | ||
| const std::string * | par, | ||
| const unsigned long * | ip, | ||
| IOpaqueAddress *& | refpAddress | ||
| ) | [virtual] |
IAddressCreator implementation: Address creation.
Create an address using the link infotmation together with the triple (database name/container name/object name).
| refLink | Reference to abstract link information |
| dbName | Database name |
| containerName | Object container name |
| refpAddress | Opaque address information to retrieve object |
Reimplemented from ConversionSvc.
Definition at line 378 of file RootCnvSvc.cpp.
{
refpAddress = new RootAddress(typ,clid,par[0],par[1],ip[0],ip[1]);
return S_OK;
}
| virtual StatusCode Gaudi::RootCnvSvc::createAddress | ( | long | svc_type, |
| const CLID & | clid, | ||
| const std::string & | refAddress, | ||
| IOpaqueAddress *& | refpAddress | ||
| ) | [inline, virtual] |
IAddressCreator implementation: Creates an address in string form to object form.
| svc_type | Technology identifier encapsulated in this address. |
| clid | Class identifier of the DataObject represented by the opaque address |
| address | Input address. |
| refpAddress | Output address in string form. |
Reimplemented from ConversionSvc.
Definition at line 188 of file RootCnvSvc.h.
{
return this->ConversionSvc::createAddress(svc_type,clid,refAddress,refpAddress);
}
| IConverter * RootCnvSvc::createConverter | ( | long | typ, |
| const CLID & | wanted, | ||
| const ICnvFactory * | fac | ||
| ) | [virtual] |
ConversionSvc overload: Create new Converter using factory.
Reimplemented from ConversionSvc.
Definition at line 155 of file RootCnvSvc.cpp.
{
if ( wanted == CLID_StatisticsFile )
return new RootDatabaseCnv(typ,wanted,serviceLocator().get(),this);
else if ( wanted == CLID_StatisticsDirectory )
return new RootDirectoryCnv(typ,wanted,serviceLocator().get(),this);
else if ( wanted == CLID_RowWiseTuple )
return new RootNTupleCnv(typ,wanted,serviceLocator().get(),this);
else if ( wanted == CLID_ColumnWiseTuple )
return new RootNTupleCnv(typ,wanted,serviceLocator().get(),this);
else
return new RootConverter(typ,wanted,serviceLocator().get(),this);
}
| StatusCode RootCnvSvc::createNullRef | ( | const std::string & | path ) | [virtual] |
Insert null marker for not existent transient object.
| path | [IN] Path to the (null-)object |
Definition at line 397 of file RootCnvSvc.cpp.
{
RootObjectRefs* refs = 0;
size_t len = path.find('/',1);
string section = path.substr(1,len==string::npos ? string::npos : len-1);
pair<int,unsigned long> ret = m_current->save(section,path+"#R",0,refs);
log() << MSG::VERBOSE << "Writing object:" << path << " "
<< ret.first << " " << hex << ret.second << dec << " [NULL]" << endmsg;
return S_OK;
}
| StatusCode RootCnvSvc::createNullRep | ( | const std::string & | path ) | [virtual] |
Insert null marker for not existent transient object.
| path | [IN] Path to the (null-)object |
Definition at line 389 of file RootCnvSvc.cpp.
| virtual StatusCode Gaudi::RootCnvSvc::disconnect | ( | const std::string & | dbName ) | [virtual] |
Disconnect from an existing data stream.
| dbName | String containing name of the database |
| StatusCode Gaudi::RootCnvSvc::error | ( | const std::string & | msg ) |
Standard way to print errors.
after the printout an exception is thrown.
| msg | [IN] Message string to be printed. |
| StatusCode RootCnvSvc::finalize | ( | ) | [virtual] |
ConversionSvc overload: Finalize Db service.
Reimplemented from ConversionSvc.
Definition at line 125 of file RootCnvSvc.cpp.
{
log() << MSG::INFO;
if ( m_ioMgr ) {
IIODataManager::Connections cons = m_ioMgr->connections(0);
for(IIODataManager::Connections::iterator i=cons.begin(); i != cons.end(); ++i) {
RootDataConnection* pc = dynamic_cast<RootDataConnection*>(*i);
if ( pc ) {
if ( pc->owner() == this && !m_ioPerfStats.empty() ) {
pc->saveStatistics(m_ioPerfStats);
}
if ( pc->lookupClient(this) ) {
size_t num_clients = pc->removeClient(this);
if ( num_clients == 0 ) {
if ( m_ioMgr->disconnect(pc).isSuccess() ) {
log() << "Disconnected data IO:" << pc->fid()
<< " [" << pc->pfn() << "]" << endmsg;
delete pc;
}
}
}
}
}
releasePtr(m_ioMgr);
}
deletePtr(m_log);
releasePtr(m_incidentSvc);
return ConversionSvc::finalize();
}
| TClass * RootCnvSvc::getClass | ( | DataObject * | pObject ) | [protected] |
Helper: Get TClass for a given DataObject pointer.
Definition at line 185 of file RootCnvSvc.cpp.
{
map<CLID, TClass*>::iterator i=s_classesClids.find(pObject->clID());
if ( i != s_classesClids.end() ) return (*i).second;
loadConverter(pObject);
i=s_classesClids.find(pObject->clID());
if ( i != s_classesClids.end() ) return (*i).second;
string cname = System::typeinfoName(typeid(*pObject));
throw runtime_error("Unknown ROOT class for object:"+cname);
return 0;
}
| StatusCode RootCnvSvc::i__createObj | ( | IOpaqueAddress * | pAddr, |
| DataObject *& | refpObj | ||
| ) | [virtual] |
Create transient object from persistent data.
| pAddr | [IN] Pointer to object address. |
| refpObj | [OUT] Location to pointer to store data object |
Definition at line 469 of file RootCnvSvc.cpp.
{
refpObj = 0;
if ( pA ) {
RootDataConnection* con = 0;
const string* par = pA->par();
unsigned long* ipar = const_cast<unsigned long*>(pA->ipar());
StatusCode sc = connectDatabase(par[0],IDataConnection::READ,&con);
if ( sc.isSuccess() ) {
ipar[0] = (unsigned long)con;
DataObject* pObj = 0;
size_t len = par[1].find('/',1);
string section = par[1].substr(1,len==string::npos ? string::npos : len-1);
int nb = con->loadObj(section,par[1],ipar[1],pObj);
if ( nb > 1 || (nb == 1 && pObj->clID() == CLID_DataObject) ) {
refpObj = pObj;
return S_OK;
}
delete pObj;
}
string tag = par[0]+":"+par[1];
if ( m_badFiles.find(tag) == m_badFiles.end() ) {
m_badFiles.insert(tag);
return error("createObj> Cannot access the object:"+tag);
}
return S_FAIL;
}
return S_FAIL;
}
| StatusCode RootCnvSvc::i__createRep | ( | DataObject * | pObj, |
| IOpaqueAddress *& | refpAddr | ||
| ) | [virtual] |
Convert the transient object to the requested persistent representation.
| pObj | [IN] Pointer to data object |
| refpAddr | [OUT] Location to store pointer to object address. |
Definition at line 408 of file RootCnvSvc.cpp.
{
refpAddr = 0;
if ( pObj ) {
CLID clid = pObj->clID();
IRegistry* pR = pObj->registry();
string p[2] = {m_current->fid(), pR->identifier()};
TClass* cl = (clid == CLID_DataObject) ? m_classDO : getClass(pObj);
size_t len = p[1].find('/',1);
string sect = p[1].substr(1,len==string::npos ? string::npos : len-1);
pair<int,unsigned long> ret = m_current->saveObj(sect,p[1],cl,pObj,true);
if ( ret.first > 1 || (clid == CLID_DataObject && ret.first==1) ) {
unsigned long ip[2] = {0,ret.second};
if ( m_currSection.empty() ) m_currSection = p[1];
return createAddress(repSvcType(),clid,p,ip,refpAddr);
}
return error("Failed to write object data for:"+p[1]);
}
return error("createRep> Current Database is invalid!");
}
| StatusCode RootCnvSvc::i__fillObjRefs | ( | IOpaqueAddress * | pAddr, |
| DataObject * | pObj | ||
| ) | [virtual] |
Resolve the references of the created transient object.
| pAddr | [IN] Pointer to object address. |
| pObj | [IN] Pointer to data object |
Definition at line 500 of file RootCnvSvc.cpp.
{
if ( pA && pObj ) {
const unsigned long* ipar = pA->ipar();
RootDataConnection* con = (RootDataConnection*)ipar[0];
if ( con ) {
RootObjectRefs refs;
const string* par = pA->par();
size_t len = par[1].find('/',1);
string section = par[1].substr(1,len==string::npos ? string::npos : len-1);
int nb = con->loadRefs(section,par[1],ipar[1],refs);
log() << MSG::VERBOSE;
if ( nb >= 1 ) {
string npar[3];
unsigned long nipar[2];
IOpaqueAddress* nPA;
IRegistry* pR = pObj->registry();
SmartIF<IService> isvc(pR->dataSvc());
SmartIF<IDataManagerSvc> dataMgr(pR->dataSvc());
LinkManager* mgr = pObj->linkMgr();
bool active = log().isActive();
for(vector<int>::const_iterator i=refs.links.begin(); i!=refs.links.end();++i) {
mgr->addLink(con->getLink(*i),0);
}
for(size_t j=0, n=refs.refs.size(); j<n; ++j) {
const RootRef& r = refs.refs[j];
npar[0] = con->getDb(r.dbase);
npar[1] = con->getCont(r.container);
npar[2] = con->getLink(r.link);
nipar[0] = 0;
nipar[1] = r.entry;
StatusCode sc = addressCreator()->createAddress(r.svc,r.clid,npar,nipar,nPA);
if ( sc.isSuccess() ) {
if ( active ) {
log() << isvc->name() << " -> Register:" << pA->registry()->identifier()
<< "#" << npar[2] << "[" << r.entry << "]" << endmsg;
}
sc = dataMgr->registerAddress(pA->registry(),npar[2],nPA);
if ( sc.isSuccess() ) {
continue;
}
}
log() << MSG::ERROR << con->fid() << ": Failed to create address!!!!" << endmsg;
return S_FAIL;
}
return pObj->update();
}
}
return S_FAIL;
}
return error("read> Cannot read object -- no valid object address present ");
}
| StatusCode RootCnvSvc::i__fillRepRefs | ( | IOpaqueAddress * | pAddr, |
| DataObject * | pObj | ||
| ) | [virtual] |
Resolve the references of the converted object.
| pAddr | [IN] Pointer to object address. |
| pObj | [IN] Pointer to data object |
Definition at line 429 of file RootCnvSvc.cpp.
{
if ( pObj ) {
typedef vector<IRegistry*> Leaves;
Leaves leaves;
RootObjectRefs refs;
IRegistry* pR = pObj->registry();
SmartIF<IDataManagerSvc> dataMgr(pR->dataSvc());
if ( dataMgr ) {
StatusCode status = dataMgr->objectLeaves(pObj, leaves);
if ( status.isSuccess() ) {
RootRef ref;
const string& id = pR->identifier();
size_t len = id.find('/',1);
string sect = id.substr(1,len==string::npos ? string::npos : len-1);
LinkManager* pLinks = pObj->linkMgr();
for(Leaves::iterator i=leaves.begin(), iend=leaves.end(); i != iend; ++i) {
if ( (*i)->address() ) {
m_current->makeRef(*i,ref);
ref.entry = (*i)->address()->ipar()[1];
refs.refs.push_back(ref);
}
}
for(int i = 0, n=pLinks->size(); i < n; ++i) {
LinkManager::Link* lnk = pLinks->link(i);
int link_id = m_current->makeLink(lnk->path());
refs.links.push_back(link_id);
}
pair<int,unsigned long> ret = m_current->save(sect,id+"#R",m_classRefs,&refs,true);
if ( ret.first > 1 ) {
log() << MSG::DEBUG << "Writing object:" << id << " "
<< ret.first << " " << hex << ret.second << dec << endmsg;
return S_OK;
}
}
}
}
return S_FAIL;
}
| StatusCode RootCnvSvc::initialize | ( | ) | [virtual] |
ConversionSvc overload: initialize Db service.
Reimplemented from ConversionSvc.
Definition at line 95 of file RootCnvSvc.cpp.
{
string cname;
StatusCode status = ConversionSvc::initialize();
if ( !status.isSuccess() )
return error("Failed to initialize ConversionSvc base class.");
m_log = new MsgStream(msgSvc(),name());
if ( !m_compression.empty() ) {
log() << MSG::INFO << "Setting global ROOT compression to:" << m_compression << endmsg;
if ( !(status=RootConnectionSetup::setCompression(m_compression)).isSuccess() ) {
return error("Unable to interprete ROOT compression encoding:"+m_compression);
}
}
if( !(status=service("IODataManager", m_ioMgr)).isSuccess() )
return error("Unable to localize interface from service:IODataManager");
if( !(status=service("IncidentSvc", m_incidentSvc)).isSuccess() )
return error("Unable to localize interface from service:IncidentSvc");
m_setup->setMessageSvc(new MsgStream(msgSvc(),name()));
GaudiRoot::patchStreamers(log());
cname = System::typeinfoName(typeid(DataObject));
m_classDO = gROOT->GetClass(cname.c_str());
if ( 0 == m_classDO )
return error("Unable to load class description for DataObject");
cname = System::typeinfoName(typeid(RootObjectRefs));
m_classRefs = gROOT->GetClass(cname.c_str());
if ( 0 == m_classRefs )
return error("Unable to load class description for ObjectRefs");
return S_OK;
}
| void RootCnvSvc::loadConverter | ( | DataObject * | pObj ) | [virtual] |
ConversionSvc overload: Load the class (dictionary) for the converter.
Reimplemented from ConversionSvc.
Definition at line 169 of file RootCnvSvc.cpp.
{
if (pObject) {
string cname = System::typeinfoName(typeid(*pObject));
log() << MSG::DEBUG << "Trying to 'Autoload' dictionary for class " << cname << endmsg;
TClass* cl = s_classesNames[cname];
if ( 0 == cl ) {
cl = gROOT->GetClass(cname.c_str());
if ( cl ) {
s_classesNames[cname] = cl;
s_classesClids[pObject->clID()] = cl;
}
}
}
}
| MsgStream& Gaudi::RootCnvSvc::log | ( | ) | const [inline, protected] |
| virtual StatusCode Gaudi::RootCnvSvc::updateServiceState | ( | IOpaqueAddress * | ) | [inline, virtual] |
Update state of the service.
Reimplemented from ConversionSvc.
Definition at line 94 of file RootCnvSvc.h.
{ return StatusCode::SUCCESS; }
std::set<std::string> Gaudi::RootCnvSvc::m_badFiles [protected] |
Set with bad files/tables.
Definition at line 75 of file RootCnvSvc.h.
TClass* Gaudi::RootCnvSvc::m_classDO [protected] |
TClass pointer to DataObject class.
Definition at line 58 of file RootCnvSvc.h.
TClass* Gaudi::RootCnvSvc::m_classRefs [protected] |
TClass pointer to reference class.
Definition at line 56 of file RootCnvSvc.h.
std::string Gaudi::RootCnvSvc::m_compression [protected] |
Property: Compression-algorithm:compression-level.
Definition at line 73 of file RootCnvSvc.h.
Gaudi::RootDataConnection* Gaudi::RootCnvSvc::m_current [protected] |
On writing: reference to active output stream.
Definition at line 54 of file RootCnvSvc.h.
std::string Gaudi::RootCnvSvc::m_currSection [protected] |
Definition at line 62 of file RootCnvSvc.h.
bool Gaudi::RootCnvSvc::m_incidentEnabled [protected] |
Property: Flag to enable incidents on FILE_OPEN.
Definition at line 65 of file RootCnvSvc.h.
IIncidentSvc* Gaudi::RootCnvSvc::m_incidentSvc [protected] |
Reference to incident service.
Definition at line 52 of file RootCnvSvc.h.
Gaudi::IIODataManager* Gaudi::RootCnvSvc::m_ioMgr [protected] |
Reference to the I/O data manager.
Definition at line 50 of file RootCnvSvc.h.
std::string Gaudi::RootCnvSvc::m_ioPerfStats [protected] |
Property: Enable TTree IOperfStats if not empty; otherwise perf stat file name.
Definition at line 71 of file RootCnvSvc.h.
MsgStream* Gaudi::RootCnvSvc::m_log [protected] |
Message streamer.
Definition at line 78 of file RootCnvSvc.h.
std::string Gaudi::RootCnvSvc::m_recordName [protected] |
Property: Records name to fire incident for file records.
Definition at line 69 of file RootCnvSvc.h.
RootConnectionSetup* Gaudi::RootCnvSvc::m_setup [protected] |
Setup structure (ref-counted) and passed to data connections.
Definition at line 60 of file RootCnvSvc.h.
std::string Gaudi::RootCnvSvc::m_shareFiles [protected] |
Property: Share files ? If set to YES, files will not be closed on finalize.
Definition at line 67 of file RootCnvSvc.h.