Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
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
 
- Public Member Functions inherited from art::EDProduct
virtual ~EDProduct ()=default
 
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 58 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 163 of file Wrapper.h.

164  : present{ptr.get() != nullptr}, rangeSetID{-1u}, obj(refOrThrow(ptr.get()))
165 {}
unsigned rangeSetID
Definition: Wrapper.h:135
bool present
Definition: Wrapper.h:134
T && refOrThrow(T *ptr)
Definition: Wrapper.h:365
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  }
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.

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
p
Definition: test.py:223
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 306 of file Wrapper.h.

307 {
309 }
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 323 of file Wrapper.h.

326 {
327  if constexpr (has_setPtr<T>::value) {
328  // Allow setPtr customizations by introducing the art::setPtr
329  // overload set, and not requiring art::setPtr(...).
330  using art::setPtr;
331  void const* result{nullptr};
332  setPtr(obj, toType, index, result);
333  return result;
334  } else {
336  << "The product type " << cet::demangle_symbol(typeid(T).name())
337  << " does not support art::Ptr\n";
338  }
339 }
static QCString name
Definition: declinfo.cpp:673
static QCString result
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
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 343 of file Wrapper.h.

346 {
347  if constexpr (has_setPtr<T>::value) {
348  // getElementAddresses is the name of an overload set; each
349  // concrete collection T should supply a getElementAddresses
350  // function, in the same namespace at that in which T is
351  // defined, or in the 'art' namespace.
353  std::vector<void const*> result;
354  getElementAddresses(obj, toType, indices, result);
355  return result;
356  } else {
358  << "The product type " << cet::demangle_symbol(typeid(T).name())
359  << " does not support art::PtrVector\n";
360  }
361 }
static QCString name
Definition: declinfo.cpp:673
static QCString result
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
std::vector< void const * > getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices) const
Definition: EDProduct.cc:20
template<typename T >
unsigned art::Wrapper< T >::do_getRangeSetID ( ) const
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 229 of file Wrapper.h.

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.

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 313 of file Wrapper.h.

316 {
318  obj, dataset, id, move(product));
319 }
def move(depos, offset)
Definition: depos.py:107
static void insert_if_sampled_product(T &, std::string const &dataset, SubRunID const &, std::unique_ptr< EDProduct >)
Definition: Wrapper.h:268
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.

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 }
static QCString name
Definition: declinfo.cpp:673
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.

223 {
224  rangeSetID = id;
225 }
unsigned rangeSetID
Definition: Wrapper.h:135
template<typename T >
std::vector< void const * > art::Wrapper< T >::getView ( ) const
overrideprivatevirtual

Reimplemented from art::EDProduct.

Definition at line 189 of file Wrapper.h.

190 {
191  return MaybeGetView<T>::get(obj);
192 }
static std::vector< void const * > get(T const &)
Definition: traits.h:147
template<typename T>
bool art::Wrapper< T >::isPresent_ ( ) const
inlineoverrideprivatevirtual

Implements art::EDProduct.

Definition at line 119 of file Wrapper.h.

120  {
121  return present;
122  }
bool present
Definition: Wrapper.h:134
template<typename T >
T const * art::Wrapper< T >::operator-> ( ) const

Definition at line 175 of file Wrapper.h.

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

Definition at line 169 of file Wrapper.h.

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

Reimplemented from art::EDProduct.

Definition at line 196 of file Wrapper.h.

197 {
198  if constexpr (detail::has_size_member<T>::value) {
199  return boost::lexical_cast<std::string>(obj.size());
200  } else {
201  return "-";
202  }
203 }
std::string string
Definition: nybbler.cc:12
template<typename T >
T && art::Wrapper< T >::refOrThrow ( T *  ptr)
inlineprivate

Definition at line 365 of file Wrapper.h.

366 {
367  if (ptr) {
368  return std::move(*ptr);
369  }
371  << "Attempt to construct " << cet::demangle_symbol(typeid(*this).name())
372  << " from nullptr.\n";
373 }
def move(depos, offset)
Definition: depos.py:107
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<typename T >
std::type_info const * art::Wrapper< T >::typeInfo_ ( ) const
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 182 of file Wrapper.h.

183 {
184  return SupportsView<T>::type_id();
185 }
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>
T art::Wrapper< T >::obj {}
private

Definition at line 136 of file Wrapper.h.

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

Definition at line 134 of file Wrapper.h.

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

Definition at line 135 of file Wrapper.h.


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