The Gaudi Framework  master (37c0b60a)
SmartDataPtr.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 // SmartDataPtr.h
13 // --------------------------------------------------------------------
14 //
15 // Package : GaudiKernel ( The LHCb Offline System)
16 //
17 // Description: Implementation of a smart pointer class to access
18 // easily (and efficiently) data stores.
19 //
20 // Author : M.Frank
21 // ====================================================================
22 #ifndef GAUDIKERNEL_SMARTDATAPTR_H
23 #define GAUDIKERNEL_SMARTDATAPTR_H 1
24 
25 // Framework include files
26 #include <GaudiKernel/DataObject.h>
28 
56 template <class TYPE>
57 class SmartDataPtr : public SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader> {
58 public:
60 #if !defined( __ICC ) && !defined( __COVERITY__ )
61  // icc and Coverity do not like this line, they fail with
62  // SmartDataPtr.h(147): internal error: assertion failed: add_symbol_to_overload_list:
63  // symbol not in symbol header list (shared/edgcpfe/symbol_tbl.c, line 4804)
65 #endif
66 
74  SmartDataPtr( IDataProviderSvc* pService, std::string fullPath )
75  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, nullptr, std::move( fullPath ) ) {}
76 
85  SmartDataPtr( IDataProviderSvc* pService, IRegistry* pDirectory )
86  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, pDirectory, "" ) {}
87 
100  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, nullptr, std::move( path ) ) {
101  if ( pObject ) this->m_pRegistry = pObject->registry();
102  }
103 
113  SmartDataPtr( SmartDataObjectPtr& refObject, IRegistry* pDirectory )
114  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( refObject.service(), pDirectory, "" ) {}
115 
126  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( refObject.service(), refObject.directory(),
127  std::move( path ) ) {}
128 
133 
136  virtual ~SmartDataPtr() = default;
137 
139  template <class OTHER>
140  SmartDataPtr& operator=( OTHER* pObj ) {
141  this->m_pObject = dynamic_cast<TYPE*>( pObj );
142  return *this;
143  }
144 
146  template <class OTHER>
147  SmartDataPtr& operator=( const OTHER* pObj ) {
148  this->m_pObject = dynamic_cast<TYPE*>( const_cast<OTHER*>( pObj ) );
149  return *this;
150  }
151 };
152 
153 #endif // GAUDIKERNEL_SMARTDATAPTR_H
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:85
std::string
STL class.
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:99
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:74
IRegistry
Definition: IRegistry.h:32
SmartDataPtr::operator=
SmartDataPtr & operator=(OTHER *pObj)
Automatic conversion to data type.
Definition: SmartDataPtr.h:140
SmartDataObjectPtr::directory
IRegistry * directory()
Access to data directory.
Definition: SmartDataObjectPtr.h:84
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:172
SmartDataObjectPtr
Definition: SmartDataObjectPtr.h:42
GaudiPython.Bindings.nullptr
nullptr
Definition: Bindings.py:87
SmartDataPtr::operator=
SmartDataPtr & operator=(const OTHER *pObj)
Automatic conversion to data type.
Definition: SmartDataPtr.h:147
SmartDataStorePtr< TYPE, SmartDataObjectPtr::ObjectLoader >::m_pObject
TYPE * m_pObject
Pointer to data store object.
Definition: SmartDataStorePtr.h:128
SmartDataObjectPtr::ObjectLoader
Helper class to configure smart pointer functionality.
Definition: SmartDataObjectPtr.h:46
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:125
SmartDataPtr::~SmartDataPtr
virtual ~SmartDataPtr()=default
Standard destructor.
DataObject.h
SmartDataPtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataPtr.h:57
std
STL namespace.
SmartDataStorePtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataStorePtr.h:55
DataObject
Definition: DataObject.h:36
SmartDataPtr::SmartDataPtr
SmartDataPtr(const SmartDataObjectPtr &copy)
Copy constructor: Construct an copy of a SmartDataPtr instance.
Definition: SmartDataPtr.h:132
SmartDataStorePtr.h
IDataProviderSvc
Definition: IDataProviderSvc.h:53
SmartDataObjectPtr::path
const std::string & path() const
Path name.
Definition: SmartDataObjectPtr.h:81
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:113
SmartDataObjectPtr::service
IDataProviderSvc * service()
Retrieve data service.
Definition: SmartDataObjectPtr.h:90
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:78