Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
gallery::Handle< T > Class Template Reference

#include <Handle.h>

Classes

class  HandleTag
 

Public Types

using element_type = T
 

Public Member Functions

 Handle ()=default
 
 Handle (T const *, art::ProductID)
 
 Handle (std::shared_ptr< art::Exception const >)
 
 Handle (Handle const &)=default
 
Handleoperator= (Handle const &)=default
 
T const & operator* () const noexcept(false)
 
T const * operator-> () const noexcept(false)
 
T const * product () const noexcept(false)
 
bool isValid () const noexcept
 
art::ProductID id () const noexcept
 
std::shared_ptr< art::Exception const > whyFailed () const noexcept
 

Private Member Functions

void throwHandleWhyFailed_ () const noexcept(false)
 

Private Attributes

T const * prod_ {nullptr}
 
art::ProductID productID_ {art::ProductID::invalid()}
 
std::shared_ptr< art::Exception const > whyFailed_
 

Detailed Description

template<typename T>
class gallery::Handle< T >

Definition at line 17 of file Handle.h.

Member Typedef Documentation

template<typename T>
using gallery::Handle< T >::element_type = T

Definition at line 19 of file Handle.h.

Constructor & Destructor Documentation

template<typename T>
gallery::Handle< T >::Handle ( )
default
template<class T >
gallery::Handle< T >::Handle ( T const *  prod,
art::ProductID  productID 
)
explicit

Definition at line 47 of file Handle.h.

48  : prod_{prod}, productID_{productID}
49  {}
T const * prod_
Definition: Handle.h:41
art::ProductID productID_
Definition: Handle.h:42
template<class T >
gallery::Handle< T >::Handle ( std::shared_ptr< art::Exception const >  iWhyFailed)
explicit

Definition at line 52 of file Handle.h.

53  : whyFailed_{iWhyFailed}
54  {}
std::shared_ptr< art::Exception const > whyFailed_
Definition: Handle.h:43
template<typename T>
gallery::Handle< T >::Handle ( Handle< T > const &  )
default

Member Function Documentation

template<class T >
art::ProductID gallery::Handle< T >::id ( ) const
noexcept

Definition at line 86 of file Handle.h.

87  {
88  return productID_;
89  }
art::ProductID productID_
Definition: Handle.h:42
template<class T >
bool gallery::Handle< T >::isValid ( ) const
noexcept

Definition at line 79 of file Handle.h.

80  {
81  return prod_ != nullptr;
82  }
T const * prod_
Definition: Handle.h:41
template<class T >
T const & gallery::Handle< T >::operator* ( ) const
inlinenoexcept

Definition at line 57 of file Handle.h.

58  {
59  return *product();
60  }
T const * product() const noexcept(false)
Definition: Handle.h:70
template<class T >
T const * gallery::Handle< T >::operator-> ( ) const
inlinenoexcept

Definition at line 63 of file Handle.h.

64  {
65  return product();
66  }
T const * product() const noexcept(false)
Definition: Handle.h:70
template<typename T>
Handle& gallery::Handle< T >::operator= ( Handle< T > const &  )
default
template<class T >
T const * gallery::Handle< T >::product ( ) const
inlinenoexcept

Definition at line 70 of file Handle.h.

71  {
72  if (!prod_)
74  return prod_;
75  }
T const * prod_
Definition: Handle.h:41
void throwHandleWhyFailed_() const noexcept(false)
Definition: Handle.h:100
template<class T >
void gallery::Handle< T >::throwHandleWhyFailed_ ( ) const
privatenoexcept

Definition at line 100 of file Handle.h.

101  {
102  if (whyFailed_) {
103  throw *whyFailed_;
104  }
106  << "Attempt to dereference invalid Handle with no stored exception\n"
107  << "Maybe you forgot to call getByLabel before dereferencing\n";
108  }
std::shared_ptr< art::Exception const > whyFailed_
Definition: Handle.h:43
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<class T >
std::shared_ptr< art::Exception const > gallery::Handle< T >::whyFailed ( ) const
inlinenoexcept

Definition at line 93 of file Handle.h.

94  {
95  return whyFailed_;
96  }
std::shared_ptr< art::Exception const > whyFailed_
Definition: Handle.h:43

Member Data Documentation

template<typename T>
T const* gallery::Handle< T >::prod_ {nullptr}
private

Definition at line 41 of file Handle.h.

template<typename T>
art::ProductID gallery::Handle< T >::productID_ {art::ProductID::invalid()}
private

Definition at line 42 of file Handle.h.

template<typename T>
std::shared_ptr<art::Exception const> gallery::Handle< T >::whyFailed_
private

Definition at line 43 of file Handle.h.


The documentation for this class was generated from the following file: