![]() |
|
|||
File indexing completed on 2025-03-13 09:10:03
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 // ==================================================================== 0012 // SmartDataPtr.h 0013 // -------------------------------------------------------------------- 0014 // 0015 // Package : GaudiKernel ( The LHCb Offline System) 0016 // 0017 // Description: Implementation of a smart pointer class to access 0018 // easily (and efficiently) data stores. 0019 // 0020 // Author : M.Frank 0021 // ==================================================================== 0022 #ifndef GAUDIKERNEL_SMARTDATAPTR_H 0023 #define GAUDIKERNEL_SMARTDATAPTR_H 1 0024 0025 // Framework include files 0026 #include "GaudiKernel/DataObject.h" 0027 #include "GaudiKernel/SmartDataStorePtr.h" 0028 0029 /** A small class used to access easily (and efficiently) data items 0030 residing in data stores. 0031 0032 The class constructors take several arguments neccessary to be passed 0033 tyo the data services in order to automatically load objects in case 0034 they are not yet loaded. This is achieved through a smart pointer 0035 mechanism i.e. by overloading the operator->() at dereferencing time 0036 the the object will be requested from the store. 0037 0038 The SmartDataPtr is meant to be "short living". It only makes 0039 sense to keep an object instance within e.g. the scope of one method. 0040 "long living" instances do not make sense and in the contrary 0041 would be harmful, because the information passed during construction 0042 to would be invalid and returned object pointers would actually 0043 point to hyperspace. 0044 0045 The intrinsic functionality, wether the object will be retrieved or 0046 loaded from the data store is defined by the LOADER::. 0047 0048 0049 Base Class: 0050 SmartDataStorePtr 0051 0052 @author M.Frank 0053 @version 1.0 0054 */ 0055 0056 template <class TYPE> 0057 class SmartDataPtr : public SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader> { 0058 public: 0059 /// unhides assignment operator of base class 0060 #if !defined( __ICC ) && !defined( __COVERITY__ ) 0061 // icc and Coverity do not like this line, they fail with 0062 // SmartDataPtr.h(147): internal error: assertion failed: add_symbol_to_overload_list: 0063 // symbol not in symbol header list (shared/edgcpfe/symbol_tbl.c, line 4804) 0064 using SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>::operator=; 0065 #endif 0066 /** Standard constructor: Construct an SmartDataPtr instance which is 0067 able to connect to a DataObject instance 0068 which is identified by its parent object and 0069 the path relative to the parent. 0070 @param pService Pointer to the data service interface which 0071 should be used to load the object. 0072 @param fullPath Full path leading to the data object. 0073 */ 0074 SmartDataPtr( IDataProviderSvc* pService, std::string fullPath ) 0075 : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, nullptr, std::move( fullPath ) ) {} 0076 0077 /** Standard constructor: Construct an SmartDataPtr instance which is 0078 able to connect to a DataObject instance 0079 which is identified by its directory entry. 0080 *** FASTEST ACCESS TO THE DATA STORE *** 0081 @param pService Pointer to the data service interface which 0082 should be used to load the object. 0083 @param pDirectory Pointer to the data directory entry. 0084 */ 0085 SmartDataPtr( IDataProviderSvc* pService, IRegistry* pDirectory ) 0086 : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, pDirectory, "" ) {} 0087 0088 /** Standard constructor: Construct an SmartDataPtr instance which is 0089 able to connect to a DataObject instance 0090 which is identified by its parent object and 0091 the path relative to the parent. 0092 The path is meant to address only ONE level, 0093 multiple path layers are invalid. 0094 @param pService Pointer to the data service interface which 0095 should be used to load the object. 0096 @param pObject Pointer to the parent object. 0097 @param path Path to the data object relative to the parent object. 0098 */ 0099 SmartDataPtr( IDataProviderSvc* pService, DataObject* pObject, std::string path ) 0100 : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, nullptr, std::move( path ) ) { 0101 if ( pObject ) this->m_pRegistry = pObject->registry(); 0102 } 0103 0104 /** Standard constructor: Construct an SmartDataPtr instance which is 0105 able to connect to a DataObject instance 0106 which is identified by its parent object and 0107 the path relative to the parent. 0108 The path is meant to address only ONE level, 0109 multiple path layers are invalid. 0110 @param refObject Smart Pointer to the parent object. 0111 @param pDirectory Pointer to the data directory entry. 0112 */ 0113 SmartDataPtr( SmartDataObjectPtr& refObject, IRegistry* pDirectory ) 0114 : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( refObject.service(), pDirectory, "" ) {} 0115 0116 /** Standard constructor: Construct an SmartDataPtr instance which is 0117 able to connect to a DataObject instance 0118 which is identified by its parent object and 0119 the path relative to the parent. 0120 The path is meant to address only ONE level, 0121 multiple path layers are invalid. 0122 @param refObject Smart Pointer to the parent object. 0123 @param path Path to the data object relative to the parent object. 0124 */ 0125 SmartDataPtr( SmartDataObjectPtr& refObject, std::string path ) 0126 : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( refObject.service(), refObject.directory(), 0127 std::move( path ) ) {} 0128 0129 /** Copy constructor: Construct an copy of a SmartDataPtr instance. 0130 @param copy Copy Smart Pointer to object. 0131 */ 0132 SmartDataPtr( const SmartDataObjectPtr& copy ) : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( copy ) {} 0133 0134 /** Standard destructor 0135 */ 0136 virtual ~SmartDataPtr() = default; 0137 0138 /// Automatic conversion to data type 0139 template <class OTHER> 0140 SmartDataPtr& operator=( OTHER* pObj ) { 0141 this->m_pObject = dynamic_cast<TYPE*>( pObj ); 0142 return *this; 0143 } 0144 0145 /// Automatic conversion to data type 0146 template <class OTHER> 0147 SmartDataPtr& operator=( const OTHER* pObj ) { 0148 this->m_pObject = dynamic_cast<TYPE*>( const_cast<OTHER*>( pObj ) ); 0149 return *this; 0150 } 0151 }; 0152 0153 #endif // GAUDIKERNEL_SMARTDATAPTR_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |