The Gaudi Framework  v40r0 (475e45c1)
SmartDataPtr.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/DataObject.h>
15 
43 template <class TYPE>
44 class SmartDataPtr : public SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader> {
45 public:
47 #if !defined( __ICC ) && !defined( __COVERITY__ )
48  // icc and Coverity do not like this line, they fail with
49  // SmartDataPtr.h(147): internal error: assertion failed: add_symbol_to_overload_list:
50  // symbol not in symbol header list (shared/edgcpfe/symbol_tbl.c, line 4804)
52 #endif
53 
61  SmartDataPtr( IDataProviderSvc* pService, std::string fullPath )
62  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, nullptr, std::move( fullPath ) ) {}
63 
72  SmartDataPtr( IDataProviderSvc* pService, IRegistry* pDirectory )
73  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, pDirectory, "" ) {}
74 
86  SmartDataPtr( IDataProviderSvc* pService, DataObject* pObject, std::string path )
87  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, nullptr, std::move( path ) ) {
88  if ( pObject ) this->m_pRegistry = pObject->registry();
89  }
90 
100  SmartDataPtr( SmartDataObjectPtr& refObject, IRegistry* pDirectory )
101  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( refObject.service(), pDirectory, "" ) {}
102 
112  SmartDataPtr( SmartDataObjectPtr& refObject, std::string path )
113  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( refObject.service(), refObject.directory(),
114  std::move( path ) ) {}
115 
120 
121  virtual ~SmartDataPtr() = default;
122 
124  template <class OTHER>
125  SmartDataPtr& operator=( OTHER* pObj ) {
126  this->m_pObject = dynamic_cast<TYPE*>( pObj );
127  return *this;
128  }
129 
131  template <class OTHER>
132  SmartDataPtr& operator=( const OTHER* pObj ) {
133  this->m_pObject = dynamic_cast<TYPE*>( const_cast<OTHER*>( pObj ) );
134  return *this;
135  }
136 };
SmartDataPtr::SmartDataPtr
SmartDataPtr(IDataProviderSvc *pService, IRegistry *pDirectory)
Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject ins...
Definition: SmartDataPtr.h:72
GaudiPartProp.decorators.std
std
Definition: decorators.py:32
SmartDataPtr::SmartDataPtr
SmartDataPtr(IDataProviderSvc *pService, DataObject *pObject, std::string path)
Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject ins...
Definition: SmartDataPtr.h:86
SmartDataPtr::SmartDataPtr
SmartDataPtr(IDataProviderSvc *pService, std::string fullPath)
Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject ins...
Definition: SmartDataPtr.h:61
IRegistry
Definition: IRegistry.h:29
SmartDataPtr::operator=
SmartDataPtr & operator=(OTHER *pObj)
Automatic conversion to data type.
Definition: SmartDataPtr.h:125
SmartDataObjectPtr::directory
IRegistry * directory()
Access to data directory.
Definition: SmartDataObjectPtr.h:79
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:167
SmartDataObjectPtr
Definition: SmartDataObjectPtr.h:37
GaudiPython.Bindings.nullptr
nullptr
Definition: Bindings.py:87
SmartDataPtr::operator=
SmartDataPtr & operator=(const OTHER *pObj)
Automatic conversion to data type.
Definition: SmartDataPtr.h:132
SmartDataStorePtr< TYPE, SmartDataObjectPtr::ObjectLoader >::m_pObject
TYPE * m_pObject
Pointer to data store object.
Definition: SmartDataStorePtr.h:115
SmartDataObjectPtr::ObjectLoader
Helper class to configure smart pointer functionality.
Definition: SmartDataObjectPtr.h:41
SmartDataPtr::SmartDataPtr
SmartDataPtr(SmartDataObjectPtr &refObject, std::string path)
Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject ins...
Definition: SmartDataPtr.h:112
SmartDataPtr::~SmartDataPtr
virtual ~SmartDataPtr()=default
DataObject.h
SmartDataPtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataPtr.h:44
SmartDataStorePtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataStorePtr.h:42
DataObject
Definition: DataObject.h:37
SmartDataPtr::SmartDataPtr
SmartDataPtr(const SmartDataObjectPtr &copy)
Copy constructor: Construct an copy of a SmartDataPtr instance.
Definition: SmartDataPtr.h:119
SmartDataStorePtr.h
IDataProviderSvc
Definition: IDataProviderSvc.h:48
SmartDataObjectPtr::path
const std::string & path() const
Path name.
Definition: SmartDataObjectPtr.h:76
SmartDataPtr::SmartDataPtr
SmartDataPtr(SmartDataObjectPtr &refObject, IRegistry *pDirectory)
Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject ins...
Definition: SmartDataPtr.h:100
SmartDataObjectPtr::service
IDataProviderSvc * service()
Retrieve data service.
Definition: SmartDataObjectPtr.h:85
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:79