The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
SmartDataObjectPtr.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 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#pragma once
12
13#include <GaudiKernel/Kernel.h>
15#include <string>
16
19class IRegistry;
20class DataObject;
21
38public:
42 public:
43 static AccessFunction access();
44 };
45
48 public:
49 static AccessFunction access();
50 };
51
52public:
59 SmartDataObjectPtr( AccessFunction access, IDataProviderSvc* pService, IRegistry* pDir, std::string path )
60 : m_dataProvider( pService ), m_pRegistry( pDir ), m_path( std::move( path ) ), m_accessFunc( access ) {}
61
65
67 virtual ~SmartDataObjectPtr() = default;
68
70 virtual SmartDataObjectPtr& operator=( const SmartDataObjectPtr& ) = default;
71
73 operator IRegistry*() { return m_pRegistry; }
74
76 const std::string& path() const { return m_path; }
77
80
83
86
88 const StatusCode& getLastError() const { return m_status; }
89
91 DataObject* accessData() { return m_accessFunc( this ); }
92
94 static DataObject* retrieve( SmartDataObjectPtr* ptr ) { return ptr->retrieveObject(); }
95
97 static DataObject* find( SmartDataObjectPtr* ptr ) { return ptr->findObject(); }
98
100 static DataObject* update( SmartDataObjectPtr* ptr ) { return ptr->updateObject(); }
101
107 DataObject* retrieveObject();
108
114 DataObject* findObject();
115
122 DataObject* updateObject();
123
124protected:
130 StatusCode find( IRegistry* pDirectory, std::string_view path, DataObject*& refpObject );
131
137 StatusCode find( std::string_view fullPath, DataObject*& refpObject );
138
144 StatusCode retrieve( IRegistry* pDirectory, std::string_view path, DataObject*& refpObject );
150 StatusCode retrieve( std::string_view fullPath, DataObject*& refpObject );
151
156 StatusCode update( IRegistry* pDirectory );
161 StatusCode update( std::string_view fullPath );
162
163protected:
167 mutable IRegistry* m_pRegistry = nullptr;
171 std::string m_path;
174};
#define GAUDI_API
Definition Kernel.h:49
A DataObject is the base class of any identifiable object on any data store.
Definition DataObject.h:37
Data provider interface definition.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition IRegistry.h:29
Helper class to configure smart pointer functionality.
Helper class to configure smart pointer functionality.
A small class used to access easily (and efficiently) data items residing in data stores.
const std::string & path() const
Path name.
SmartDataObjectPtr(const SmartDataObjectPtr &)=default
Copy constructor: Construct an copy of a SmartDataStorePtr instance.
virtual SmartDataObjectPtr & operator=(const SmartDataObjectPtr &)=default
Assignment operator.
DataObject * findObject()
Object find method.
DataObject * retrieveObject()
Object retrieve method.
IDataProviderSvc * service()
Retrieve data service.
SmartDataObjectPtr(AccessFunction access, IDataProviderSvc *pService, IRegistry *pDir, std::string path)
Standard constructor: Construct an SmartDataObjectPtr instance.
DataObject * updateObject()
Object update method.
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
DataObject * accessData()
Static Object retrieval method: must call specific function.
AccessFunction m_accessFunc
Data access function.
const StatusCode & getLastError() const
Access to potential errors during data accesses.
DataObject *(*)(SmartDataObjectPtr *ptr) AccessFunction
IRegistry * directory()
Access to data directory.
std::string m_path
Path to object.
virtual ~SmartDataObjectPtr()=default
Standard Destructor.
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
void setService(IDataProviderSvc *svc)
Assign data service.
IDataProviderSvc * m_dataProvider
Pointer to contained object.
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
StatusCode m_status
Keep track of the last error.
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99
STL namespace.