1 #ifndef canvas_Persistency_Common_Wrapper_h 2 #define canvas_Persistency_Common_Wrapper_h 18 #include "cetlib/metaprogramming.h" 19 #include "cetlib_except/demangle.h" 32 using cet::enable_if_function_exists_t;
35 template <
typename T,
typename =
void>
42 enable_if_function_exists_t<size_t (T::*)() const, &T::size>>
47 template <
typename T,
typename =
void>
54 enable_if_function_exists_t<
std::unique_ptr<EDProduct> (T::*)(
55 std::type_info const&) const,
56 &T::makePartner>> : std::true_type {
83 explicit Wrapper(std::unique_ptr<T> ptr);
86 T
const* product()
const;
87 T
const* operator->()
const;
97 void fillView(std::vector<void const*>& view)
const override;
100 void do_combine(
EDProduct* product)
override;
102 void do_setRangeSetID(
unsigned)
override;
103 unsigned do_getRangeSetID()
const override;
105 std::unique_ptr<EDProduct> do_makePartner(
106 std::type_info
const& wanted_type)
const override;
113 std::type_info
const* typeInfo_()
const override;
115 void do_setPtr(std::type_info
const& toType,
117 void const*& ptr)
const override;
119 void do_getElementAddresses(std::type_info
const& toType,
120 std::vector<unsigned long>
const&
indices,
121 std::vector<void const*>& ptr)
const override;
123 T&& refOrThrow(T* ptr);
126 unsigned rangeSetID{-1u};
139 #include "boost/lexical_cast.hpp" 143 #include <type_traits> 154 template <
typename T>
159 template <
typename T>
166 template <
typename T>
172 template <
typename T>
173 std::type_info
const*
179 template <
typename T>
186 template <
typename T>
193 template <
typename T>
208 template <
typename T>
215 template <
typename T>
222 template <
typename T>
223 std::unique_ptr<art::EDProduct>
226 std::unique_ptr<art::EDProduct> retval;
231 retval = maybe_maker(
obj, wanted_wrapper);
235 template <
typename T>
239 void const*& ptr)
const 243 maybe_filler(this->
obj, toType, index, ptr);
246 template <
typename T>
249 std::type_info
const& toType,
250 std::vector<unsigned long>
const&
indices,
251 std::vector<void const*>& ptrs)
const 255 maybe_filler(this->
obj, toType, indices, ptrs);
258 template <
typename T>
263 return std::move(*ptr);
266 <<
"Attempt to construct " << cet::demangle_symbol(
typeid(*this).name())
267 <<
" from nullptr.\n";
277 template <
typename T>
282 return boost::lexical_cast<std::string>(obj.size());
286 template <
typename T>
325 template <
typename T>
327 std::unique_ptr<EDProduct>
330 return obj.makePartner(wanted_wrapper_type);
334 template <
typename T>
336 std::unique_ptr<EDProduct>
340 <<
"Attempted to make partner of a product (" 341 << cet::demangle_symbol(
typeid(T).name())
342 <<
") that does not know how!\n" 343 <<
"Please report to the ART framework developers.\n";
347 template <
typename T>
349 void operator()(T
const&
obj,
350 std::type_info
const& toType,
352 void const*& ptr)
const;
353 void operator()(T
const& obj,
354 std::type_info
const& toType,
355 std::vector<unsigned long>
const& index,
356 std::vector<void const*>& ptrs)
const;
359 template <
typename T>
363 std::type_info
const&,
368 <<
"The product type " << cet::demangle_symbol(
typeid(T).name())
369 <<
"\ndoes not support art::Ptr\n";
374 std::type_info
const&,
375 std::vector<unsigned long>
const&,
376 std::vector<void const*>&)
const 379 <<
"The product type " << cet::demangle_symbol(
typeid(T).name())
380 <<
"\ndoes not support art::PtrVector\n";
384 template <
typename T>
387 std::type_info
const& toType,
388 unsigned long const index,
389 void const*& ptr)
const 394 setPtr(obj, toType, index, ptr);
397 template <
typename T>
400 std::type_info
const& toType,
401 std::vector<unsigned long>
const&
indices,
402 std::vector<void const*>& ptr)
const unsigned do_getRangeSetID() const override
T const * operator->() const
void do_setPtr(std::type_info const &toType, unsigned long index, void const *&ptr) const override
std::unique_ptr< EDProduct > do_makePartner(std::type_info const &wanted_type) const override
void operator()(T const &, std::type_info const &, std::vector< unsigned long > const &, std::vector< void const * > &) const
void do_getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices, std::vector< void const * > &ptr) const override
static std::type_info const * type_id()
void do_combine(EDProduct *product) override
std::type_info const * typeInfo_() const override
bool isPresent_() const override
std::unique_ptr< EDProduct > operator()(T const &obj, std::type_info const &wanted_wrapper_type) const
static short Class_Version()
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::string operator()(T const &) const
T const * product() const
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
std::string operator()(T const &obj) const
std::unique_ptr< EDProduct > operator()(T const &, std::type_info const &) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
void getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices, std::vector< void const * > &ptr) const
std::string value(boost::any const &)
static void fill(T const &, std::vector< void const * > &)
void operator()(T const &, std::type_info const &, unsigned long, void const *&) const
void operator()(T const &obj, std::type_info const &toType, unsigned long index, void const *&ptr) const
void fillView(std::vector< void const * > &view) const override
static void aggregate(T &, T const &)
std::string productSize() const override
void setPtr(std::type_info const &toType, unsigned long index, void const *&ptr) const
void do_setRangeSetID(unsigned) override