| # Gaudi Framework, version v21r9 |

Home |  | Generated: 3 May 2010

# SmartDataLocator.h

Go to the documentation of this file.

    00001 //      ====================================================================
    00002 //      SmartDataLocator.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_SMARTDATALOCATOR_H
    00013 #define GAUDIKERNEL_SMARTDATALOCATOR_H 1
    00014
    00015 // Framework include files
    00016 #include "GaudiKernel/SmartDataPtr.h"
    00017
    00045 template<class TYPE> class SmartDataLocator : public SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>    {
    00046 public:
    00055   SmartDataLocator(IDataProviderSvc* pService, const std::string& fullPath)
    00056     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,0,fullPath)
    00057   {
    00058   }
    00059
    00068   SmartDataLocator(IDataProviderSvc* pService, IRegistry* pDirectory)
    00069     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,pDirectory,"")
    00070   {
    00071   }
    00072
    00084   SmartDataLocator(IDataProviderSvc* pService, DataObject* pObject, const std::string& path)
    00085     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,0,path)
    00086   {
    00087     if ( 0 != pObject )   {
    00088       this->m_pDirectory = pObject->registry();
    00089     }
    00090   }
    00091
    00101   SmartDataLocator(SmartDataObjectPtr& refObject, IRegistry* pDirectory)
    00102     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( refObject.service(), pDirectory, "")
    00103   {
    00104   }
    00105
    00115   SmartDataLocator(SmartDataObjectPtr& refObject, const std::string& path)
    00116     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( refObject.service(), refObject.directory(), path)
    00117   {
    00118   }
    00119
    00122   virtual ~SmartDataLocator()   {
    00123   }
    00124
    00126   template <class OTHER>
    00127   SmartDataPtr<OTHER>& operator=( OTHER* pObj )    {
    00128     this->m_pObject = dynamic_cast<TYPE*>(pObj);
    00129     return *this;
    00130   }
    00131
    00133   template <class OTHER>
    00134   SmartDataPtr<OTHER>& operator=( const OTHER* pObj )    {
    00135     this->m_pObject = dynamic_cast<TYPE*>(const_cast<OTHER*>(pObj));
    00136     return *this;
    00137   }
    00138 };
    00139
    00140 #endif // GAUDIKERNEL_SMARTDATALOCATOR_H