| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

# SmartDataPtr.h

Go to the documentation of this file.

    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 #if !defined(__ICC) && !defined(__COVERITY__)
    00051   // icc and Coverity do not like this line, they fail with
    00052   // SmartDataPtr.h(147): internal error: assertion failed: add_symbol_to_overload_list:
    00053   //   symbol not in symbol header list (shared/edgcpfe/symbol_tbl.c, line 4804)
    00054   using SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>::operator=;
    00055 #endif
    00056
    00064   SmartDataPtr(IDataProviderSvc* pService, const std::string& fullPath)
    00065     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,0,fullPath)
    00066   {
    00067   }
    00068
    00077   SmartDataPtr(IDataProviderSvc* pService, IRegistry* pDirectory)
    00078     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,pDirectory,"")
    00079   {
    00080   }
    00081
    00093   SmartDataPtr(IDataProviderSvc* pService, DataObject* pObject, const std::string& path)
    00094     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,0,path)
    00095   {
    00096     if ( 0 != pObject )   {
    00097       this->m_pRegistry = pObject->registry();
    00098     }
    00099   }
    00100
    00110   SmartDataPtr(SmartDataObjectPtr& refObject, IRegistry* pDirectory)
    00111     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( refObject.service(), pDirectory, "")
    00112   {
    00113   }
    00114
    00124   SmartDataPtr(SmartDataObjectPtr& refObject, const std::string& path)
    00125     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( refObject.service(), refObject.directory(), path)
    00126   {
    00127   }
    00128
    00132   SmartDataPtr(const SmartDataObjectPtr& copy)
    00133     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( copy )
    00134   {
    00135   }
    00136
    00139   virtual ~SmartDataPtr()   {
    00140   }
    00141
    00143   template <class OTHER>
    00144   SmartDataPtr& operator=( OTHER* pObj )    {
    00145     this->m_pObject = dynamic_cast<TYPE*>(pObj);
    00146     return *this;
    00147   }
    00148
    00150   template <class OTHER>
    00151   SmartDataPtr& operator=( const OTHER* pObj )    {
    00152     this->m_pObject = dynamic_cast<TYPE*>(const_cast<OTHER*>(pObj));
    00153     return *this;
    00154   }
    00155 };
    00156
    00157 #endif // GAUDIKERNEL_SMARTDATAPTR_H

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines