The Gaudi Framework  v33r1 (b1225454)
SmartDataObjectPtr.cpp
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 // ====================================================================
12 // SmartDataObjectPtr.cpp
13 // --------------------------------------------------------------------
14 //
15 // Package :
16 //
17 // Author : Markus Frank
18 //
19 // ====================================================================
20 #define GAUDIKERNEL_SMARTDATAOBJECTPTR_CPP 1
21 
22 // Framework include files
24 #include "GaudiKernel/DataObject.h"
26 
28 
30 
33  m_path = copy.m_path;
34  m_pRegistry = copy.m_pRegistry;
35  m_dataProvider = copy.m_dataProvider;
36  return *this;
37 }
38 
40 StatusCode SmartDataObjectPtr::retrieve( IRegistry* pRegistry, std::string_view path, DataObject*& refpObject ) {
41  return ( m_dataProvider && pRegistry ) ? m_dataProvider->retrieveObject( pRegistry, path, refpObject )
43 }
44 
46 StatusCode SmartDataObjectPtr::retrieve( std::string_view fullPath, DataObject*& refpObject ) {
47  return m_dataProvider ? m_dataProvider->retrieveObject( fullPath, refpObject ) : StatusCode::FAILURE;
48 }
49 
51 StatusCode SmartDataObjectPtr::find( IRegistry* pDirectory, std::string_view path, DataObject*& refpObject ) {
52  return ( m_dataProvider && pDirectory ) ? m_dataProvider->findObject( pDirectory, path, refpObject )
54  ;
55 }
56 
58 StatusCode SmartDataObjectPtr::find( std::string_view fullPath, DataObject*& refpObject ) {
59  return m_dataProvider ? m_dataProvider->findObject( fullPath, refpObject ) : StatusCode::FAILURE;
60 }
61 
64  return ( m_dataProvider && pRegistry ) ? m_dataProvider->updateObject( pRegistry ) : StatusCode::FAILURE;
65 }
66 
68 StatusCode SmartDataObjectPtr::update( std::string_view fullPath ) {
70 }
71 
78  DataObject* pObj = nullptr;
79  m_status = ( !m_pRegistry ? retrieve( m_path, pObj ) : retrieve( m_pRegistry, m_path, pObj ) );
80  if ( m_status.isSuccess() ) {
81  m_pRegistry = pObj->registry();
82  m_path.clear();
83  }
84  return pObj;
85 }
86 
93  DataObject* pObj = nullptr;
94  m_status = ( m_pRegistry ? find( m_pRegistry, m_path, pObj ) : find( m_path, pObj ) );
95  if ( m_status.isSuccess() ) {
96  m_pRegistry = pObj->registry();
97  m_path.clear();
98  }
99  return pObj;
100 }
101 
108  DataObject* pObj = accessData(); // Have to load AND update if not present.
109  if ( m_status.isSuccess() ) {
111  if ( !m_status.isSuccess() ) pObj = nullptr;
112  }
113  return pObj;
114 }
115 
128 bool operator&&( SmartDataObjectPtr& object_1, SmartDataObjectPtr& object_2 ) {
129  return object_1.accessData() && object_2.accessData();
130 }
131 
148 bool operator||( SmartDataObjectPtr& object_1, SmartDataObjectPtr& object_2 ) {
149  return object_1.accessData() || object_2.accessData();
150 }
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
bool operator||(SmartDataObjectPtr &object_1, SmartDataObjectPtr &object_2)
Helper to test Smart data objects efficiently This construct allows statements like: SmartEvtDataPtr<...
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:82
bool operator &&(SmartDataObjectPtr &object_1, SmartDataObjectPtr &object_2)
Helper to test Smart data objects efficiently This construct allows statements like: SmartEvtDataPtr<...
DataObject * retrieveObject()
Object retrieve method.
virtual StatusCode findObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Find object identified by its directory entry.
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
const std::string & path() const
Path name.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
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
T clear(T... args)
bool isSuccess() const
Definition: StatusCode.h:365
virtual SmartDataObjectPtr & operator=(const SmartDataObjectPtr &)
Assignment operator.
StatusCode m_status
Keep track of the last error.
A small class used to access easily (and efficiently) data items residing in data stores.
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
DataObject * findObject()
Object find method.
IDataProviderSvc * m_dataProvider
Pointer to contained object.
constexpr static const auto FAILURE
Definition: StatusCode.h:101
DataObject *(*)(SmartDataObjectPtr *ptr) AccessFunction
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
DataObject * updateObject()
Object update method.