The Gaudi Framework  v33r1 (b1225454)
SmartDataPtr.h
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 // 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
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:82
STL namespace.
SmartDataPtr & operator=(const OTHER *pObj)
Automatic conversion to data type.
Definition: SmartDataPtr.h:147
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
Data provider interface definition.
IDataProviderSvc * service()
Retrieve data service.
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
STL class.
virtual ~SmartDataPtr()=default
Standard destructor.
Helper class to configure smart pointer functionality.
const std::string & path() const
Path name.
SmartDataPtr(const SmartDataObjectPtr &copy)
Copy constructor: Construct an copy of a SmartDataPtr instance.
Definition: SmartDataPtr.h:132
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
SmartDataPtr(IDataProviderSvc *pService, IRegistry *pDirectory)
Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject ins...
Definition: SmartDataPtr.h:85
SmartDataPtr & operator=(OTHER *pObj)
Automatic conversion to data type.
Definition: SmartDataPtr.h:140
A small class used to access easily (and efficiently) data items residing in data stores.
A small class used to access easily (and efficiently) data items residing in data stores.
SmartDataPtr(SmartDataObjectPtr &refObject, IRegistry *pDirectory)
Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject ins...
Definition: SmartDataPtr.h:113
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataPtr.h:57
IRegistry * directory()
Access to data directory.
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
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