The Gaudi Framework  master (82fdf313)
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\***********************************************************************************/
14
16
18
20StatusCode SmartDataObjectPtr::retrieve( IRegistry* pRegistry, std::string_view path, DataObject*& refpObject ) {
21 return ( m_dataProvider && pRegistry ) ? m_dataProvider->retrieveObject( pRegistry, path, refpObject )
23}
24
26StatusCode SmartDataObjectPtr::retrieve( std::string_view fullPath, DataObject*& refpObject ) {
27 return m_dataProvider ? m_dataProvider->retrieveObject( fullPath, refpObject ) : StatusCode::FAILURE;
28}
29
31StatusCode SmartDataObjectPtr::find( IRegistry* pDirectory, std::string_view path, DataObject*& refpObject ) {
32 return ( m_dataProvider && pDirectory ) ? m_dataProvider->findObject( pDirectory, path, refpObject )
34 ;
35}
36
38StatusCode SmartDataObjectPtr::find( std::string_view fullPath, DataObject*& refpObject ) {
39 return m_dataProvider ? m_dataProvider->findObject( fullPath, refpObject ) : StatusCode::FAILURE;
40}
41
44 return ( m_dataProvider && pRegistry ) ? m_dataProvider->updateObject( pRegistry ) : StatusCode::FAILURE;
45}
46
48StatusCode SmartDataObjectPtr::update( std::string_view fullPath ) {
49 return ( m_dataProvider ) ? m_dataProvider->updateObject( fullPath ) : StatusCode::FAILURE;
50}
51
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
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
88 DataObject* pObj = accessData(); // Have to load AND update if not present.
89 if ( m_status.isSuccess() ) {
91 if ( !m_status.isSuccess() ) pObj = nullptr;
92 }
93 return pObj;
94}
95
109 return object_1.accessData() && object_2.accessData();
110}
111
129 return object_1.accessData() || object_2.accessData();
130}
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...
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...
A DataObject is the base class of any identifiable object on any data store.
Definition DataObject.h:37
IRegistry * registry() const
Get pointer to Registry.
Definition DataObject.h:79
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition IRegistry.h:29
A small class used to access easily (and efficiently) data items residing in data stores.
const std::string & path() const
Path name.
DataObject * findObject()
Object find method.
DataObject * retrieveObject()
Object retrieve method.
DataObject * updateObject()
Object update method.
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
DataObject * accessData()
Static Object retrieval method: must call specific function.
DataObject *(*)(SmartDataObjectPtr *ptr) AccessFunction
std::string m_path
Path to object.
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
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 FAILURE
Definition StatusCode.h:100