Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
art::Ptr< T > Class Template Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/canvas/v3_09_01/source/canvas/Persistency/Common/fwd.h"

Public Types

using key_type = std::size_t
 
using value_type = T
 
using const_pointer = T const *
 
using const_reference = T const &
 

Public Member Functions

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

Static Public Member Functions

static constexpr short Class_Version () noexcept
 

Private Attributes

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

Detailed Description

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

Definition at line 29 of file fwd.h.

Member Typedef Documentation

template<typename T>
using art::Ptr< T >::const_pointer = T const*

Definition at line 81 of file Ptr.h.

template<typename T>
using art::Ptr< T >::const_reference = T const&

Definition at line 82 of file Ptr.h.

template<typename T>
using art::Ptr< T >::key_type = std::size_t

Definition at line 79 of file Ptr.h.

template<typename T>
using art::Ptr< T >::value_type = T

Definition at line 80 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,
typename Ptr< T >::key_type  key 
)
inline

Definition at line 88 of file Ptr.h.

89  : core_{handle.id(),
90  detail::ItemGetter<T,
91  std::remove_const_t<std::remove_pointer_t<
92  decltype(handle.product())>>>()(
93  handle.product(),
94  key),
95  nullptr}
96  , key_{key}
97  {
98  if (core_.isNull()) {
100  << "Attempt to construct a Ptr from a Handle with invalid ProductID. "
101  "Perhaps a\n"
102  "default-constructed Ptr is what you want?";
103  }
104  }
RefCore core_
Definition: Ptr.h:250
key_type key_
Definition: Ptr.h:253
constexpr bool isNull() const noexcept
Definition: RefCore.h:34
key_type key() const noexcept
Definition: Ptr.h:236
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr ProductID id() const noexcept
Definition: RefCore.h:47
double T
Definition: Xdiff_gwt.C:5
template<typename T>
art::Ptr< T >::Ptr ( ProductID const &  productID)
inlineexplicit

Definition at line 107 of file Ptr.h.

108  : core_{productID, nullptr, nullptr}
109  {}
RefCore core_
Definition: Ptr.h:250
template<typename T>
art::Ptr< T >::Ptr ( ProductID const &  productID,
key_type  itemKey,
EDProductGetter const *  prodGetter 
)
inline

Definition at line 112 of file Ptr.h.

115  : core_{productID, nullptr, prodGetter}, key_{itemKey}
116  {}
RefCore core_
Definition: Ptr.h:250
key_type key_
Definition: Ptr.h:253
template<typename T>
template<typename U >
art::Ptr< T >::Ptr ( Ptr< U > const &  pu,
std::enable_if_t< std::is_base_of_v< T, U >> *  = nullptr 
)
inline

Definition at line 120 of file Ptr.h.

121  : core_{pu.id(),
122  (pu.hasCache() ? static_cast<T const*>(pu.get()) : nullptr),
123  pu.productGetter()}
124  , key_{pu.key()}
125  {}
RefCore core_
Definition: Ptr.h:250
key_type key_
Definition: Ptr.h:253
constexpr ProductID id() const noexcept
Definition: RefCore.h:47
double T
Definition: Xdiff_gwt.C:5
template<typename T>
template<typename U >
art::Ptr< T >::Ptr ( Ptr< U > const &  pu,
std::enable_if_t< std::is_base_of_v< U, T >> *  = nullptr 
)
inline

Definition at line 128 of file Ptr.h.

129  : core_{pu.id(), static_cast<T const*>(pu.get()), nullptr}, key_{pu.key()}
130  {}
RefCore core_
Definition: Ptr.h:250
key_type key_
Definition: Ptr.h:253
constexpr ProductID id() const noexcept
Definition: RefCore.h:47
double T
Definition: Xdiff_gwt.C:5
template<typename T>
art::Ptr< T >::Ptr ( ProductID const &  productID,
T const *  item,
key_type const  itemKey 
)
inline

Definition at line 133 of file Ptr.h.

134  : core_{productID, item, nullptr}, key_{itemKey}
135  {}
RefCore core_
Definition: Ptr.h:250
key_type key_
Definition: Ptr.h:253

