|
Gaudi Framework, version v22r2 |
| Home | Generated: Tue May 10 2011 |
Description: Definition of the generic Db data converter. More...
#include <PoolDb/PoolDbBaseCnv.h>


Public Member Functions | |
| PoolDbBaseCnv (long typ, const CLID &clid, ISvcLocator *svc) | |
| Initializing Constructor. | |
| virtual | ~PoolDbBaseCnv () |
| Standard Destructor. | |
| virtual StatusCode | initialize () |
| Converter overrides: Initialize the Db converter. | |
| virtual StatusCode | finalize () |
| Converter overrides: Finalize the Db data converter. | |
| virtual long | repSvcType () const |
| Retrieve the class type of the data store the converter uses. | |
| virtual StatusCode | createObj (IOpaqueAddress *pAddr, DataObject *&refpObj) |
| Converter overrides: Create transient object from persistent data. | |
| virtual StatusCode | fillObjRefs (IOpaqueAddress *pAddr, DataObject *pObj) |
| Converter overrides: Resolve the references of the created transient object. | |
| virtual StatusCode | updateObj (IOpaqueAddress *pAddr, DataObject *pObj) |
| Converter overrides: Update transient object from persistent data. | |
| virtual StatusCode | updateObjRefs (IOpaqueAddress *pAddr, DataObject *pObj) |
| Converter overrides: Update the references of an updated transient object. | |
| virtual StatusCode | createRep (DataObject *pObj, IOpaqueAddress *&refpAddr) |
| Converter overrides: Convert the transient object to the requested representation. | |
| virtual StatusCode | fillRepRefs (IOpaqueAddress *pAddr, DataObject *pObj) |
| Converter overrides: Resolve the references of the converted object. | |
| virtual StatusCode | updateRep (IOpaqueAddress *pAddr, DataObject *pObj) |
| Converter overrides: Update the converted representation of a transient object. | |
| virtual StatusCode | updateRepRefs (IOpaqueAddress *pAddr, DataObject *pObj) |
| Converter overrides: Update the references of an already converted object. | |
| virtual PoolDbLinkManager * | createReferences (DataObject *pObj) |
| virtual StatusCode | setReferences (PoolDbLinkManager *pMgr, LinkManager *pLinks, DataObject *pObj, IRegistry *pReg) |
| Set the references of a DataObject when reading. | |
| virtual StatusCode | dumpReferences (PoolDbLinkManager *pMgr, LinkManager *pLinks, DataObject *pObj, IRegistry *pReg) |
| Dump the references of a DataObject after writing. | |
Protected Member Functions | |
| StatusCode | makeError (const std::string &msg, bool rethrow=true) |
| Standard way to print errors. | |
| virtual const std::string | containerName (IRegistry *pReg) const |
| Retrieve the name of the container a given object is placed into. | |
Protected Attributes | |
| IPoolDbMgr * | m_dbMgr |
| Services needed for proper operation: POOL database manager. | |
| IDataManagerSvc * | m_dataMgr |
| Services needed for proper operation: Gaudi datastore manager. | |
| pool::Guid | m_objGuid |
| Object Guid. | |
| ROOT::Reflex::Type | m_class |
| Reference to seal reflection class. | |
| pool::DataCallBack * | m_call |
| Definition callback. | |
| std::set< std::string > | m_badFiles |
| Set with bad files/tables. | |
Description: Definition of the generic Db data converter.
The generic data converter provides the infrastructure of all data converters. The templated class takes two arguments: The Transient and the Persistent object type.
For a detailed description of the overridden function see the the base class.
Definition at line 45 of file PoolDbBaseCnv.h.
| PoolDbBaseCnv::PoolDbBaseCnv | ( | long | typ, |
| const CLID & | clid, | ||
| ISvcLocator * | svc | ||
| ) |
Initializing Constructor.
Standard Constructor.
| typ | [IN] Concrete storage type of the converter |
| clid | [IN] Class identifier of the object |
| svc | [IN] Pointer to service locator object |
Definition at line 255 of file PoolDbBaseCnv.cpp.
| PoolDbBaseCnv::~PoolDbBaseCnv | ( | ) | [virtual] |
Standard Destructor.
Definition at line 264 of file PoolDbBaseCnv.cpp.
{
pool::releasePtr(m_dbMgr);
s_count->decrement();
}
| const std::string PoolDbBaseCnv::containerName | ( | IRegistry * | pReg ) | const [protected, virtual] |
Retrieve the name of the container a given object is placed into.
| pReg | [IN] Pointer to registry entry. |
Reimplemented in PoolDbDatabaseCnv, and PoolDbStatCnv.
Definition at line 353 of file PoolDbBaseCnv.cpp.
{
if ( 0 != pRegistry ) {
return pRegistry->identifier();
}
return "";
}
| StatusCode PoolDbBaseCnv::createObj | ( | IOpaqueAddress * | pAddr, |
| DataObject *& | refpObj | ||
| ) | [virtual] |
Converter overrides: Create transient object from persistent data.
Db specific implementation: Create an empty transient object: Default: DataObject.
| pAddr | [IN] Pointer to object address. |
| refpObj | [OUT] Location to pointer to store data object |
Reimplemented from Converter.
Reimplemented in PoolDbDatabaseCnv, PoolDbDirectoryCnv, and PoolDbNTupleCnv.
Definition at line 500 of file PoolDbBaseCnv.cpp.
{
try {
PoolDbAddress* pA = dynamic_cast<PoolDbAddress*>(pAddress);
if ( pA ) {
PoolDbObjectContext ctxt(this, pAddress->registry());
pool::DataCallBack* call = m_call->clone();
StatusCode sc = m_dbMgr->read(call, pA);
if ( sc.isSuccess() ) {
refpObject = (DataObject*)call->object();
call->release();
return StatusCode::SUCCESS;
}
call->release();
std::string tag = pA->par()[0]+":"+pA->par()[1];
if ( sc.getCode() == IPoolDbMgr::BAD_DATA_CONNECTION ) {
if ( m_badFiles.find(tag) != m_badFiles.end() ) {
return sc; // Let's save us the additional printout
}
m_badFiles.insert(tag);
}
MsgStream log(msgSvc(),"PoolDbBaseCnv");
log << MSG::ERROR << "createObj> Cannot access the object:"+tag << endmsg;
return StatusCode::FAILURE;
}
return makeError("createObj> Invalid object address.", false);
}
catch (std::exception& e) {
return makeError(std::string("createObj> Caught exception:")+e.what(), false);
}
catch(...) {
}
return makeError("createObj> Unknown exception occurred.", false);
}
| PoolDbLinkManager * PoolDbBaseCnv::createReferences | ( | DataObject * | pObj ) | [virtual] |
Definition at line 448 of file PoolDbBaseCnv.cpp.
{
typedef std::vector<IRegistry*> Leaves;
PoolDbLinkManager* refs = new PoolDbLinkManager;
Leaves leaves;
StatusCode status = m_dataMgr->objectLeaves(pObj, leaves);
if ( status.isSuccess() ) {
for(Leaves::iterator i=leaves.begin(), iend=leaves.end(); i != iend; ++i) {
IRegistry* pR = *i;
IOpaqueAddress* pA = pR->address();
if ( 0 != pA ) {
PoolDbAddress* pdbA = dynamic_cast<PoolDbAddress*>(pA);
if ( 0 != pdbA ) {
pool::Token* tok = const_cast<pool::Token*>(pdbA->token());
if ( tok ) {
tok->addRef();
refs->references().push_back(tok);
refs->links().push_back(pR->name());
}
else {
// What should we do here ?
// Not so clear...
}
}
else {
const std::string* spar = pA->par();
const unsigned long* ipar = pA->ipar();
pool::Guid guid(pool::Guid::null());
guid.Data1 = pA->clID();
pool::Token* tok = new pool::Token();
tok->setClassID(guid);
tok->setTechnology(pA->svcType());
tok->setDb(spar[0]).setCont(spar[1]);
tok->oid().first = ipar[0];
tok->oid().second = ipar[1];
refs->references().push_back(tok);
refs->links().push_back(pR->name());
}
}
else {
// This is not really an error, it only means that the object
// pointed to is not persistent. Hence, this link cannot be followed
// from the data written.
}
}
}
return refs;
}
| StatusCode PoolDbBaseCnv::createRep | ( | DataObject * | pObj, |
| IOpaqueAddress *& | refpAddr | ||
| ) | [virtual] |
Converter overrides: Convert the transient object to the requested representation.
Create persistent representation of the object.
| pObj | [IN] Pointer to data object |
| refpAddr | [OUT] Location to store pointer to object address. |
Reimplemented from Converter.
Reimplemented in PoolDbDirectoryCnv, and PoolDbNTupleCnv.
Definition at line 584 of file PoolDbBaseCnv.cpp.
{
try {
refpA = 0;
if ( pObj ) {
IRegistry* pReg = pObj->registry();
if ( pReg ) {
PoolDbAddress* pA = 0;
std::string cnt = containerName(pReg);
PoolDbObjectContext ctxt(this, pObj->registry());
pool::DataCallBack* call = m_call->clone();
call->setObject(pObj);
StatusCode sc = m_dbMgr->markWrite(call, cnt, &pA);
if ( sc.isSuccess() ) {
refpA = pA;
return sc;
}
}
return makeError("createRep> Invalid object registry entry.");
}
return makeError("createRep> Invalid object reference.");
}
catch (std::exception& e) {
makeError(std::string("createRep> Caught exception:")+e.what());
}
catch (...) {
return makeError("createRep> Unknown Fatal Exception.");
}
return makeError("createRep> Fatal Error.");
}
| StatusCode PoolDbBaseCnv::dumpReferences | ( | PoolDbLinkManager * | pMgr, |
| LinkManager * | pLinks, | ||
| DataObject * | pObj, | ||
| IRegistry * | pReg | ||
| ) | [virtual] |
Dump the references of a DataObject after writing.
| pMgr | [IN] Pointer to POOL Link manager object |
| pLinks | [IN] Pointer to intermediate link manager |
| pObj | [IN] Pointer to data object |
| pReg | [IN] Pointer to registry entry |
Definition at line 374 of file PoolDbBaseCnv.cpp.
{
if ( printLinks() ) {
MsgStream log(msgSvc(), "dumpReferences");
LinkManager* mgr = pObj->linkMgr();
for ( int i = 0; i < mgr->size(); ++i) {
LinkManager::Link* lnk = mgr->link(i);
log << MSG::ALWAYS << "PUT> " << pObj->registry()->identifier() << "[" << i << "] = " << lnk->path() << endmsg;
}
}
return StatusCode::SUCCESS;
}
| StatusCode PoolDbBaseCnv::fillObjRefs | ( | IOpaqueAddress * | pAddr, |
| DataObject * | pObj | ||
| ) | [virtual] |
Converter overrides: Resolve the references of the created transient object.
Resolve the references of the created transient object.
| pAddr | [IN] Pointer to object address. |
| pObj | [IN] Pointer to data object |
Reimplemented from Converter.
Reimplemented in PoolDbDirectoryCnv, and PoolDbNTupleCnv.
Definition at line 537 of file PoolDbBaseCnv.cpp.
{
return updateObjRefs(pAddress, pObject);
}
| StatusCode PoolDbBaseCnv::fillRepRefs | ( | IOpaqueAddress * | pAddr, |
| DataObject * | pObj | ||
| ) | [virtual] |
Converter overrides: Resolve the references of the converted object.
Resolve the references of the converted object.
| pAddr | [IN] Pointer to object address. |
| pObj | [IN] Pointer to data object |
Reimplemented from Converter.
Reimplemented in PoolDbNTupleCnv.
Definition at line 642 of file PoolDbBaseCnv.cpp.
{
return updateRepRefs(pAddr, pObj);
}
| StatusCode PoolDbBaseCnv::finalize | ( | void | ) | [virtual] |
Converter overrides: Finalize the Db data converter.
Finalize the Db converter.
Reimplemented from Converter.
Definition at line 339 of file PoolDbBaseCnv.cpp.
{
pool::DbTypeInfo* shapeH = 0;
if ( m_call ) {
shapeH = dynamic_cast<pool::DbTypeInfo*>((pool::Shape*)m_call->shape());
if ( shapeH ) shapeH->deleteRef();
}
pool::releasePtr(m_call);
pool::releasePtr(m_dbMgr);
pool::releasePtr(m_dataMgr);
return Converter::finalize();
}
| StatusCode PoolDbBaseCnv::initialize | ( | ) | [virtual] |
Converter overrides: Initialize the Db converter.
Initialize the converter.
Reimplemented from Converter.
Definition at line 270 of file PoolDbBaseCnv.cpp.
{
StatusCode status = Converter::initialize();
MsgStream log(msgSvc(),"PoolDbBaseCnv");
if ( !status.isSuccess() ) {
log << MSG::ERROR << "Cannot initialize base class \"Converter\"" << endmsg;
return status;
}
IPoolDbMgr **ptr1 = &m_dbMgr;
status = conversionSvc()->queryInterface(IPoolDbMgr::interfaceID(), (void**)ptr1);
if ( !status.isSuccess() ) {
log << MSG::ERROR << "Cannot connect to \"IPoolDbMgr\" interface." << endmsg;
return status;
}
IDataManagerSvc **ptr2 = &m_dataMgr;
status = dataProvider()->queryInterface(IDataManagerSvc::interfaceID(), (void**)ptr2);
if ( !status.isSuccess() ) {
log << MSG::ERROR << "Cannot connect to \"IDataManagerSvc\" interface." << endmsg;
return status;
}
const pool::DbTypeInfo* shapeH = 0;
const ROOT::Reflex::Type refH = ROOT::Reflex::Type::ByName("PoolDbLinkManager");
if ( !refH ) {
log << MSG::ERROR << "Dictionary for class \"PoolDbLinkManager\" missing." << endmsg;
return StatusCode::FAILURE;
}
const ROOT::Reflex::Type lnkH = ROOT::Reflex::Type::ByName("LinkManager");
if ( !lnkH ) {
log << MSG::ERROR << "Dictionary for class \"LinkManager\" missing." << endmsg;
return StatusCode::FAILURE;
}
m_class = pool::DbReflex::forGuid(m_objGuid);
if ( !m_class ) {
// This may fail if the dictionary is not yet loaded, therefore it is not going to report an ERROR
log << MSG::DEBUG << "Dictionary for class with GUID:" << m_objGuid.toString()
<< " missing." << endmsg;
return StatusCode::FAILURE;
}
if ( !pool::DbTransform::getShape(m_objGuid, shapeH).isSuccess() ) {
std::vector<const pool::DbColumn*> c;
c.push_back(new pool::DbColumn(m_class.Name(),
m_class.Name(ROOT::Reflex::SCOPED),
pool::DbColumn::POINTER,
0));
c.push_back(new pool::DbColumn("Links",
lnkH.Name(ROOT::Reflex::SCOPED),
pool::DbColumn::POINTER,
0));
c.push_back(new pool::DbColumn("Refs",
refH.Name(ROOT::Reflex::SCOPED),
pool::DbColumn::POINTER,
0));
shapeH = pool::DbTypeInfo::create(m_objGuid, c);
}
if ( shapeH ) {
log << MSG::DEBUG << "Created object shape for class:"
<< m_class.Name(ROOT::Reflex::SCOPED) << endmsg
<< shapeH->toString() << endmsg;
shapeH->addRef();
m_call = new PoolDbDataObjectHandler(m_class);
m_call->setShape(shapeH);
}
else {
return makeError("Failed to create POOL shape information for GUID:"+
m_objGuid.toString(),false);
}
return status;
}
| StatusCode PoolDbBaseCnv::makeError | ( | const std::string & | msg, |
| bool | rethrow = true |
||
| ) | [protected] |
Standard way to print errors.
after the printout an exception is thrown.
| msg | [IN] Message string to be printed. |
| rethrow | [IN] Flag to indicate if an exception must be thrown |
Definition at line 360 of file PoolDbBaseCnv.cpp.
{
MsgStream log(msgSvc(),"PoolDbBaseCnv");
log << MSG::ERROR << "Trouble with class:" << m_objGuid.toString() << " ";
if ( m_class ) log << "<" << m_class.Name(ROOT::Reflex::SCOPED) << "> ";
log << endmsg;
log << msg << endmsg;
if ( rethrow ) {
pool::debugBreak("Error:"+msg, "PoolDbBaseCnv", true);
}
return StatusCode::FAILURE;
}
| virtual long PoolDbBaseCnv::repSvcType | ( | ) | const [inline, virtual] |
Retrieve the class type of the data store the converter uses.
Implements IConverter.
Definition at line 97 of file PoolDbBaseCnv.h.
{
return i_repSvcType();
}
| StatusCode PoolDbBaseCnv::setReferences | ( | PoolDbLinkManager * | pMgr, |
| LinkManager * | pLinks, | ||
| DataObject * | pObj, | ||
| IRegistry * | pReg | ||
| ) | [virtual] |
Set the references of a DataObject when reading.
| pMgr | [IN] Pointer to POOL Link manager object |
| pLinks | [IN] Pointer to intermediate link manager |
| pObj | [IN] Pointer to data object |
| pReg | [IN] Pointer to registry entry |
Definition at line 391 of file PoolDbBaseCnv.cpp.
{
std::string tmp;
LinkManager* pmgr = pObj->linkMgr();
for(int i = 0; i < pLinks->size(); ++i) {
LinkManager::Link* lnk = pLinks->link(i);
pmgr->addLink(lnk->path(), 0);
}
size_t ref_size = mgr->references().size();
for(size_t j = 0; j < ref_size; ++j) {
IOpaqueAddress* pA = 0;
const pool::Token* token = mgr->references()[j];
std::string& location = mgr->links()[j];
long typ = token->technology();
CLID clid = token->classID().Data1;
std::string spar[] = {token->dbID(),
token->contID()};
unsigned long ipar[] = {token->oid().first,
token->oid().second};
StatusCode sc = addressCreator()->createAddress(typ,clid,spar,ipar,pA);
if ( sc.isSuccess() ) {
// Temporary fix for all files written with previous release(s)
// The fix should be removed when these files are obsolete
if ( location.substr(0,7) == "/Event/" ) {
size_t idx = location.rfind("/");
tmp = (idx==std::string::npos) ? location : location.substr(idx);
location = tmp;
}
sc = m_dataMgr->registerAddress(pReg, location, pA);
if ( sc.isSuccess() ) {
// MsgStream log(msgSvc(), "Reflection");
// log << MSG::ALWAYS << "Registered:" << pReg->identifier() << " as " << location << endmsg;
continue;
}
pA->release();
ROOT::Reflex::Type classH = pool::DbReflex::forGuid(token->classID());
MsgStream err(msgSvc(), "Reflection");
if ( 0 == classH ) {
err << MSG::ERROR << "No reflection information availible for class ID:"
<< token->classID().toString() << endmsg;
}
else {
err << MSG::ERROR << "Reflection information availible for class ID:"
<< token->classID().toString() << endmsg
<< classH.Name(ROOT::Reflex::SCOPED) << endmsg;
}
makeError("setReferences> Failed to register opaque address:"+location+
"\n"+token->toString());
}
}
return StatusCode::SUCCESS;
}
| StatusCode PoolDbBaseCnv::updateObj | ( | IOpaqueAddress * | pAddr, |
| DataObject * | pObj | ||
| ) | [virtual] |
Converter overrides: Update transient object from persistent data.
Db specific implementation: Update a transient object: Default: DataObject.
| pAddr | [IN] Pointer to object address. |
| pObj | [IN] Pointer to data object |
Reimplemented from Converter.
Reimplemented in PoolDbDirectoryCnv, and PoolDbNTupleCnv.
Definition at line 544 of file PoolDbBaseCnv.cpp.
{
try {
PoolDbAddress* pA = dynamic_cast<PoolDbAddress*>(pAddr);
if ( 0 != pA ) {
return makeError("updateObj> Sorry folks, not yet implemented...");
}
return makeError("updateObj> Invalid opaque object address.");
}
catch (std::exception& e) {
return makeError(std::string("updateObj> Caught exception:")+e.what());
}
catch (...) {
}
return makeError("updateObj> Unknown Error - exception was thrown.");
}
| StatusCode PoolDbBaseCnv::updateObjRefs | ( | IOpaqueAddress * | pAddr, |
| DataObject * | pObj | ||
| ) | [virtual] |
Converter overrides: Update the references of an updated transient object.
Update the references of an updated transient object.
| pAddr | [IN] Pointer to object address. |
| pObj | [IN] Pointer to data object |
Reimplemented from Converter.
Reimplemented in PoolDbDirectoryCnv, and PoolDbNTupleCnv.
Definition at line 563 of file PoolDbBaseCnv.cpp.
{
if ( 0 != pObj ) {
// First call the reconfiguration callback
StatusCode sc = pObj->update();
if ( sc.isSuccess() && printLinks() ) {
MsgStream log(msgSvc(), "updateObjRefs");
LinkManager* mgr = pObj->linkMgr();
std::string id = pObj->registry()->identifier();
for ( int i = 0; i < mgr->size(); ++i) {
LinkManager::Link* lnk = mgr->link(i);
log << MSG::ALWAYS << "GET> " << id << "[" << i << "] = " << lnk->path() << endmsg;
}
}
return sc;
}
return makeError("updateObjRefs> Invalid object reference.");
}
| StatusCode PoolDbBaseCnv::updateRep | ( | IOpaqueAddress * | pAddr, |
| DataObject * | pObj | ||
| ) | [virtual] |
Converter overrides: Update the converted representation of a transient object.
Update the converted representation of a transient object.
| pAddr | [IN] Pointer to object address. |
| pObj | [IN] Pointer to data object |
Reimplemented from Converter.
Reimplemented in PoolDbDirectoryCnv, and PoolDbNTupleCnv.
Definition at line 617 of file PoolDbBaseCnv.cpp.
{
try {
PoolDbAddress* pA = dynamic_cast<PoolDbAddress*>(pAddr);
if ( 0 != pA ) {
if ( pObj ) {
PoolDbObjectContext ctxt(this, pAddr->registry());
pool::DataCallBack* call = m_call->clone();
call->setObject(pObj);
return m_dbMgr->markUpdate(call, pA);
}
return makeError("updateRep> Invalid object reference.");
}
return makeError("updateRep> Invalid opaque object address.");
}
catch (std::exception& e) {
makeError(std::string("updateRep> Caught exception:")+e.what());
}
catch (...) {
return makeError("updateRep> Unknown Fatal Exception.");
}
return makeError("updateRep> Fatal Error.");
}
| StatusCode PoolDbBaseCnv::updateRepRefs | ( | IOpaqueAddress * | pAddr, |
| DataObject * | pObj | ||
| ) | [virtual] |
Converter overrides: Update the references of an already converted object.
Update the references of an already converted object.
| pAddr | [IN] Pointer to object address. |
| pObj | [IN] Pointer to data object |
Reimplemented from Converter.
Reimplemented in PoolDbDirectoryCnv, and PoolDbNTupleCnv.
Definition at line 649 of file PoolDbBaseCnv.cpp.
{
if ( pObj ) {
return StatusCode::SUCCESS;
}
return makeError("updateRepRefs> Invalid object reference.");
}
std::set<std::string> PoolDbBaseCnv::m_badFiles [protected] |
Set with bad files/tables.
Definition at line 58 of file PoolDbBaseCnv.h.
pool::DataCallBack* PoolDbBaseCnv::m_call [protected] |
Definition callback.
Definition at line 56 of file PoolDbBaseCnv.h.
ROOT::Reflex::Type PoolDbBaseCnv::m_class [protected] |
Reference to seal reflection class.
Definition at line 54 of file PoolDbBaseCnv.h.
IDataManagerSvc* PoolDbBaseCnv::m_dataMgr [protected] |
Services needed for proper operation: Gaudi datastore manager.
Definition at line 50 of file PoolDbBaseCnv.h.
IPoolDbMgr* PoolDbBaseCnv::m_dbMgr [protected] |
Services needed for proper operation: POOL database manager.
Definition at line 48 of file PoolDbBaseCnv.h.
pool::Guid PoolDbBaseCnv::m_objGuid [protected] |
Object Guid.
Definition at line 52 of file PoolDbBaseCnv.h.