LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
art::Ptr< T > Class Template Reference

#include "fwd.h"

Public Types

typedef std::size_t key_type
 
typedef T value_type
 
typedef T const * const_pointer
 
typedef T const & const_reference
 

Public Member Functions

 Ptr ()=default
 
template<typename H >
 Ptr (H const &handle, key_type idx)
 
 Ptr (ProductID const id)
 
 Ptr (ProductID const productID, key_type itemKey, EDProductGetter const *prodGetter)
 
template<typename U >
 Ptr (Ptr< U > const &iOther, std::enable_if_t< std::is_base_of< T, U >::value > *dummy=nullptr)
 
template<typename U >
 Ptr (Ptr< U > const &iOther, std::enable_if_t< std::is_base_of< U, T >::value > *dummy=nullptr)
 
 Ptr (ProductID const productID, T const *item, key_type itemKey)
 
T const & operator* () const
 
T const * operator-> () const
 
T const * get () const
 
bool isNull () const
 
bool isNonnull () const
 
bool isAvailable () const
 
ProductID id () const
 
key_type key () const
 
bool hasCache () const
 
RefCore const & refCore () const
 
 operator bool () const
 
EDProductGetter const * productGetter () const
 
template<typename H >
 Ptr (H const &handle, typename Ptr< T >::key_type const idx)
 

Static Public Member Functions

static short Class_Version ()
 

Private Member Functions

template<typename C >
T const * getItem_ (C const *product, key_type iKey)
 
void getData_ () const
 

Private Attributes

RefCore core_ {}
 
key_type key_ {key_traits<key_type>::value}
 

Detailed Description

template<typename T>
class art::Ptr< T >

Definition at line 25 of file fwd.h.

Member Typedef Documentation

template<typename T>
typedef T const* art::Ptr< T >::const_pointer

Definition at line 104 of file Ptr.h.

template<typename T>
typedef T const& art::Ptr< T >::const_reference

Definition at line 105 of file Ptr.h.

template<typename T>
typedef std::size_t art::Ptr< T >::key_type

Definition at line 102 of file Ptr.h.

template<typename T>
typedef T art::Ptr< T >::value_type

Definition at line 103 of file Ptr.h.

Constructor & Destructor Documentation

template<typename T>
art::Ptr< T >::Ptr ( )
default
template<typename T>
template<typename H >
art::Ptr< T >::Ptr ( H const &  handle,
key_type  idx 
)
template<typename T >
art::Ptr< T >::Ptr ( ProductID const  id)
inlineexplicit

Definition at line 269 of file Ptr.h.

References art::Ptr< T >::key_.

270  : core_{productID, 0, nullptr}, key_{key_traits<key_type>::value}
271 {}
RefCore core_
Definition: Ptr.h:165
key_type key_
Definition: Ptr.h:166
static constexpr key_type value
Definition: traits.h:40
template<typename T >
art::Ptr< T >::Ptr ( ProductID const  productID,
key_type  itemKey,
EDProductGetter const *  prodGetter 
)
inline

Definition at line 274 of file Ptr.h.

References art::Ptr< T >::key_.

277  : core_{productID, 0, prodGetter}, key_{itemKey}
278 {}
RefCore core_
Definition: Ptr.h:165
key_type key_
Definition: Ptr.h:166
template<typename T>
template<typename U >
art::Ptr< T >::Ptr ( Ptr< U > const &  iOther,
std::enable_if_t< std::is_base_of< T, U >::value > *  dummy = nullptr 
)
inline

Definition at line 282 of file Ptr.h.

References art::Ptr< T >::key().

284  : core_(iOther.id(),
285  (iOther.hasCache() ? static_cast<T const*>(iOther.get()) :
286  static_cast<T const*>(nullptr)),
287  iOther.productGetter())
288  , key_{iOther.key()}
289 {}
RefCore core_
Definition: Ptr.h:165
key_type key_
Definition: Ptr.h:166
template<typename T>
template<typename U >
art::Ptr< T >::Ptr ( Ptr< U > const &  iOther,
std::enable_if_t< std::is_base_of< U, T >::value > *  dummy = nullptr 
)
inline

Definition at line 293 of file Ptr.h.

References art::Ptr< T >::get(), art::Ptr< T >::id(), and art::Ptr< T >::key_.

295  : core_{iOther.id(), dynamic_cast<T const*>(iOther.get()), nullptr}
296  , key_{iOther.key()}
297 {}
RefCore core_
Definition: Ptr.h:165
key_type key_
Definition: Ptr.h:166
ProductID id() const
Definition: RefCore.h:93
template<typename T>
art::Ptr< T >::Ptr ( ProductID const  productID,
T const *  item,
key_type  itemKey 
)
inline

