LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::Wrapper< T > Class Template Reference

#include "Handle.h"

Inheritance diagram for art::Wrapper< T >:
art::EDProduct

Public Member Functions

 Wrapper ()=default
 
 Wrapper (std::unique_ptr< T > ptr)
 
virtual ~Wrapper ()=default
 
T const * product () const
 
T const * operator-> () const
 
bool isPresent () const
 
virtual std::type_info const * typeInfo () const
 
void const * getElementAddress (std::type_info const &toType, unsigned long index) const
 
std::vector< void const * > getElementAddresses (std::type_info const &toType, std::vector< unsigned long > const &indices) const
 
product_typeids_t getTypeIDs () const
 
std::unique_ptr< EDProductmakePartner (std::type_info const &wanted_type) const
 
unsigned getRangeSetID () const
 
void setRangeSetID (unsigned const id)
 
void combine (EDProduct *p)
 
std::unique_ptr< EDProductcreateEmptySampledProduct (InputTag const &tag) const
 
void insertIfSampledProduct (std::string const &dataset, SubRunID const &id, std::unique_ptr< EDProduct > product)
 

Static Public Member Functions

static short Class_Version ()
 

Private Member Functions

std::vector< void const * > getView () const override
 
std::string productSize () const override
 
product_typeids_t do_getTypeIDs () const override
 
std::unique_ptr< EDProductdo_makePartner (std::type_info const &wanted_type) const override
 
unsigned do_getRangeSetID () const override
 
void do_setRangeSetID (unsigned) override
 
void do_combine (EDProduct const *product) override
 
std::unique_ptr< EDProductdo_createEmptySampledProduct (InputTag const &tag) const override
 
void do_insertIfSampledProduct (std::string const &dataset, SubRunID const &id, std::unique_ptr< EDProduct > product) override
 
bool isPresent_ () const override
 
std::type_info const * typeInfo_ () const override
 
void const * do_getElementAddress (std::type_info const &toType, unsigned long index) const override
 
std::vector< void const * > do_getElementAddresses (std::type_info const &toType, std::vector< unsigned long > const &indices) const override
 
T && refOrThrow (T *ptr)
 

Private Attributes

bool present {false}
 
unsigned rangeSetID {-1u}
 
obj {}
 

Friends

template<typename >
struct prevent_recursion
 

Detailed Description

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

Definition at line 66 of file Handle.h.

Constructor & Destructor Documentation

template<typename T>
art::Wrapper< T >::Wrapper ( )
default
template<typename T >
art::Wrapper< T >::Wrapper ( std::unique_ptr< T >  ptr)
explicit

Definition at line 161 of file Wrapper.h.

References art::Wrapper< T >::obj, art::Wrapper< T >::rangeSetID, and art::Wrapper< T >::refOrThrow().

162  : present{ptr.get() != nullptr}, rangeSetID{-1u}, obj(refOrThrow(ptr.get()))
163 {}
unsigned rangeSetID
Definition: Wrapper.h:135
bool present
Definition: Wrapper.h:134
T && refOrThrow(T *ptr)
Definition: Wrapper.h:366
template<typename T>
virtual art::Wrapper< T >::~Wrapper ( )
virtualdefault

Member Function Documentation

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

Definition at line 91 of file Wrapper.h.

92  {
93  return 11;
94  }
void art::EDProduct::combine ( EDProduct p)
inlineinherited

Definition at line 79 of file EDProduct.h.

References art::EDProduct::do_combine().

80  {
81  do_combine(p);
82  }
virtual void do_combine(EDProduct const *)=0
std::unique_ptr<EDProduct> art::EDProduct::createEmptySampledProduct ( InputTag const &  tag) const
inlineinherited

Definition at line 85 of file EDProduct.h.

References art::EDProduct::do_createEmptySampledProduct().

86  {
87  return do_createEmptySampledProduct(tag);
88  }
virtual std::unique_ptr< EDProduct > do_createEmptySampledProduct(InputTag const &tag) const =0
template<typename T >
void art::Wrapper< T >::do_combine ( art::EDProduct const *  p)
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 207 of file Wrapper.h.

References art::detail::CanBeAggregated< T, Enable >::aggregate(), art::EDProduct::isPresent(), art::Wrapper< T >::obj, and art::Wrapper< T >::present.

208 {
209  if (!p->isPresent())
210  return;
211 
212  auto wp = static_cast<Wrapper<T> const*>(p);
214 
215  // The presence for the combined product is 'true', if we get this
216  // far.
217  present = true;
218 }
static void aggregate(T &, T const &)
Definition: aggregate.h:53
bool present
Definition: Wrapper.h:134
template<typename T >
std::unique_ptr< art::EDProduct > art::Wrapper< T >::do_createEmptySampledProduct ( InputTag const &  tag) const
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 307 of file Wrapper.h.

References art::prevent_recursion< T >::create_empty_sampled_product().

