File indexing completed on 2024-04-06 12:03:51
0001 #ifndef DataFormats_Common_Handle_h
0002 #define DataFormats_Common_Handle_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #include "DataFormats/Common/interface/HandleBase.h"
0029
0030 namespace edm {
0031
0032 template <typename T>
0033 class Handle : public HandleBase {
0034 public:
0035 using element_type = T;
0036
0037
0038 Handle();
0039
0040 Handle(T const* prod, Provenance const* prov);
0041
0042 Handle(std::shared_ptr<HandleExceptionFactory const>&&);
0043 Handle(Handle const&) = default;
0044 Handle& operator=(Handle&&) = default;
0045 Handle& operator=(Handle const&) = default;
0046
0047 ~Handle();
0048
0049 T const* product() const;
0050 T const* operator->() const;
0051 T const& operator*() const;
0052
0053 private:
0054 };
0055
0056 template <class T>
0057 Handle<T>::Handle() : HandleBase() {}
0058
0059 template <class T>
0060 Handle<T>::Handle(T const* prod, Provenance const* prov) : HandleBase(prod, prov) {}
0061
0062 template <class T>
0063 Handle<T>::Handle(std::shared_ptr<edm::HandleExceptionFactory const>&& iWhyFailed)
0064 : HandleBase(std::move(iWhyFailed)) {}
0065
0066 template <class T>
0067 Handle<T>::~Handle() {}
0068
0069 template <class T>
0070 T const* Handle<T>::product() const {
0071 return static_cast<T const*>(productStorage());
0072 }
0073
0074 template <class T>
0075 T const* Handle<T>::operator->() const {
0076 return product();
0077 }
0078
0079 template <class T>
0080 T const& Handle<T>::operator*() const {
0081 return *product();
0082 }
0083 }
0084 #endif