Definition at line 300 of file Ptr.h.

References art::Ptr< T >::key_.

303  : core_{productID, item, nullptr}, key_{itemKey}
304 {}
RefCore core_
Definition: Ptr.h:165
key_type key_
Definition: Ptr.h:166
template<typename T>
template<typename H >
art::Ptr< T >::Ptr ( H const &  handle,
typename Ptr< T >::key_type const  idx 
)
inline

Definition at line 258 of file Ptr.h.

References art::Ptr< T >::core_, art::Ptr< T >::getItem_(), art::errors::InvalidReference, art::RefCore::isNull(), and art::Ptr< T >::key_.

259  : core_{handle.id(), getItem_(handle.product(), idx), nullptr}, key_{idx}
260 {
261  if (core_.isNull()) {
263  << "Attempt to construct a Ptr from a Handle with invalid ProductID. "
264  "Perhaps a\ndefault-constructed Ptr is what you want?";
265  }
266 }
RefCore core_
Definition: Ptr.h:165
key_type key_
Definition: Ptr.h:166
T const * getItem_(C const *product, key_type iKey)
Definition: Ptr.h:391
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ProductID id() const
Definition: RefCore.h:93
bool isNull() const
Definition: RefCore.h:82

Member Function Documentation

template<typename T>
static short art::Ptr< T >::Class_Version ( )
inlinestatic

Definition at line 155 of file Ptr.h.

156  {
157  return 10;
158  }
template<typename T >
void art::Ptr< T >::getData_ ( ) const
private

Definition at line 398 of file Ptr.h.

References art::Ptr< T >::core_, e, art::EDProductGetter::getIt(), art::Ptr< T >::hasCache(), art::RefCore::id(), art::Ptr< T >::key(), art::Ptr< T >::key_, art::operator!=(), art::operator==(), art::Ptr< T >::productGetter(), art::errors::ProductNotFound, art::Ptr< T >::refCore(), art::RefCore::setProductPtr(), art::EDProduct::setPtr(), and fhicl::detail::atom::value().

Referenced by art::Ptr< T >::operator->().

399 {
400  if (!hasCache()) {
401  EDProduct const* prod =
402  productGetter() ? productGetter()->getIt() : nullptr;
403  if (prod == nullptr) {
405  e << "A request to resolve an art::Ptr to a product containing items of "
406  "type: "
407  << cet::demangle_symbol(typeid(T).name()) << " with ProductID "
408  << core_.id()
409  << "\ncannot be satisfied because the product cannot be found.\n";
410  if (productGetter() == nullptr) {
411  e << "The productGetter was not set -- are you trying to dereference a "
412  "Ptr during mixing?\n";
413  } else {
414  e << "Probably the branch containing the product is not stored in the "
415  "input file.\n";
416  }
417  throw e;
418  }
419  void const* ad = nullptr;
420  prod->setPtr(typeid(T), key_, ad);
421  core_.setProductPtr(ad);
422  }
423 }
virtual EDProduct const * getIt() const =0
RefCore core_
Definition: Ptr.h:165
EDProductGetter const * productGetter() const
Definition: Ptr.h:383
key_type key_
Definition: Ptr.h:166
bool hasCache() const
Definition: Ptr.h:363
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ProductID id() const
Definition: RefCore.h:93
Float_t e
Definition: plot.C:34
void setProductPtr(void const *prodPtr) const
Definition: RefCore.h:111
template<typename T >
template<typename C >
T const * art::Ptr< T >::getItem_ ( C const *  product,
key_type  iKey 
)
inlineprivate

Definition at line 391 of file Ptr.h.

Referenced by art::Ptr< T >::Ptr().

392 {
393  return detail::ItemGetter<T, C>()(product, iKey);
394 }
template<typename T >
bool art::Ptr< T >::hasCache ( ) const
inline

Definition at line 363 of file Ptr.h.

References art::Ptr< T >::core_, and art::RefCore::productPtr().

Referenced by art::Ptr< T >::getData_().

364 {
365  return nullptr != core_.productPtr();
366 }
RefCore core_
Definition: Ptr.h:165
void const * productPtr() const
Definition: RefCore.h:99
template<typename T >
bool art::Ptr< T >::isAvailable ( ) const
inline

Definition at line 342 of file Ptr.h.

References art::Ptr< T >::core_, and art::RefCore::isAvailable().