Member Function Documentation

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

Definition at line 243 of file Ptr.h.

244  {
245  return 10;
246  }
template<typename T>
T const* art::Ptr< T >::get ( ) const
inline

Definition at line 149 of file Ptr.h.

Referenced by dif::DiFShowerFinder::adjustPlane(), dif::DiFShowerFinder::adjustPlane_end(), chaninfo::CosmicEff::analyze(), comi::NumiFilteringAna::analyze(), showere::ShowerEnergyAna::analyze(), rockmuon::NDRockMuon::analyze(), bpfit::BPFTmvaTrainer::analyze(), bpf::BPFCVNAna::analyze(), ncs::Xeff::analyze(), ncs::ROCKMRE::analyze(), slid::LIDTraining::analyze(), ncs::NCAna::analyze(), fuzz::ViewMatchAlg::CalcEnergyProfile(), nerd::ViewMatchAlg::CalcEnergyProfile(), slid::NuEEnergyAlg::CellEnergy(), cheat::CheckBackTracking::CheckTrackIdToParticle(), bpfit::dEdxCalculator::computeDEDX(), evd::RecoBaseDrawer::DrawTrack2D(), cheat::BackTracker::EnergyFromTrackId(), dif::DiFShowerFinder::eparm(), art::detail::BcollHelper< ProdB >::fill(), caf::FillHadClustVars(), bpfit::BreakPoint::FillHitList(), caf::FillSliceVars(), comi::NumiFiltering::filter(), bsf::BremShowerFilter::filter(), showere::ShowerEnergyFilterMC::filter(), trident::DimuonSliceFilter::filter(), bsf::BremShowerFilter::findShowerByReco(), dif::DiFShowerFinder::findShowerByReco(), bpfit::BreakPoint::FitTracks(), bpfit::DimuonFitter::FitView(), cosrej::CosRejFxs::getBBC(), jmshower::RecoJMShower::GetRVPStats(), rb::HitList::HitList(), cheat::BackTracker::HitToPhotonSignal(), cheat::BackTracker::HitToTrackIDE(), dif::DiFShowerFinder::muonstub(), evg::MCTruthToDk2NuHackItr::Next(), calib::PCHitsList::ProcessTrack(), tf::TimingFit::produce(), nuesand::FillNueSandbox::produce(), presel::NuePresel::produce(), numusand::FillSandbox::produce(), lem::Preselection::produce(), cosrej::CosRej::produce(), earms::ElasticArmsHS::produce(), calib::PCHitsList::produce(), jmshower::NueSel::produce(), rvp::RecVarPID::produce(), jmshower::NueSelLID::produce(), g4n::G4Gen::produce(), bpfit::BPFEnergyEstimator::produce(), bpfit::BPFEnergyEstimatorOnly::produce(), cosrej::MakeNueCosRej::produce(), bpfit::DimuonFitter::produce(), art::Ptr< L >::Ptr(), rb::Cluster::RecoHit(), jmshower::RecoJMShower::RecoShowers(), g4n::G4Alg::RunGeant(), and lem::LEMSummarizer::SliceToLEMInput().

150  {
151  return isNull() ? nullptr : operator->();
152  }
T const * operator->() const
Definition: Ptr.h:154
bool isNull() const noexcept
Definition: Ptr.h:193
template<typename T>
bool art::Ptr< T >::hasCache ( ) const
inlinenoexcept

Definition at line 230 of file Ptr.h.

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

231  {
232  return core_.productPtr() != nullptr;
233  }
RefCore core_
Definition: Ptr.h:250
void const * productPtr() const noexcept
template<typename T>
ProductID art::Ptr< T >::id ( ) const
inlinenoexcept

Definition at line 210 of file Ptr.h.

Referenced by cheat::CheckBackTracking::CheckTrackIdToParticle(), art::PtrRemapper::operator()(), and art::Ptr< L >::Ptr().

211  {
212  return core_.id();
213  }
RefCore core_
Definition: Ptr.h:250
constexpr ProductID id() const noexcept
Definition: RefCore.h:47
template<typename T>
bool art::Ptr< T >::isAvailable ( ) const
inline