308 {
310 }
static std::unique_ptr< EDProduct > create_empty_sampled_product(InputTag const &tag)
Definition: Wrapper.h:261
template<typename T>
void const * art::Wrapper< T >::do_getElementAddress ( std::type_info const &  toType,
unsigned long  index 
) const
inlineoverrideprivatevirtual

Implements art::EDProduct.

Definition at line 324 of file Wrapper.h.

References art::Wrapper< T >::obj, art::errors::ProductDoesNotSupportPtr, and art::setPtr().

327 {
328  if constexpr (has_setPtr<T>::value) {
329  // Allow setPtr customizations by introducing the art::setPtr
330  // overload set, and not requiring art::setPtr(...).
331  using art::setPtr;
332  void const* result{nullptr};
333  setPtr(obj, toType, index, result);
334  return result;
335  } else {
337  << "The product type " << cet::demangle_symbol(typeid(T).name())
338  << " does not support art::Ptr\n";
339  }
340 }
void setPtr(COLLECTION const &coll, std::type_info const &iToType, unsigned long iIndex, void const *&oPtr)
double value
Definition: spectrum.C:18
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<typename T >
std::vector< void const * > art::Wrapper< T >::do_getElementAddresses ( std::type_info const &  toType,
std::vector< unsigned long > const &  indices 
) const
inlineoverrideprivatevirtual

Implements art::EDProduct.

Definition at line 344 of file Wrapper.h.

References art::getElementAddresses(), art::EDProduct::getElementAddresses(), art::Wrapper< T >::obj, and art::errors::ProductDoesNotSupportPtr.

347 {
348  if constexpr (has_setPtr<T>::value) {
349  // getElementAddresses is the name of an overload set; each
350  // concrete collection T should supply a getElementAddresses
351  // function, in the same namespace at that in which T is
352  // defined, or in the 'art' namespace.
354  std::vector<void const*> result;
355  getElementAddresses(obj, toType, indices, result);
356  return result;
357  } else {
359  << "The product type " << cet::demangle_symbol(typeid(T).name())
360  << " does not support art::PtrVector\n";
361  }
362 }
void getElementAddresses(Collection const &coll, std::type_info const &iToType, std::vector< unsigned long > const &indices, std::vector< void const * > &oPtr)
double value
Definition: spectrum.C:18
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::vector< void const * > getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices) const
Definition: EDProduct.cc:34
template<typename T >
unsigned art::Wrapper< T >::do_getRangeSetID ( ) const
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 229 of file Wrapper.h.

References art::Wrapper< T >::rangeSetID.

230 {
231  return rangeSetID;
232 }
unsigned rangeSetID
Definition: Wrapper.h:135
template<typename T >
art::product_typeids_t art::Wrapper< T >::do_getTypeIDs ( ) const
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 236 of file Wrapper.h.

References art::detail::ProductTypeIDs< T >::get().

237 {
239 }
static product_typeids_t get()
template<typename T >
void art::Wrapper< T >::do_insertIfSampledProduct ( std::string const &  dataset,
SubRunID const &  id,
std::unique_ptr< EDProduct product 
)
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 314 of file Wrapper.h.

References art::prevent_recursion< T >::insert_if_sampled_product(), and art::Wrapper< T >::obj.

317 {
319  obj, dataset, id, std::move(product));
320 }
static void insert_if_sampled_product(T &, std::string const &dataset, SubRunID const &, std::unique_ptr< EDProduct >)
Definition: Wrapper.h:269
template<typename T >
std::unique_ptr< art::EDProduct > art::Wrapper< T >::do_makePartner ( std::type_info const &  wanted_type) const
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 243 of file Wrapper.h.

References art::errors::LogicError, and art::Wrapper< T >::obj.

244 {
245  std::unique_ptr<art::EDProduct> retval;
247  retval = obj.makePartner(wanted_wrapper);
248  } else {
249  throw Exception{errors::LogicError, "makePartner"}
250  << "Attempted to make partner of a product ("
251  << cet::demangle_symbol(typeid(T).name()) << ") that does not know how!\n"
252  << "Please report to the art framework developers.\n";
253  }
254  return retval;
255 }
double value
Definition: spectrum.C:18
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<typename T >
void art::Wrapper< T >::do_setRangeSetID ( unsigned  id)
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 222 of file Wrapper.h.

References art::Wrapper< T >::rangeSetID.

223 {
224  rangeSetID = id;
225 }
unsigned rangeSetID
Definition: Wrapper.h:135
void const * EDProduct::getElementAddress ( std::type_info const &  toType,
unsigned long  index 
) const
inherited

Definition at line 27 of file EDProduct.cc.

References art::EDProduct::do_getElementAddress().

Referenced by art::EDProduct::isPresent(), and art::Ptr< L >::operator->().

29 {
30  return do_getElementAddress(toType, index);
31 }
virtual void const * do_getElementAddress(std::type_info const &toType, unsigned long index) const =0
std::vector< void const * > EDProduct::getElementAddresses ( std::type_info const &  toType,
std::vector< unsigned long > const &  indices 
) const
inherited

Definition at line 34 of file EDProduct.cc.

References art::EDProduct::do_getElementAddresses().