Referenced by art::Ptr< T >::operator bool().

343 {
344  return core_.isAvailable();
345 }
RefCore core_
Definition: Ptr.h:165
bool isAvailable() const
Definition: RefCore.cc:15
template<typename T >
bool art::Ptr< T >::isNonnull ( ) const
inline
template<typename T >
auto art::Ptr< T >::key ( ) const
inline

Definition at line 356 of file Ptr.h.

References art::Ptr< T >::key_.

Referenced by RecoProxyUsageExample::analyze(), lar_pandora::LArPandoraHelper::BuildMCParticleHitMaps(), shower::EMShowerAlg::CheckShowerPlanes(), t0::IndirectHitParticleAssns::CreateHitParticleAssociations(), evd::RecoBaseDrawer::DrawPFParticle3D(), evd::RecoBaseDrawer::DrawTrackVertexAssns2D(), ems::EndPoint::FillBins(), lar_pandora::LArPandoraHelper::GetAssociatedHits(), lar_pandora::LArPandoraEvent::GetAssociationMap(), art::Ptr< T >::getData_(), anab::MVAReader< T, N >::getOutput(), anab::FVectorReader< T, N >::getVector(), anab::FVectorWriter< 4 >::getVector(), art::PtrVectorBase::key(), trkmkr::TrackMaker::makeTrack(), lar::util::details::FindAllP< Source, Dest >::Merge(), art::PtrRemapper::operator()(), std::hash< art::Ptr< T > >::operator()(), lar::util::details::UniqueAssociationCache< Source_t, Dest_t >::operator[](), lar_pandora::LArPandoraEventDump::PrintParticle(), apa::APAHitFinder::produce(), hit::HitCheater::produce(), caldata::CalWire::produce(), CRHitRemoval::produce(), caldata::CalWireT962::produce(), cosmic::TrackPFParticleMatch::produce(), TrackProducerFromPFParticle::produce(), cosmic::CosmicPFParticleTagger::produce(), shower::EMShower::produce(), cosmic::CosmicTrackTagger::produce(), cosmic::CosmicPCAxisTagger::produce(), vertex::PrimaryVertexFinder::produce(), shwf::ShowerReco::produce(), trkf::PMAlgTrajFitter::produce(), art::Ptr< T >::Ptr(), and trkf::KalmanFilterFinalTrackFitter::setMomValue().

357 {
358  return key_;
359 }
key_type key_
Definition: Ptr.h:166
template<typename T >
art::Ptr< T >::operator bool ( ) const
inlineexplicit

Definition at line 376 of file Ptr.h.

References art::Ptr< T >::isAvailable(), and art::Ptr< T >::isNonnull().

377 {
378  return isNonnull() && isAvailable();
379 }
bool isNonnull() const
Definition: Ptr.h:335
bool isAvailable() const
Definition: Ptr.h:342
template<typename T >
T const & art::Ptr< T >::operator* ( ) const
inline

Definition at line 307 of file Ptr.h.

308 {
309  return *get();
310 }
template<typename T >
T const * art::Ptr< T >::operator-> ( ) const
inline

Definition at line 313 of file Ptr.h.

References art::Ptr< T >::core_, art::Ptr< T >::getData_(), and art::RefCore::productPtr().

Referenced by art::Ptr< T >::get().

314 {
315  getData_();
316  return reinterpret_cast<T const*>(core_.productPtr());
317 }
RefCore core_
Definition: Ptr.h:165
void getData_() const
Definition: Ptr.h:398
void const * productPtr() const
Definition: RefCore.h:99
template<typename T >
auto art::Ptr< T >::productGetter ( ) const
inline

Definition at line 383 of file Ptr.h.

References art::Ptr< T >::core_, and art::RefCore::productGetter().

Referenced by art::Ptr< T >::getData_().

384 {
385  return core_.productGetter();
386 }
RefCore core_
Definition: Ptr.h:165
EDProductGetter const * productGetter() const
Definition: RefCore.h:105
template<typename T >
auto art::Ptr< T >::refCore ( ) const
inline

Definition at line 370 of file Ptr.h.

References art::Ptr< T >::core_.

Referenced by art::PtrVector< T >::assign(), art::Ptr< T >::getData_(), art::PtrVector< T >::insert(), and art::PtrVector< T >::push_back().

371 {
372  return core_;
373 }
RefCore core_
Definition: Ptr.h:165

Member Data Documentation

template<typename T>
key_type art::Ptr< T >::key_ {key_traits<key_type>::value}
private

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