| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# SmartDataObjectPtr.h

Go to the documentation of this file.

    00001 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/GaudiKernel/SmartDataObjectPtr.h,v 1.7 2007/11/21 09:29:31 marcocle Exp $
    00002 #ifndef GAUDIKERNEL_SMARTDATAOBJECTPTR_H
    00003 #define GAUDIKERNEL_SMARTDATAOBJECTPTR_H 1
    00004
    00005 // STL include files
    00006 #include <string>
    00007
    00008 // Framework include files
    00009 #include "GaudiKernel/Kernel.h"
    00010 #include "GaudiKernel/StatusCode.h"
    00011
    00012 // Forward declarations
    00013 class SmartDataObjectPtr;
    00014 class IDataProviderSvc;
    00015 class IRegistry;
    00016 class DataObject;
    00017
    00033 class SmartDataObjectPtr    {
    00034 public:
    00035   typedef DataObject* (* AccessFunction) (SmartDataObjectPtr* ptr);
    00037   class ObjectLoader    {
    00038   public:
    00039     static AccessFunction access();
    00040   };
    00041
    00043   class ObjectFinder    {
    00044   public:
    00045     static AccessFunction access();
    00046   };
    00047
    00048 public:
    00055   SmartDataObjectPtr(AccessFunction access, IDataProviderSvc* pService, IRegistry* pDir, const std::string& path)
    00056     : m_dataProvider(pService),
    00057       m_pRegistry(pDir),
    00058       m_status(StatusCode::SUCCESS,true),
    00059       m_path(path),
    00060       m_accessFunc(access)
    00061   {
    00062   }
    00066   SmartDataObjectPtr(const SmartDataObjectPtr& copy)
    00067     : m_dataProvider(copy.m_dataProvider),
    00068       m_pRegistry(copy.m_pRegistry),
    00069       m_status(copy.m_status),
    00070       m_path(copy.m_path),
    00071       m_accessFunc(copy.m_accessFunc)
    00072   {
    00073   }
    00075   virtual ~SmartDataObjectPtr()  {
    00076   }
    00078   virtual SmartDataObjectPtr& operator=(const SmartDataObjectPtr& copy);
    00079
    00081   operator IRegistry*()    {
    00082     return m_pRegistry;
    00083   }
    00084
    00086   const std::string& path()   const   {
    00087     return m_path;
    00088   }
    00089
    00091   IRegistry* directory()    {
    00092     return m_pRegistry;
    00093   }
    00094
    00096   void setService( IDataProviderSvc* svc )    {
    00097     m_dataProvider = svc;
    00098   }
    00099
    00101   IDataProviderSvc* service()    {
    00102     return m_dataProvider;
    00103   }
    00104
    00106   StatusCode getLastError()   const   {
    00107     return m_status;
    00108   }
    00109
    00111   DataObject* accessData()    {
    00112     return m_accessFunc(this);
    00113   }
    00114
    00116   static DataObject* retrieve(SmartDataObjectPtr* ptr)   {
    00117     return ptr->retrieveObject();
    00118   }
    00119
    00121   static DataObject* find(SmartDataObjectPtr* ptr)   {
    00122     return ptr->findObject();
    00123   }
    00124
    00126   static DataObject* update(SmartDataObjectPtr* ptr)   {
    00127     return ptr->updateObject();
    00128   }
    00129
    00135   DataObject* retrieveObject();
    00136
    00142   DataObject* findObject();
    00143
    00150   DataObject* updateObject();
    00151
    00152 protected:
    00153
    00159   StatusCode find(IRegistry* pDirectory, const std::string& path, DataObject*& refpObject);
    00160
    00166   StatusCode find(const std::string& fullPath, DataObject*& refpObject);
    00167
    00173   StatusCode retrieve(IRegistry* pDirectory, const std::string& path, DataObject*& refpObject);
    00179   StatusCode retrieve(const std::string& fullPath, DataObject*& refpObject);
    00180
    00185   StatusCode update(IRegistry* pDirectory);
    00190   StatusCode update(const std::string& fullPath);
    00191
    00192 protected:
    00194   mutable IDataProviderSvc* m_dataProvider;
    00196   mutable IRegistry*        m_pRegistry;
    00198   mutable StatusCode        m_status;
    00200   std::string               m_path;
    00202   AccessFunction            m_accessFunc;
    00203
    00204 };
    00205 #endif // GAUDIKERNEL_SMARTDATAOBJECTPTR_H