![]() |
|
|
Generated: 24 Nov 2008 |
00001 // ==================================================================== 00002 // SmartDataPtr.h 00003 // -------------------------------------------------------------------- 00004 // 00005 // Package : GaudiKernel ( The LHCb Offline System) 00006 // 00007 // Description: Implementation of a smart pointer class to access 00008 // easily (and efficiently) data stores. 00009 // 00010 // Author : M.Frank 00011 // ==================================================================== 00012 #ifndef GAUDIKERNEL_SMARTDATAPTR_H 00013 #define GAUDIKERNEL_SMARTDATAPTR_H 1 00014 00015 // Framework include files 00016 #include "GaudiKernel/SmartDataStorePtr.h" 00017 #include "GaudiKernel/DataObject.h" 00018 00046 template<class TYPE> class SmartDataPtr : public SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader> { 00047 public: 00048 00050 using SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>::operator=; 00051 00060 SmartDataPtr(IDataProviderSvc* pService, const std::string& fullPath) 00061 : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,0,fullPath) 00062 { 00063 } 00064 00073 SmartDataPtr(IDataProviderSvc* pService, IRegistry* pDirectory) 00074 : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,pDirectory,"") 00075 { 00076 } 00077 00089 SmartDataPtr(IDataProviderSvc* pService, DataObject* pObject, const std::string& path) 00090 : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,0,path) 00091 { 00092 if ( 0 != pObject ) { 00093 this->m_pRegistry = pObject->registry(); 00094 } 00095 } 00096 00106 SmartDataPtr(SmartDataObjectPtr& refObject, IRegistry* pDirectory) 00107 : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( refObject.service(), pDirectory, "") 00108 { 00109 } 00110 00120 SmartDataPtr(SmartDataObjectPtr& refObject, const std::string& path) 00121 : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( refObject.service(), refObject.directory(), path) 00122 { 00123 } 00124 00128 SmartDataPtr(const SmartDataObjectPtr& copy) 00129 : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( copy ) 00130 { 00131 } 00132 00135 virtual ~SmartDataPtr() { 00136 } 00137 00139 template <class OTHER> 00140 SmartDataPtr& operator=( OTHER* pObj ) { 00141 this->m_pObject = dynamic_cast<TYPE*>(pObj); 00142 return *this; 00143 } 00144 00146 template <class OTHER> 00147 SmartDataPtr& operator=( const OTHER* pObj ) { 00148 this->m_pObject = dynamic_cast<TYPE*>(const_cast<OTHER*>(pObj)); 00149 return *this; 00150 } 00151 }; 00152 00153 #endif // GAUDIKERNEL_SMARTDATAPTR_H