Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:02

0001 #ifndef FWCore_Framework_ESTransientHandle_h
0002 #define FWCore_Framework_ESTransientHandle_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Framework
0006 // Class  :     ESTransientHandle
0007 //
0008 /**\class ESTransientHandle ESTransientHandle.h FWCore/Framework/interface/ESTransientHandle.h
0009 
0010  Description: Provides transient access to data in an EventSetup Record
0011 
0012  Usage:
0013     This handle is used to setup a memory optimization.  Data obtained via this handle are allowed to be discarded before
0014 the end of the actual IOV for the data.  In this way the system can claim back some memory
0015 
0016     Only use this form of the EventSetup handle IF AND ONLY IF
0017  1) you do not plan on holding onto a pointer to the EventSetup data to which the handle refers
0018     (since the pointer may become invalid after returning from your function)
0019  2) you only access this EventSetup data once per IOV change of the Record [i.e. you do NOT read it every Event]
0020     (failure to do this will cause the EventSetup data to be created each access which can drastically slow the system)
0021 
0022  If you are unsure whether to use this handle or not then it is best not to and just use the regular ESHandle.
0023 
0024 */
0025 //
0026 // Author:      Chris Jones
0027 // Created:     Thu Nov 12 14:47:35 CST 2009
0028 //
0029 
0030 // system include files
0031 
0032 // user include files
0033 #include "FWCore/Framework/interface/ESHandle.h"
0034 
0035 // forward declarations
0036 namespace edm {
0037 
0038   class ESHandleExceptionFactory;
0039 
0040   template <typename T>
0041   class ESTransientHandle : public ESHandleBase {
0042   public:
0043     typedef T value_type;
0044 
0045     ESTransientHandle() : ESHandleBase() {}
0046     ESTransientHandle(T const* iData) : ESHandleBase(iData, 0) {}
0047     ESTransientHandle(T const* iData, edm::eventsetup::ComponentDescription const* desc) : ESHandleBase(iData, desc) {}
0048     ESTransientHandle(std::shared_ptr<ESHandleExceptionFactory>&&);
0049 
0050     // ---------- const member functions ---------------------
0051     T const* product() const { return static_cast<T const*>(productStorage()); }
0052     T const* operator->() const { return product(); }
0053     T const& operator*() const { return *product(); }
0054     // ---------- static member functions --------------------
0055     static constexpr bool transientAccessOnly = true;
0056 
0057     // ---------- member functions ---------------------------
0058 
0059   private:
0060   };
0061 
0062   template <class T>
0063   ESTransientHandle<T>::ESTransientHandle(std::shared_ptr<edm::ESHandleExceptionFactory>&& iWhyFailed)
0064       : ESHandleBase(std::move(iWhyFailed)) {}
0065 
0066 }  // namespace edm
0067 #endif