File indexing completed on 2023-10-25 09:46:49
0001 #ifndef FWCore_Framework_ESValidHandle_h
0002 #define FWCore_Framework_ESValidHandle_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "FWCore/Framework/interface/ComponentDescription.h"
0025
0026 #include <exception>
0027 #include <memory>
0028 #include <utility>
0029
0030 namespace edm {
0031
0032 namespace esvhhelper {
0033 void throwIfNotValid(const void*) noexcept(false);
0034 }
0035
0036 template <typename T>
0037 class ESValidHandle {
0038 public:
0039 typedef T value_type;
0040
0041 ESValidHandle() = delete;
0042 ESValidHandle(T const& iData, edm::eventsetup::ComponentDescription const* desc) noexcept
0043 : data_{&iData}, description_{desc} {}
0044
0045 ESValidHandle(ESValidHandle<T> const&) = default;
0046 ESValidHandle(ESValidHandle<T>&&) = default;
0047 ESValidHandle& operator=(ESValidHandle<T> const&) = default;
0048 ESValidHandle& operator=(ESValidHandle<T>&&) = default;
0049
0050
0051 T const* product() const noexcept { return data_; }
0052 T const* operator->() const noexcept { return product(); }
0053 T const& operator*() const noexcept { return *product(); }
0054
0055 static constexpr bool transientAccessOnly = false;
0056
0057
0058 private:
0059 T const* data_{nullptr};
0060 edm::eventsetup::ComponentDescription const* description_{nullptr};
0061 };
0062
0063
0064
0065
0066
0067 template <typename U>
0068 auto makeESValid(const U& iOtherHandleType) noexcept(false) {
0069 esvhhelper::throwIfNotValid(iOtherHandleType.product());
0070
0071 return ESValidHandle<typename U::value_type>(*iOtherHandleType.product(), iOtherHandleType.description());
0072 }
0073
0074 }
0075 #endif