The Gaudi Framework
master (9f3f8895)
Toggle main menu visibility
Loading...
Searching...
No Matches
SmartDataObjectPtr.cpp
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
#include <
GaudiKernel/DataObject.h
>
12
#include <
GaudiKernel/IDataProviderSvc.h
>
13
#include <
GaudiKernel/SmartDataObjectPtr.h
>
14
15
SmartDataObjectPtr::AccessFunction
SmartDataObjectPtr::ObjectLoader::access
() {
return
&
SmartDataObjectPtr::retrieve
; }
16
17
SmartDataObjectPtr::AccessFunction
SmartDataObjectPtr::ObjectFinder::access
() {
return
&
SmartDataObjectPtr::find
; }
18
20
StatusCode
SmartDataObjectPtr::retrieve
(
IRegistry
* pRegistry, std::string_view
path
,
DataObject
*& refpObject ) {
21
return
(
m_dataProvider
&& pRegistry ) ?
m_dataProvider
->retrieveObject( pRegistry,
path
, refpObject )
22
:
StatusCode::FAILURE
;
23
}
24
26
StatusCode
SmartDataObjectPtr::retrieve
( std::string_view fullPath,
DataObject
*& refpObject ) {
27
return
m_dataProvider
?
m_dataProvider
->retrieveObject( fullPath, refpObject ) :
StatusCode::FAILURE
;
28
}
29
31
StatusCode
SmartDataObjectPtr::find
(
IRegistry
* pDirectory, std::string_view
path
,
DataObject
*& refpObject ) {
32
return
(
m_dataProvider
&& pDirectory ) ?
m_dataProvider
->findObject( pDirectory,
path
, refpObject )
33
:
StatusCode::FAILURE
;
34
;
35
}
36
38
StatusCode
SmartDataObjectPtr::find
( std::string_view fullPath,
DataObject
*& refpObject ) {
39
return
m_dataProvider
?
m_dataProvider
->findObject( fullPath, refpObject ) :
StatusCode::FAILURE
;
40
}
41
43
StatusCode
SmartDataObjectPtr::update
(
IRegistry
* pRegistry ) {
44
return
(
m_dataProvider
&& pRegistry ) ?
m_dataProvider
->updateObject( pRegistry ) :
StatusCode::FAILURE
;
45
}
46
48
StatusCode
SmartDataObjectPtr::update
( std::string_view fullPath ) {
49
return
(
m_dataProvider
) ?
m_dataProvider
->updateObject( fullPath ) :
StatusCode::FAILURE
;
50
}
51
57
DataObject
*
SmartDataObjectPtr::retrieveObject
() {
58
DataObject
* pObj =
nullptr
;
59
m_status
= ( !
m_pRegistry
?
retrieve
(
m_path
, pObj ) :
retrieve
(
m_pRegistry
,
m_path
, pObj ) );
60
if
(
m_status
.isSuccess() ) {
61
m_pRegistry
= pObj->
registry
();
62
m_path
.clear();
63
}
64
return
pObj;
65
}
66
72
DataObject
*
SmartDataObjectPtr::findObject
() {
73
DataObject
* pObj =
nullptr
;
74
m_status
= (
m_pRegistry
?
find
(
m_pRegistry
,
m_path
, pObj ) :
find
(
m_path
, pObj ) );
75
if
(
m_status
.isSuccess() ) {
76
m_pRegistry
= pObj->
registry
();
77
m_path
.clear();
78
}
79
return
pObj;
80
}
81
87
DataObject
*
SmartDataObjectPtr::updateObject
() {
88
DataObject
* pObj =
accessData
();
// Have to load AND update if not present.
89
if
(
m_status
.isSuccess() ) {
90
m_status
= ( !
m_pRegistry
?
update
(
m_path
) :
update
(
m_pRegistry
) );
91
if
( !
m_status
.isSuccess() ) pObj =
nullptr
;
92
}
93
return
pObj;
94
}
95
108
bool
operator&&
(
SmartDataObjectPtr
& object_1,
SmartDataObjectPtr
& object_2 ) {
109
return
object_1.
accessData
() && object_2.
accessData
();
110
}
111
128
bool
operator||
(
SmartDataObjectPtr
& object_1,
SmartDataObjectPtr
& object_2 ) {
129
return
object_1.
accessData
() || object_2.
accessData
();
130
}
DataObject.h
IDataProviderSvc.h
SmartDataObjectPtr.h
operator&&
bool operator&&(SmartDataStorePtr< A, LDA > &object_1, SmartDataStorePtr< B, LDB > &object_2)
Helper to test Smart data objects efficiently This construct allows statements like: SmartDataPtr<MCV...
Definition
SmartDataStorePtr.h:129
operator||
bool operator||(SmartDataStorePtr< A, LDA > &object_1, SmartDataStorePtr< B, LDB > &object_2)
Helper to test Smart data objects efficiently This construct allows statements like: SmartDataPtr<MCV...
Definition
SmartDataStorePtr.h:193
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition
DataObject.h:37
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition
DataObject.h:79
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition
IRegistry.h:29
SmartDataObjectPtr::ObjectFinder::access
static AccessFunction access()
Definition
SmartDataObjectPtr.cpp:17
SmartDataObjectPtr::ObjectLoader::access
static AccessFunction access()
Definition
SmartDataObjectPtr.cpp:15
SmartDataObjectPtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition
SmartDataObjectPtr.h:37
SmartDataObjectPtr::path
const std::string & path() const
Path name.
Definition
SmartDataObjectPtr.h:76
SmartDataObjectPtr::findObject
DataObject * findObject()
Object find method.
Definition
SmartDataObjectPtr.cpp:72
SmartDataObjectPtr::retrieveObject
DataObject * retrieveObject()
Object retrieve method.
Definition
SmartDataObjectPtr.cpp:57
SmartDataObjectPtr::updateObject
DataObject * updateObject()
Object update method.
Definition
SmartDataObjectPtr.cpp:87
SmartDataObjectPtr::find
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
Definition
SmartDataObjectPtr.h:97
SmartDataObjectPtr::accessData
DataObject * accessData()
Static Object retrieval method: must call specific function.
Definition
SmartDataObjectPtr.h:91
SmartDataObjectPtr::AccessFunction
DataObject *(*)(SmartDataObjectPtr *ptr) AccessFunction
Definition
SmartDataObjectPtr.h:39
SmartDataObjectPtr::m_path
std::string m_path
Path to object.
Definition
SmartDataObjectPtr.h:171
SmartDataObjectPtr::retrieve
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
Definition
SmartDataObjectPtr.h:94
SmartDataObjectPtr::update
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
Definition
SmartDataObjectPtr.h:100
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition
SmartDataObjectPtr.h:165
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition
SmartDataObjectPtr.h:167
SmartDataObjectPtr::m_status
StatusCode m_status
Keep track of the last error.
Definition
SmartDataObjectPtr.h:169
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
GaudiKernel
src
Lib
SmartDataObjectPtr.cpp
Generated on
for The Gaudi Framework by
1.17.0