Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v28r2p1 (f1a77ff4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SmartDataPtr.h
Go to the documentation of this file.
1 // ====================================================================
2 // SmartDataPtr.h
3 // --------------------------------------------------------------------
4 //
5 // Package : GaudiKernel ( The LHCb Offline System)
6 //
7 // Description: Implementation of a smart pointer class to access
8 // easily (and efficiently) data stores.
9 //
10 // Author : M.Frank
11 // ====================================================================
12 #ifndef GAUDIKERNEL_SMARTDATAPTR_H
13 #define GAUDIKERNEL_SMARTDATAPTR_H 1
14 
15 // Framework include files
17 #include "GaudiKernel/DataObject.h"
18 
46 template<class TYPE> class SmartDataPtr : public SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader> {
47 public:
48 
50 #if !defined(__ICC) && !defined(__COVERITY__)
51  // icc and Coverity do not like this line, they fail with
52  // SmartDataPtr.h(147): internal error: assertion failed: add_symbol_to_overload_list:
53  // symbol not in symbol header list (shared/edgcpfe/symbol_tbl.c, line 4804)
55 #endif
56 
64  SmartDataPtr(IDataProviderSvc* pService, const std::string& fullPath)
65  : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,nullptr,fullPath)
66  {
67  }
68 
77  SmartDataPtr(IDataProviderSvc* pService, IRegistry* pDirectory)
78  : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,pDirectory,"")
79  {
80  }
81 
94  : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,nullptr,path)
95  {
96  if ( pObject ) this->m_pRegistry = pObject->registry();
97  }
98 
108  SmartDataPtr(SmartDataObjectPtr& refObject, IRegistry* pDirectory)
109  : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( refObject.service(), pDirectory, "")
110  {
111  }
112 
123  : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( refObject.service(), refObject.directory(), path)
124  {
125  }
126 
132  {
133  }
134 
137  virtual ~SmartDataPtr() = default;
138 
140  template <class OTHER>
141  SmartDataPtr& operator=( OTHER* pObj ) {
142  this->m_pObject = dynamic_cast<TYPE*>(pObj);
143  return *this;
144  }
145 
147  template <class OTHER>
148  SmartDataPtr& operator=( const OTHER* pObj ) {
149  this->m_pObject = dynamic_cast<TYPE*>(const_cast<OTHER*>(pObj));
150  return *this;
151  }
152 };
153 
154 #endif // GAUDIKERNEL_SMARTDATAPTR_H
SmartDataPtr(SmartDataObjectPtr &refObject, const std::string &path)
Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject ins...
Definition: SmartDataPtr.h:122
SmartDataPtr & operator=(const OTHER *pObj)
Automatic conversion to data type.
Definition: SmartDataPtr.h:148
Data provider interface definition.
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:74
IDataProviderSvc * service()
Retrieve data service.
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:130
SmartDataPtr(IDataProviderSvc *pService, const std::string &fullPath)
Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject ins...
Definition: SmartDataPtr.h:64
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
SmartDataPtr(IDataProviderSvc *pService, IRegistry *pDirectory)
Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject ins...
Definition: SmartDataPtr.h:77
SmartDataPtr & operator=(OTHER *pObj)
Automatic conversion to data type.
Definition: SmartDataPtr.h:141
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:108
A small class used to access easily (and efficiently) data items residing in data stores...
Definition: SmartDataPtr.h:46
IRegistry * directory()
Access to data directory.
SmartDataPtr(IDataProviderSvc *pService, DataObject *pObject, const std::string &path)
Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject ins...
Definition: SmartDataPtr.h:93
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:30