The Gaudi Framework  master (37c0b60a)
SmartDataLocator.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 // SmartDataLocator.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_SMARTDATALOCATOR_H
23 #define GAUDIKERNEL_SMARTDATALOCATOR_H 1
24 
25 // Framework include files
27 
55 template <class TYPE>
56 class SmartDataLocator : public SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader> {
57 public:
66  SmartDataLocator( IDataProviderSvc* pService, const std::string& fullPath )
67  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, 0, fullPath ) {}
68 
77  SmartDataLocator( IDataProviderSvc* pService, IRegistry* pDirectory )
78  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, pDirectory, "" ) {}
79 
92  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( pService, 0, path ) {
93  if ( 0 != pObject ) { this->m_pDirectory = pObject->registry(); }
94  }
95 
105  SmartDataLocator( SmartDataObjectPtr& refObject, IRegistry* pDirectory )
106  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( refObject.service(), pDirectory, "" ) {}
107 
118  : SmartDataStorePtr<TYPE, SmartDataObjectPtr::ObjectLoader>( refObject.service(), refObject.directory(), path ) {}
119 
122  virtual ~SmartDataLocator() {}
123 
125  template <class OTHER>
126  SmartDataPtr<OTHER>& operator=( OTHER* pObj ) {
127  this->m_pObject = dynamic_cast<TYPE*>( pObj );
128  return *this;
129  }
130 
132  template <class OTHER>
133  SmartDataPtr<OTHER>& operator=( const OTHER* pObj ) {
134  this->m_pObject = dynamic_cast<TYPE*>( const_cast<OTHER*>( pObj ) );
135  return *this;
136  }
137 };
138 
139 #endif // GAUDIKERNEL_SMARTDATALOCATOR_H
SmartDataLocator::SmartDataLocator
SmartDataLocator(IDataProviderSvc *pService, DataObject *pObject, const std::string &path)
Standard constructor: Construct an SmartDataLocator instance which is able to connect to a DataObject...
Definition: SmartDataLocator.h:91
std::string
STL class.
IRegistry
Definition: IRegistry.h:32
SmartDataLocator::SmartDataLocator
SmartDataLocator(IDataProviderSvc *pService, const std::string &fullPath)
Standard constructor: Construct an SmartDataLocator instance which is able to connect to a DataObject...
Definition: SmartDataLocator.h:66
SmartDataObjectPtr::directory
IRegistry * directory()
Access to data directory.
Definition: SmartDataObjectPtr.h:84
SmartDataLocator::SmartDataLocator
SmartDataLocator(IDataProviderSvc *pService, IRegistry *pDirectory)
Standard constructor: Construct an SmartDataLocator instance which is able to connect to a DataObject...
Definition: SmartDataLocator.h:77
SmartDataLocator::SmartDataLocator
SmartDataLocator(SmartDataObjectPtr &refObject, const std::string &path)
Standard constructor: Construct an SmartDataLocator instance which is able to connect to a DataObject...
Definition: SmartDataLocator.h:117
SmartDataPtr.h
SmartDataObjectPtr
Definition: SmartDataObjectPtr.h:42
SmartDataLocator::SmartDataLocator
SmartDataLocator(SmartDataObjectPtr &refObject, IRegistry *pDirectory)
Standard constructor: Construct an SmartDataLocator instance which is able to connect to a DataObject...
Definition: SmartDataLocator.h:105
SmartDataStorePtr< TYPE, SmartDataObjectPtr::ObjectLoader >::m_pObject
TYPE * m_pObject
Pointer to data store object.
Definition: SmartDataStorePtr.h:128
SmartDataLocator
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataLocator.h:56
SmartDataObjectPtr::ObjectLoader
Helper class to configure smart pointer functionality.
Definition: SmartDataObjectPtr.h:46
SmartDataPtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataPtr.h:57
SmartDataLocator::operator=
SmartDataPtr< OTHER > & operator=(const OTHER *pObj)
Automatic conversion to data type.
Definition: SmartDataLocator.h:133
SmartDataLocator::operator=
SmartDataPtr< OTHER > & operator=(OTHER *pObj)
Automatic conversion to data type.
Definition: SmartDataLocator.h:126
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
IDataProviderSvc
Definition: IDataProviderSvc.h:53
SmartDataObjectPtr::path
const std::string & path() const
Path name.
Definition: SmartDataObjectPtr.h:81
SmartDataLocator::~SmartDataLocator
virtual ~SmartDataLocator()
Standard destructor.
Definition: SmartDataLocator.h:122
SmartDataObjectPtr::service
IDataProviderSvc * service()
Retrieve data service.
Definition: SmartDataObjectPtr.h:90
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:78