|
Gaudi Framework, version v23r2 |
| Home | Generated: Thu Jun 28 2012 |
00001 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/src/Lib/SmartRefBase.cpp,v 1.8 2005/05/10 12:24:16 hmd Exp $ 00002 // ==================================================================== 00003 // SmartRefBase.cpp 00004 // -------------------------------------------------------------------- 00005 // 00006 // Package : Root conversion example 00007 // 00008 // Author : Markus Frank 00009 // 00010 // ==================================================================== 00011 #define KERNEL_SMARTREFBASE_CPP 1 00012 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/src/Lib/SmartRefBase.cpp,v 1.8 2005/05/10 12:24:16 hmd Exp $ 00013 00014 // Framework include files 00015 #include "GaudiKernel/IDataProviderSvc.h" 00016 #include "GaudiKernel/GaudiException.h" 00017 #include "GaudiKernel/IRegistry.h" 00018 #include "GaudiKernel/DataObject.h" 00019 #include "GaudiKernel/LinkManager.h" 00020 #include "GaudiKernel/StreamBuffer.h" 00021 #include "GaudiKernel/SmartRefBase.h" 00022 #include "GaudiKernel/ContainedObject.h" 00023 #include "GaudiKernel/ObjectContainerBase.h" 00024 00025 typedef ObjectContainerBase _Container; 00026 00028 void SmartRefBase::set(DataObject* pObj, long hint_id, long link_id) { 00029 m_data = pObj; 00030 m_hintID = hint_id; 00031 m_linkID = link_id; 00032 } 00033 00035 const ContainedObject* SmartRefBase::accessData(const ContainedObject*) const { 00036 if ( m_hintID != StreamBuffer::INVALID && m_linkID != StreamBuffer::INVALID ) { 00037 const _Container* cnt = dynamic_cast<const _Container*>(accessData(m_data)); 00038 if ( 0 != cnt ) { 00039 return cnt->containedObject(m_linkID); 00040 } 00041 } 00042 return 0; 00043 } 00044 00046 const DataObject* SmartRefBase::accessData(const DataObject*) const { 00047 DataObject* target = 0; 00048 DataObject* source =0; 00049 if ( 0 == m_data && 0 != m_contd ) { 00050 m_data = m_contd->parent(); 00051 } 00052 source = const_cast<DataObject*>(m_data); 00053 if ( m_hintID != StreamBuffer::INVALID && source != 0 ) { 00054 LinkManager* mgr = source->linkMgr(); 00055 if ( 0 != mgr ) { 00056 LinkManager::Link* link = mgr->link(m_hintID); 00057 if ( 0 != link ) { 00058 target = link->object(); 00059 if ( 0 == target ) { 00060 IRegistry* reg = source->registry(); 00061 if ( 0 != reg ) { 00062 IDataProviderSvc* datasvc = reg->dataSvc(); 00063 if ( 0 != datasvc ) { 00064 if ( datasvc->retrieveObject(link->path(), target).isSuccess() ) { 00065 link->setObject(target); 00066 } 00067 } 00068 } 00069 } 00070 } 00071 } 00072 } 00073 return target; 00074 } 00075 00076 // Extended equality check 00077 bool SmartRefBase::isEqualEx(const DataObject* pObj, const SmartRefBase& c) const { 00078 if ( c.m_hintID != StreamBuffer::INVALID && 0 != pObj ) { 00079 DataObject* source = const_cast<DataObject*>(c.m_data); 00080 if ( 0 != source ) { 00081 LinkManager* mgr = source->linkMgr(); 00082 if ( 0 != mgr ) { 00083 LinkManager::Link* link = mgr->link(c.m_hintID); 00084 if ( 0 != link ) { 00085 IRegistry* pReg = pObj->registry(); 00086 if ( pReg != 0 ) { 00087 return link->path() == pReg->identifier(); 00088 } 00089 } 00090 } 00091 } 00092 } 00093 return false; 00094 } 00095 00096 // Extended equality check 00097 bool SmartRefBase::isEqualEx(const ContainedObject* pObj, const SmartRefBase& c) const { 00098 if ( isEqualEx(pObj->parent(), c) ) { 00099 return pObj->index() == c.m_linkID; 00100 } 00101 return false; 00102 } 00103 00104 const std::string &SmartRefBase::path () const { 00105 static std::string s_empty_string = std::string(); 00106 DataObject *source = 0; 00107 if ( 0 == m_data && 0 != m_contd ) { 00108 m_data = m_contd->parent(); 00109 } 00110 source = const_cast<DataObject*>(m_data); 00111 if ( m_hintID != StreamBuffer::INVALID && source != 0 ) { 00112 LinkManager* mgr = source->linkMgr(); 00113 if ( 0 != mgr ) { 00114 LinkManager::Link* link = mgr->link(m_hintID); 00115 if ( 0 != link ) 00116 return link->path(); 00117 } 00118 } 00119 return s_empty_string; 00120 }