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

#include "/cvmfs/nova.opensciencegrid.org/externals/art/v3_05_01/source/art/Framework/Principal/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 setPtr (std::type_info const &toType, unsigned long index, void const *&ptr) const
 
void getElementAddresses (std::type_info const &toType, std::vector< unsigned long > const &indices, std::vector< void const * > &ptr) 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

void fillView (std::vector< void const * > &view) 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 *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 do_setPtr (std::type_info const &toType, unsigned long index, void const *&ptr) const override
 
void do_getElementAddresses (std::type_info const &toType, std::vector< unsigned long > const &indices, std::vector< void const * > &ptr) const override
 
T && refOrThrow (T *ptr)
 

Private Attributes

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

Friends

template<typename >
struct prevent_recursion
 

Detailed Description

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

Definition at line 57 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 166 of file Wrapper.h.

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

167  : present{ptr.get() != nullptr}, rangeSetID{-1u}, obj(refOrThrow(ptr.get()))
168 {}
unsigned rangeSetID
Definition: Wrapper.h:138
bool present
Definition: Wrapper.h:137
T && refOrThrow(T *ptr)
Definition: Wrapper.h:361
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 93 of file Wrapper.h.

References string, getGoodRuns4SAM::tag, and POTSpillRate::view.

94  {
95  return 11;
96  }
void art::EDProduct::combine ( EDProduct p)
inlineinherited

Definition at line 87 of file EDProduct.h.

References art::EDProduct::do_combine().

88  {
89  do_combine(p);
90  }
const char * p
Definition: xmltok.h:285
virtual void do_combine(EDProduct *)=0
std::unique_ptr<EDProduct> art::EDProduct::createEmptySampledProduct ( InputTag const &  tag) const
inlineinherited

Definition at line 93 of file EDProduct.h.

References art::EDProduct::do_createEmptySampledProduct().

94  {
96  }
virtual std::unique_ptr< EDProduct > do_createEmptySampledProduct(InputTag const &tag) const =0
template<typename T >
void art::Wrapper< T >::do_combine ( art::EDProduct p)
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 206 of file Wrapper.h.

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

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

Implements art::EDProduct.

Definition at line 305 of file Wrapper.h.

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

306 {
308 }
static std::unique_ptr< EDProduct > create_empty_sampled_product(InputTag const &tag)
Definition: Wrapper.h:260
template<typename T >
void art::Wrapper< T >::do_getElementAddresses ( std::type_info const &  toType,
std::vector< unsigned long > const &  indices,
std::vector< void const * > &  ptr 
) const
inlineoverrideprivatevirtual

Implements art::EDProduct.

Definition at line 340 of file Wrapper.h.

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

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

Implements art::EDProduct.

Definition at line 228 of file Wrapper.h.

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

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

Implements art::EDProduct.

Definition at line 235 of file Wrapper.h.

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

236 {
238 }
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 312 of file Wrapper.h.

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

315 {
317  obj, dataset, id, move(product));
318 }
T const * product() const
Definition: Wrapper.h:172
static void insert_if_sampled_product(T &, std::string const &dataset, SubRunID const &, std::unique_ptr< EDProduct >)
Definition: Wrapper.h:267
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 242 of file Wrapper.h.

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

243 {
244  std::unique_ptr<art::EDProduct> retval;
246  retval = obj.makePartner(wanted_wrapper);
247  } else {
248  throw Exception{errors::LogicError, "makePartner"}
249  << "Attempted to make partner of a product ("
250  << cet::demangle_symbol(typeid(T).name()) << ") that does not know how!\n"
251  << "Please report to the art framework developers.\n";
252  }
253  return retval;
254 }
const XML_Char * name
Definition: expat.h:151
const XML_Char int const XML_Char * value
Definition: expat.h:331
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
double T
Definition: Xdiff_gwt.C:5
template<typename T>
void art::Wrapper< T >::do_setPtr ( std::type_info const &  toType,
unsigned long  index,
void const *&  ptr 
) const
inlineoverrideprivatevirtual

Implements art::EDProduct.

Definition at line 322 of file Wrapper.h.

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

325 {
326  if constexpr (has_setPtr<T>::value) {
327  // Allow setPtr customizations by introducing the art::setPtr
328  // overload set, and not requiring art::setPtr(...).
329  using art::setPtr;
330  setPtr(obj, toType, index, ptr);
331  } else {
333  << "The product type " << cet::demangle_symbol(typeid(T).name())
334  << " does not support art::Ptr\n";
335  }
336 }
const XML_Char * name
Definition: expat.h:151
void setPtr(std::type_info const &toType, unsigned long index, void const *&ptr) const
const XML_Char int const XML_Char * value
Definition: expat.h:331
void setPtr(COLLECTION const &coll, std::type_info const &iToType, unsigned long iIndex, void const *&oPtr)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
double T
Definition: Xdiff_gwt.C:5
template<typename T >
void art::Wrapper< T >::do_setRangeSetID ( unsigned  id)
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 221 of file Wrapper.h.

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

