LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 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
 
std::unique_ptr< EDProductmakePartner (std::type_info const &wanted_type) const
 
unsigned getRangeSetID () const
 
void setRangeSetID (unsigned const id)
 
void combine (EDProduct *p)
 

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
 
void do_combine (EDProduct *product) override
 
void do_setRangeSetID (unsigned) override
 
unsigned do_getRangeSetID () const override
 
std::unique_ptr< EDProductdo_makePartner (std::type_info const &wanted_type) const 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}
 
obj {}
 

Detailed Description

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

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

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

156  : present{ptr.get() != 0}, rangeSetID{-1u}, obj(refOrThrow(ptr.get()))
157 {}
unsigned rangeSetID
Definition: Wrapper.h:126
bool present
Definition: Wrapper.h:125
T && refOrThrow(T *ptr)
Definition: Wrapper.h:260
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 p)
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 195 of file Wrapper.h.

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

196 {
197  if (!p->isPresent())
198  return;
199 
200  auto wp = static_cast<Wrapper<T>*>(p);
202 
203  // The presence for the combined product is 'true', if we get this
204  // far.
205  present = true;
206 }
bool present
Definition: Wrapper.h:125
bool isPresent() const
Definition: EDProduct.h:28
static void aggregate(T &, T const &)
Definition: aggregate.h:57
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 248 of file Wrapper.h.

References art::Wrapper< T >::obj, and fhicl::detail::atom::value().

252 {
253  std::conditional_t<has_setPtr<T>::value, DoSetPtr<T>, DoNotSetPtr<T>>
254  maybe_filler;
255  maybe_filler(this->obj, toType, indices, ptrs);
256 }
std::string value(boost::any const &)
template<typename T >
unsigned art::Wrapper< T >::do_getRangeSetID ( ) const
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 217 of file Wrapper.h.

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

218 {
219  return rangeSetID;
220 }
unsigned rangeSetID
Definition: Wrapper.h:126
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 224 of file Wrapper.h.

References art::Wrapper< T >::obj, and fhicl::detail::atom::value().

225 {
226  std::unique_ptr<art::EDProduct> retval;
228  DoMakePartner<T>,
229  DoNotMakePartner<T>>
230  maybe_maker;
231  retval = maybe_maker(obj, wanted_wrapper);
232  return retval;
233 }
std::string value(boost::any const &)
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 237 of file Wrapper.h.

References art::Wrapper< T >::obj, and fhicl::detail::atom::value().

240 {
241  std::conditional_t<has_setPtr<T>::value, DoSetPtr<T>, DoNotSetPtr<T>>
242  maybe_filler;
243  maybe_filler(this->obj, toType, index, ptr);
244 }
std::string value(boost::any const &)
template<typename T >
void art::Wrapper< T >::do_setRangeSetID ( unsigned  id)
overrideprivatevirtual

Implements art::EDProduct.

Definition at line 210 of file Wrapper.h.

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

211 {
212  rangeSetID = id;
213 }
unsigned rangeSetID
Definition: Wrapper.h:126
template<typename T >
void art::Wrapper< T >::fillView ( std::vector< void const * > &  view) const
overrideprivatevirtual

Reimplemented from art::EDProduct.

Definition at line 181 of file Wrapper.h.

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

182 {
184 }
static void fill(T const &, std::vector< void const * > &)
Definition: traits.h:147
void EDProduct::getElementAddresses ( std::type_info const &  toType,
std::vector< unsigned long > const &  indices,
std::vector< void const * > &  ptr 
) const
inherited

Definition at line 23 of file EDProduct.cc.

References art::EDProduct::do_getElementAddresses().

Referenced by art::DoSetPtr< T >::operator()(), and art::EDProduct::typeInfo().

26 {
27  do_getElementAddresses(toType, indices, ptr);
28 }
virtual void do_getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices, std::vector< void const * > &ptr) 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
bool art::EDProduct::isPresent ( ) const
inlineinherited

Definition at line 28 of file EDProduct.h.

References art::EDProduct::isPresent_().

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

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

Implements art::EDProduct.

Definition at line 109 of file Wrapper.h.

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

110  {
111  return present;
112  }
bool present
Definition: Wrapper.h:125
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().

Referenced by art::AssnsGroup::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 167 of file Wrapper.h.

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

168 {
169  return product();
170 }
T const * product() const
Definition: Wrapper.h:161
template<typename T >
T const * art::Wrapper< T >::product ( ) const

Definition at line 161 of file Wrapper.h.

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

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

162 {
163  return present ? &obj : nullptr;
164 }
bool present
Definition: Wrapper.h:125
template<typename T >
std::string art::Wrapper< T >::productSize ( ) const
overrideprivatevirtual

Reimplemented from art::EDProduct.

Definition at line 188 of file Wrapper.h.

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

189 {
190  return art::productSize<T>()(obj);
191 }
template<typename T >
T && art::Wrapper< T >::refOrThrow ( T *  ptr)
inlineprivate

Definition at line 260 of file Wrapper.h.

References art::errors::NullPointerError.

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

261 {
262  if (ptr) {
263  return std::move(*ptr);
264  } else {
266  << "Attempt to construct " << cet::demangle_symbol(typeid(*this).name())
267  << " from nullptr.\n";
268  }
269 }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void EDProduct::setPtr ( std::type_info const &  toType,
unsigned long  index,
void const *&  ptr 
) const
inherited

Definition at line 15 of file EDProduct.cc.

References art::EDProduct::do_setPtr().

Referenced by art::Ptr< T >::getData_(), art::DoSetPtr< T >::operator()(), and art::EDProduct::typeInfo().

18 {
19  do_setPtr(toType, index, ptr);
20 }
virtual void do_setPtr(std::type_info const &toType, unsigned long index, void const *&ptr) const =0
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
virtual std::type_info const* art::EDProduct::typeInfo ( ) const
inlinevirtualinherited

Definition at line 41 of file EDProduct.h.

References art::EDProduct::getElementAddresses(), geo::vect::indices(), art::EDProduct::setPtr(), and art::EDProduct::typeInfo_().

42  {
43  return typeInfo_();
44  }
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 174 of file Wrapper.h.

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

175 {
176  return SupportsView<T>::type_id();
177 }
static std::type_info const * type_id()
Definition: traits.h:92

Member Data Documentation

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

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