Definition at line 224 of file Ptr.h.

225  {
226  return core_.isAvailable();
227  }
RefCore core_
Definition: Ptr.h:250
bool isAvailable() const
template<typename T>
bool art::Ptr< T >::isNonnull ( ) const
inlinenoexcept

Definition at line 186 of file Ptr.h.

Referenced by art::PtrRemapper::operator()().

187  {
189  }
key_type key_
Definition: Ptr.h:253
static constexpr key_type value
Definition: traits.h:39
template<typename T>
bool art::Ptr< T >::isNull ( ) const
inlinenoexcept

Definition at line 193 of file Ptr.h.

Referenced by rb::SecondaryInteraction::ParentTrack(), and cheat::BackTracker::SliceToOrderedNuIds().

194  {
195  return !isNonnull();
196  }
bool isNonnull() const noexcept
Definition: Ptr.h:186
template<typename T>
key_type art::Ptr< T >::key ( ) const
inlinenoexcept

Definition at line 236 of file Ptr.h.

Referenced by art::PtrRemapper::operator()(), and art::operator==().

237  {
238  return key_;
239  }
key_type key_
Definition: Ptr.h:253
template<typename T>
art::Ptr< T >::operator bool ( ) const
inlineexplicit

Definition at line 198 of file Ptr.h.

199  {
201  }
RefCore core_
Definition: Ptr.h:250
key_type key_
Definition: Ptr.h:253
bool isAvailable() const
static constexpr key_type value
Definition: traits.h:39
template<typename T>
T const& art::Ptr< T >::operator* ( ) const
inline

Definition at line 141 of file Ptr.h.

142  {
143  // FIXME: This causes an nullptr dereference if isNull!
144  // return isNull() ? nullptr : operator->();
145  return *get();
146  }
template<typename T>
T const* art::Ptr< T >::operator-> ( ) const
inline

Definition at line 154 of file Ptr.h.

155  {
156  if (core_.productPtr() == nullptr) {
157  EDProduct const* prod{nullptr};
158  if (productGetter()) {
159  prod = productGetter()->getIt();
160  }
161  if (prod == nullptr) {
163  e << "A request to resolve an Ptr to a product containing items of "
164  "type: "
165  << cet::demangle_symbol(typeid(T).name()) << " with ProductID "
166  << core_.id()
167  << "\ncannot be satisfied because the product cannot be found.\n";
168  if (productGetter() == nullptr) {
169  e << "The productGetter was not set -- are you trying to "
170  "dereference a Ptr during mixing?\n";
171  } else {
172  e << "Probably the branch containing the product is not stored in "
173  "the input file.\n";
174  }
175  throw e;
176  }
177  void const* ad{nullptr};
178  prod->setPtr(typeid(T), key_, ad);
179  core_.setProductPtr(ad);
180  }
181  return reinterpret_cast<T const*>(core_.productPtr());
182  }
const XML_Char * name
Definition: expat.h:151
RefCore core_
Definition: Ptr.h:250
key_type key_
Definition: Ptr.h:253
void const * productPtr() const noexcept
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
EDProduct const * getIt() const
EDProductGetter const * productGetter() const noexcept
Definition: Ptr.h:216
void setProductPtr(void const *prodPtr) const noexcept
constexpr ProductID id() const noexcept
Definition: RefCore.h:47
double T
Definition: Xdiff_gwt.C:5
Float_t e
Definition: plot.C:35
template<typename T>
EDProductGetter const* art::Ptr< T >::productGetter ( ) const
inlinenoexcept

Definition at line 216 of file Ptr.h.

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

217  {
218  return core_.productGetter();
219  }
RefCore core_
Definition: Ptr.h:250
EDProductGetter const * productGetter() const noexcept
template<typename T>
RefCore const& art::Ptr< T >::refCore ( ) const
inlinenoexcept

Definition at line 204 of file Ptr.h.

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

205  {
206  return core_;
207  }
RefCore core_
Definition: Ptr.h:250

Member Data Documentation

template<typename T>
RefCore art::Ptr< T >::core_ {}
private

Definition at line 250 of file Ptr.h.

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

Definition at line 253 of file Ptr.h.


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