CMS 3D CMS Logo

ESValidHandle.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ESValidHandle_h
2 #define FWCore_Framework_ESValidHandle_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : ESValidHandle
7 //
16 //
17 // Author: Chris Jones
18 // Created: Tue Feb 5 14:47:35 EST 2019
19 //
20 
21 // system include files
22 
23 // user include files
25 
26 #include <exception>
27 #include <memory>
28 #include <utility>
29 
30 namespace edm {
31 
32  namespace esvhhelper {
33  void throwIfNotValid(const void*) noexcept(false);
34  }
35 
36  template <typename T>
37  class ESValidHandle {
38  public:
39  typedef T value_type;
40 
41  ESValidHandle() = delete;
43  : data_{&iData}, description_{desc} {}
44 
45  ESValidHandle(ESValidHandle<T> const&) = default;
46  ESValidHandle(ESValidHandle<T>&&) = default;
47  ESValidHandle& operator=(ESValidHandle<T> const&) = default;
49 
50  // ---------- const member functions ---------------------
51  T const* product() const noexcept { return data_; }
52  T const* operator->() const noexcept { return product(); }
53  T const& operator*() const noexcept { return *product(); }
54  // ---------- static member functions --------------------
55  static constexpr bool transientAccessOnly = false;
56 
57  // ---------- member functions ---------------------------
58  private:
59  T const* data_{nullptr};
61  };
62 
67  template <typename U>
68  auto makeESValid(const U& iOtherHandleType) noexcept(false) {
69  esvhhelper::throwIfNotValid(iOtherHandleType.product());
70  //because of the check, we know this is valid and do not have to check again
71  return ESValidHandle<typename U::value_type>(*iOtherHandleType.product(), iOtherHandleType.description());
72  }
73 
74 } // namespace edm
75 #endif
edm::ESValidHandle::operator*
T const & operator*() const noexcept
Definition: ESValidHandle.h:53
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ESValidHandle::ESValidHandle
ESValidHandle()=delete
ComponentDescription.h
edm::makeESValid
auto makeESValid(const U &iOtherHandleType) noexcept(false)
Definition: ESValidHandle.h:68
edm::esvhhelper::throwIfNotValid
void throwIfNotValid(const void *) noexcept(false)
Definition: ESValidHandle.cc:5
watchdog.const
const
Definition: watchdog.py:83
edm::ESValidHandle::description_
edm::eventsetup::ComponentDescription const * description_
Definition: ESValidHandle.h:60
edm::ESValidHandle::transientAccessOnly
static constexpr bool transientAccessOnly
Definition: ESValidHandle.h:55
edm::ESValidHandle::ESValidHandle
ESValidHandle(T const &iData, edm::eventsetup::ComponentDescription const *desc) noexcept
Definition: ESValidHandle.h:42
edm::ESValidHandle::data_
T const * data_
Definition: ESValidHandle.h:59
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::ESValidHandle::operator=
ESValidHandle & operator=(ESValidHandle< T > const &)=default
edm::eventsetup::ComponentDescription
Definition: ComponentDescription.h:30
edm::ESValidHandle
Definition: ESValidHandle.h:37
edm::ESValidHandle::operator->
T const * operator->() const noexcept
Definition: ESValidHandle.h:52
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
T
long double T
Definition: Basic3DVectorLD.h:48
edm::ESValidHandle::product
T const * product() const noexcept
Definition: ESValidHandle.h:51
edm::ESValidHandle::value_type
T value_type
Definition: ESValidHandle.h:39
ESValidHandle