SmartDataObjectPtr.h
Go to the documentation of this file.
1 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/GaudiKernel/SmartDataObjectPtr.h,v 1.7 2007/11/21 09:29:31 marcocle Exp $
2 #ifndef GAUDIKERNEL_SMARTDATAOBJECTPTR_H
3 #define GAUDIKERNEL_SMARTDATAOBJECTPTR_H 1
4 
5 // STL include files
6 #include <string>
7 
8 // Framework include files
9 #include "GaudiKernel/Kernel.h"
10 #include "GaudiKernel/StatusCode.h"
11 
12 // Forward declarations
13 class SmartDataObjectPtr;
14 class IDataProviderSvc;
15 class IRegistry;
16 class DataObject;
17 
34 public:
35  typedef DataObject* (* AccessFunction) (SmartDataObjectPtr* ptr);
37  class ObjectLoader {
38  public:
39  static AccessFunction access();
40  };
41 
43  class ObjectFinder {
44  public:
45  static AccessFunction access();
46  };
47 
48 public:
55  SmartDataObjectPtr(AccessFunction access, IDataProviderSvc* pService, IRegistry* pDir, const std::string& path)
56  : m_dataProvider(pService),
57  m_pRegistry(pDir),
58  m_status(StatusCode::SUCCESS,true),
59  m_path(path),
60  m_accessFunc(access)
61  {
62  }
67  : m_dataProvider(copy.m_dataProvider),
68  m_pRegistry(copy.m_pRegistry),
69  m_status(copy.m_status),
70  m_path(copy.m_path),
71  m_accessFunc(copy.m_accessFunc)
72  {
73  }
75  virtual ~SmartDataObjectPtr() {
76  }
78  virtual SmartDataObjectPtr& operator=(const SmartDataObjectPtr& copy);
79 
81  operator IRegistry*() {
82  return m_pRegistry;
83  }
84 
86  const std::string& path() const {
87  return m_path;
88  }
89 
91  IRegistry* directory() {
92  return m_pRegistry;
93  }
94 
96  void setService( IDataProviderSvc* svc ) {
97  m_dataProvider = svc;
98  }
99 
101  IDataProviderSvc* service() {
102  return m_dataProvider;
103  }
104 
106  StatusCode getLastError() const {
107  return m_status;
108  }
109 
111  DataObject* accessData() {
112  return m_accessFunc(this);
113  }
114 
116  static DataObject* retrieve(SmartDataObjectPtr* ptr) {
117  return ptr->retrieveObject();
118  }
119 
121  static DataObject* find(SmartDataObjectPtr* ptr) {
122  return ptr->findObject();
123  }
124 
126  static DataObject* update(SmartDataObjectPtr* ptr) {
127  return ptr->updateObject();
128  }
129 
135  DataObject* retrieveObject();
136 
142  DataObject* findObject();
143 
150  DataObject* updateObject();
151 
152 protected:
153 
159  StatusCode find(IRegistry* pDirectory, const std::string& path, DataObject*& refpObject);
160 
166  StatusCode find(const std::string& fullPath, DataObject*& refpObject);
167 
173  StatusCode retrieve(IRegistry* pDirectory, const std::string& path, DataObject*& refpObject);
179  StatusCode retrieve(const std::string& fullPath, DataObject*& refpObject);
180 
185  StatusCode update(IRegistry* pDirectory);
190  StatusCode update(const std::string& fullPath);
191 
192 protected:
194  mutable IDataProviderSvc* m_dataProvider;
196  mutable IRegistry* m_pRegistry;
198  mutable StatusCode m_status;
200  std::string m_path;
202  AccessFunction m_accessFunc;
203 
204 };
205 #endif // GAUDIKERNEL_SMARTDATAOBJECTPTR_H
#define GAUDI_API
Definition: Kernel.h:108
DataObject * retrieveObject()
Object retrieve method.
GAUDI_API unsigned long getLastError()
Get last system known error.
Definition: System.cpp:244
list path
Definition: __init__.py:15
Data provider interface definition.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
bool access(const ContainedObject *from, ContainedObject **to)
Definition: KeyedObject.cpp:66
A small class used to access easily (and efficiently) data items residing in data stores...
def update
Definition: install.py:213
DataObject * findObject()
Object find method.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
DataObject * updateObject()
Object update method.