00001 // $Header: /nfs/slac/g/glast/ground/cvs/GaudiKernel/src/Lib/SmartRefBase.cpp,v 1.1.1.1 2001/04/18 18:14:18 tlindner 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: /nfs/slac/g/glast/ground/cvs/GaudiKernel/src/Lib/SmartRefBase.cpp,v 1.1.1.1 2001/04/18 18:14:18 tlindner Exp $ 00013 00014 // Framework include files 00015 #include "GaudiKernel/IDataProviderSvc.h" 00016 00017 #include "GaudiKernel/DataObject.h" 00018 #include "GaudiKernel/StreamBuffer.h" 00019 #include "GaudiKernel/SmartRefBase.h" 00020 #include "GaudiKernel/ContainedObject.h" 00021 #include "GaudiKernel/ObjectContainerBase.h" 00022 00023 #include "GaudiKernel/TransientStore.h" 00024 00025 typedef ObjectContainerBase _Container; 00026 00028 const ContainedObject* SmartRefBase::accessData(const ContainedObject*) const { 00029 if ( m_hintID != StreamBuffer::INVALID && m_linkID != StreamBuffer::INVALID && 0 != m_data ) { 00030 const _Container* cnt = dynamic_cast<const _Container*>(accessData(m_data)); 00031 return (cnt==0) ? 0 : cnt->containedObject(m_linkID); 00032 } 00033 return 0; 00034 } 00035 00037 const DataObject* SmartRefBase::accessData(const DataObject*) const { 00038 DataObject* source = const_cast<DataObject*>(m_data); 00039 DataObject* target = 0; 00040 if ( m_hintID != StreamBuffer::INVALID && source != 0 ) { 00041 DataObject::Link* link = source->symLink(m_hintID); 00042 TransientStore* store = source->store(); 00043 if ( 0 != link ) { 00044 IDataProviderSvc* datasvc = store->dataSvc(); 00045 target = link->object(); 00046 if ( 0 == target && 0 != datasvc ) { 00047 if ( 0 != datasvc ) { 00048 StatusCode status = datasvc->retrieveObject(link->path(), target); 00049 if ( status.isSuccess() ) { 00050 source->addLink(link->path(), target); 00051 } 00052 } 00053 } 00054 // Nothing we can do on failure.... 00055 if ( 0 != target && 0 != datasvc ) { 00056 // datasvc->updateObject(source->directory()); 00057 } 00058 } 00059 } 00060 return target; 00061 }
1.2.3 written by Dimitri van Heesch,
© 1997-2000