The Gaudi Framework  v33r1 (b1225454)
SmartDataObjectPtr.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_SMARTDATAOBJECTPTR_H
12 #define GAUDIKERNEL_SMARTDATAOBJECTPTR_H 1
13 
14 // STL include files
15 #include <string>
16 
17 // Framework include files
18 #include "GaudiKernel/Kernel.h"
19 #include "GaudiKernel/StatusCode.h"
20 
21 // Forward declarations
22 class SmartDataObjectPtr;
23 class IDataProviderSvc;
24 class IRegistry;
25 class DataObject;
26 
43 public:
46  class ObjectLoader {
47  public:
48  static AccessFunction access();
49  };
50 
52  class ObjectFinder {
53  public:
54  static AccessFunction access();
55  };
56 
57 public:
65  : m_dataProvider( pService ), m_pRegistry( pDir ), m_path( std::move( path ) ), m_accessFunc( access ) {}
69  SmartDataObjectPtr( const SmartDataObjectPtr& ) = default;
70 
72  virtual ~SmartDataObjectPtr() = default;
73 
75  virtual SmartDataObjectPtr& operator=( const SmartDataObjectPtr& );
76 
78  operator IRegistry*() { return m_pRegistry; }
79 
81  const std::string& path() const { return m_path; }
82 
84  IRegistry* directory() { return m_pRegistry; }
85 
87  void setService( IDataProviderSvc* svc ) { m_dataProvider = svc; }
88 
90  IDataProviderSvc* service() { return m_dataProvider; }
91 
93  const StatusCode& getLastError() const { return m_status; }
94 
96  DataObject* accessData() { return m_accessFunc( this ); }
97 
99  static DataObject* retrieve( SmartDataObjectPtr* ptr ) { return ptr->retrieveObject(); }
100 
102  static DataObject* find( SmartDataObjectPtr* ptr ) { return ptr->findObject(); }
103 
105  static DataObject* update( SmartDataObjectPtr* ptr ) { return ptr->updateObject(); }
106 
112  DataObject* retrieveObject();
113 
119  DataObject* findObject();
120 
127  DataObject* updateObject();
128 
129 protected:
135  StatusCode find( IRegistry* pDirectory, std::string_view path, DataObject*& refpObject );
136 
142  StatusCode find( std::string_view fullPath, DataObject*& refpObject );
143 
149  StatusCode retrieve( IRegistry* pDirectory, std::string_view path, DataObject*& refpObject );
155  StatusCode retrieve( std::string_view fullPath, DataObject*& refpObject );
156 
161  StatusCode update( IRegistry* pDirectory );
166  StatusCode update( std::string_view fullPath );
167 
168 protected:
170  mutable IDataProviderSvc* m_dataProvider = nullptr;
172  mutable IRegistry* m_pRegistry = nullptr;
174  mutable StatusCode m_status = {StatusCode::SUCCESS, true};
179 };
180 #endif // GAUDIKERNEL_SMARTDATAOBJECTPTR_H
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
DataObject * retrieveObject()
Object retrieve method.
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
STL namespace.
Data provider interface definition.
SmartDataObjectPtr(AccessFunction access, IDataProviderSvc *pService, IRegistry *pDir, std::string path)
Standard constructor: Construct an SmartDataObjectPtr instance.
void setService(IDataProviderSvc *svc)
Assign data service.
IDataProviderSvc * service()
Retrieve data service.
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
STL class.
Helper class to configure smart pointer functionality.
const std::string & path() const
Path name.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
const StatusCode & getLastError() const
Access to potential errors during data accesses.
std::string m_path
Path to object.
DataObject * accessData()
Static Object retrieval method: must call specific function.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
AccessFunction m_accessFunc
Data access function.
A small class used to access easily (and efficiently) data items residing in data stores.
Helper class to configure smart pointer functionality.
DataObject * findObject()
Object find method.
IRegistry * directory()
Access to data directory.
DataObject *(*)(SmartDataObjectPtr *ptr) AccessFunction
#define GAUDI_API
Definition: Kernel.h:81
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
DataObject * updateObject()
Object update method.