Referenced by art::Wrapper< T >::do_getElementAddresses(), and art::EDProduct::isPresent().

36 {
37  return do_getElementAddresses(toType, indices);
38 }
virtual std::vector< void const * > do_getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices) const =0
unsigned art::EDProduct::getRangeSetID ( ) const
inlineinherited

Definition at line 67 of file EDProduct.h.

References art::EDProduct::do_getRangeSetID().

68  {
69  return do_getRangeSetID();
70  }
virtual unsigned do_getRangeSetID() const =0
product_typeids_t art::EDProduct::getTypeIDs ( ) const
inlineinherited

Definition at line 55 of file EDProduct.h.

References art::EDProduct::do_getTypeIDs().

56  {
57  return do_getTypeIDs();
58  }
virtual product_typeids_t do_getTypeIDs() const =0
template<typename T >
std::vector< void const * > art::Wrapper< T >::getView ( ) const
overrideprivatevirtual

Reimplemented from art::EDProduct.

Definition at line 188 of file Wrapper.h.

References art::CannotGetView< T >::get(), and art::Wrapper< T >::obj.

189 {
190  return MaybeGetView<T>::get(obj);
191 }
static std::vector< void const * > get(T const &)
Definition: traits.h:147
void art::EDProduct::insertIfSampledProduct ( std::string const &  dataset,
SubRunID const &  id,
std::unique_ptr< EDProduct product 
)
inlineinherited
bool art::EDProduct::isPresent ( ) const
inlineinherited
template<typename T>
bool art::Wrapper< T >::isPresent_ ( ) const
inlineoverrideprivatevirtual

Implements art::EDProduct.

Definition at line 119 of file Wrapper.h.

References geo::vect::indices(), and art::productstatus::present().

120  {
121  return present;
122  }
bool present
Definition: Wrapper.h:134
std::unique_ptr<EDProduct> art::EDProduct::makePartner ( std::type_info const &  wanted_type) const
inlineinherited

Definition at line 61 of file EDProduct.h.

References art::EDProduct::do_makePartner().

62  {
63  return do_makePartner(wanted_type);
64  }
virtual std::unique_ptr< EDProduct > do_makePartner(std::type_info const &wanted_type) const =0
template<typename T >
T const * art::Wrapper< T >::operator-> ( ) const

Definition at line 174 of file Wrapper.h.

References art::Wrapper< T >::product().

175 {
176  return product();
177 }
T const * product() const
Definition: Wrapper.h:167
template<typename T >
T const * art::Wrapper< T >::product ( ) const

Definition at line 167 of file Wrapper.h.

References art::Wrapper< T >::obj, and art::Wrapper< T >::present.

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

168 {
169  return present ? &obj : nullptr;
170 }
bool present
Definition: Wrapper.h:134
template<typename T >
std::string art::Wrapper< T >::productSize ( ) const
overrideprivatevirtual

Reimplemented from art::EDProduct.

Definition at line 195 of file Wrapper.h.

References art::Wrapper< T >::obj, art::to_string(), and util::to_string().

196 {
197  if constexpr (detail::has_size_member<T>::value) {
198  using std::to_string;
199  return to_string(obj.size());
200  } else {
201  return "-";
202  }
203 }
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
double value
Definition: spectrum.C:18
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
template<typename T >
T && art::Wrapper< T >::refOrThrow ( T *  ptr)
inlineprivate

Definition at line 366 of file Wrapper.h.

References art::errors::NullPointerError.

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

367 {
368  if (ptr) {
369  return std::move(*ptr);
370  }
372  << "Attempt to construct " << cet::demangle_symbol(typeid(*this).name())
373  << " from nullptr.\n";
374 }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void art::EDProduct::setRangeSetID ( unsigned const  id)
inlineinherited

Definition at line 73 of file EDProduct.h.

References art::EDProduct::do_setRangeSetID().

74  {
75  do_setRangeSetID(id);
76  }
virtual void do_setRangeSetID(unsigned)=0
std::type_info const * EDProduct::typeInfo ( ) const
virtualinherited

Definition at line 21 of file EDProduct.cc.

References art::EDProduct::typeInfo_().

Referenced by art::EDProduct::isPresent().

22 {
23  return typeInfo_();
24 }
virtual std::type_info const * typeInfo_() const =0
template<typename T >
std::type_info const * art::Wrapper< T >::typeInfo_ ( ) const
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 181 of file Wrapper.h.

References art::SupportsView< T, typename >::type_id().

182 {
183  return SupportsView<T>::type_id();
184 }
static std::type_info const * type_id()
Definition: traits.h:83

Friends And Related Function Documentation

template<typename T>
template<typename >
friend struct prevent_recursion
friend

Definition at line 112 of file Wrapper.h.

Member Data Documentation

template<typename T>
bool art::Wrapper< T >::present {false}
private

Definition at line 134 of file Wrapper.h.

Referenced by art::Wrapper< T >::do_combine(), and art::Wrapper< T >::product().

template<typename T>
unsigned art::Wrapper< T >::rangeSetID {-1u}
private

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