222 {
223  rangeSetID = id;
224 }
::xsd::cxx::tree::id< char, ncname > id
Definition: Database.h:165
unsigned rangeSetID
Definition: Wrapper.h:138
template<typename T >
void art::Wrapper< T >::fillView ( std::vector< void const * > &  view) const
overrideprivatevirtual

Reimplemented from art::EDProduct.

Definition at line 192 of file Wrapper.h.

References art::CannotFillView< T >::fill(), art::Wrapper< T >::obj, and string.

193 {
195 }
static void fill(T const &, std::vector< void const * > &)
Definition: traits.h:136
void art::EDProduct::getElementAddresses ( std::type_info const &  toType,
std::vector< unsigned long > const &  indices,
std::vector< void const * > &  ptr 
) const
inherited
unsigned art::EDProduct::getRangeSetID ( ) const
inlineinherited

Definition at line 75 of file EDProduct.h.

References art::EDProduct::do_getRangeSetID().

76  {
77  return do_getRangeSetID();
78  }
virtual unsigned do_getRangeSetID() const =0
product_typeids_t art::EDProduct::getTypeIDs ( ) const
inlineinherited

Definition at line 63 of file EDProduct.h.

References art::EDProduct::do_getTypeIDs().

64  {
65  return do_getTypeIDs();
66  }
virtual product_typeids_t do_getTypeIDs() const =0
void art::EDProduct::insertIfSampledProduct ( std::string const &  dataset,
SubRunID const &  id,
std::unique_ptr< EDProduct product 
)
inlineinherited
bool art::EDProduct::isPresent ( ) const
inlineinherited

Definition at line 30 of file EDProduct.h.

References art::EDProduct::isPresent_().

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

31  {
32  return isPresent_();
33  }
virtual bool isPresent_() const =0
template<typename T>
bool art::Wrapper< T >::isPresent_ ( ) const
inlineoverrideprivatevirtual

Implements art::EDProduct.

Definition at line 121 of file Wrapper.h.

References allTimeWatchdog::index, art::productstatus::present(), and T.

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

Definition at line 69 of file EDProduct.h.

References art::EDProduct::do_makePartner().

70  {
71  return do_makePartner(wanted_type);
72  }
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 178 of file Wrapper.h.

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

179 {
180  return product();
181 }
T const * product() const
Definition: Wrapper.h:172
template<typename T >
T const * art::Wrapper< T >::product ( ) const

Definition at line 172 of file Wrapper.h.

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

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

173 {
174  return present ? &obj : nullptr;
175 }
bool present
Definition: Wrapper.h:137
template<typename T >
std::string art::Wrapper< T >::productSize ( ) const
overrideprivatevirtual

Reimplemented from art::EDProduct.

Definition at line 199 of file Wrapper.h.

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

200 {
201  return art::productSize<T>()(obj);
202 }
template<typename T >
T && art::Wrapper< T >::refOrThrow ( T ptr)
inlineprivate

Definition at line 361 of file Wrapper.h.

References art::errors::NullPointerError.

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

362 {
363  if (ptr) {
364  return std::move(*ptr);
365  } else {
367  << "Attempt to construct " << cet::demangle_symbol(typeid(*this).name())
368  << " from nullptr.\n";
369  }
370 }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void art::EDProduct::setPtr ( std::type_info const &  toType,
unsigned long  index,
void const *&  ptr 
) const
inherited
void art::EDProduct::setRangeSetID ( unsigned const  id)
inlineinherited

Definition at line 81 of file EDProduct.h.

References art::EDProduct::do_setRangeSetID().

82  {
83  do_setRangeSetID(id);
84  }
virtual void do_setRangeSetID(unsigned)=0
virtual std::type_info const* art::EDProduct::typeInfo ( ) const
inlinevirtualinherited

Definition at line 43 of file EDProduct.h.

References art::EDProduct::getElementAddresses(), allTimeWatchdog::index, art::EDProduct::setPtr(), string, and art::EDProduct::typeInfo_().

44  {
45  return typeInfo_();
46  }
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 185 of file Wrapper.h.

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

186 {
187  return SupportsView<T>::type_id();
188 }
static std::type_info const * type_id()
Definition: traits.h:84

Friends And Related Function Documentation

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

Definition at line 114 of file Wrapper.h.

Member Data Documentation

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

Definition at line 137 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: