1 #ifndef canvas_Persistency_Common_Wrapper_h 2 #define canvas_Persistency_Common_Wrapper_h 22 #include "cetlib_except/demangle.h" 44 template <
typename T,
typename =
void>
52 template <
typename T,
typename =
void>
59 std::type_info const&)
const,
60 &T::makePartner>> : std::true_type {};
83 explicit Wrapper(std::unique_ptr<T> ptr);
86 T const* product()
const;
87 T const* operator->()
const;
97 std::vector<void const*> getView()
const override;
102 std::unique_ptr<EDProduct> do_makePartner(
103 std::type_info
const& wanted_type)
const override;
105 unsigned do_getRangeSetID()
const override;
106 void do_setRangeSetID(
unsigned)
override;
107 void do_combine(
EDProduct const* product)
override;
108 std::unique_ptr<EDProduct> do_createEmptySampledProduct(
114 void do_insertIfSampledProduct(
std::string const& dataset,
116 std::unique_ptr<EDProduct> product)
override;
123 std::type_info
const* typeInfo_()
const override;
125 void const* do_getElementAddress(std::type_info
const& toType,
126 unsigned long index)
const override;
128 std::vector<void const*> do_getElementAddresses(
129 std::type_info
const& toType,
130 std::vector<unsigned long>
const&
indices)
const override;
132 T&& refOrThrow(
T* ptr);
135 unsigned rangeSetID{-1u};
143 #include "boost/lexical_cast.hpp" 156 #include <type_traits> 162 template <
typename T>
167 template <
typename T>
174 template <
typename T>
180 template <
typename T>
181 std::type_info
const*
187 template <
typename T>
188 std::vector<void const*>
194 template <
typename T>
205 template <
typename T>
220 template <
typename T>
227 template <
typename T>
234 template <
typename T>
241 template <
typename T>
242 std::unique_ptr<art::EDProduct>
245 std::unique_ptr<art::EDProduct> retval;
247 retval =
obj.makePartner(wanted_wrapper);
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";
258 template <
typename T>
260 static std::unique_ptr<EDProduct>
263 auto emptySampledProduct = std::make_unique<Sampled<T>>(tag);
264 return std::make_unique<Wrapper<Sampled<T>>>(
move(emptySampledProduct));
267 [[noreturn]]
static void 271 std::unique_ptr<EDProduct>)
274 <<
"An attempt was made to insert a product from dataset '" << dataset
275 <<
"'\ninto a non-sampled product of type '" 276 << cet::demangle_symbol(
typeid(
T).
name()) <<
"'.\n" 277 <<
"Please contact artists@fnal.gov for guidance.";
281 template <
typename T>
283 [[noreturn]]
static std::unique_ptr<EDProduct>
287 <<
"An attempt was made to create an empty sampled product\n" 288 <<
"for a sampled product. This type of recursion is not allowed.\n" 289 <<
"Please contact artists@fnal.gov for guidance.";
296 std::unique_ptr<EDProduct>
product)
298 auto& wp =
dynamic_cast<Wrapper<T>&
>(*product);
304 template <
typename T>
305 std::unique_ptr<art::EDProduct>
311 template <
typename T>
315 std::unique_ptr<EDProduct>
product)
318 obj, dataset,
id,
move(product));
321 template <
typename T>
324 unsigned long const index 325 [[maybe_unused]])
const 331 void const*
result{
nullptr};
336 <<
"The product type " << cet::demangle_symbol(
typeid(
T).
name())
337 <<
" does not support art::Ptr\n";
341 template <
typename T>
342 inline std::vector<void const*>
344 std::type_info
const& toType,
345 std::vector<unsigned long>
const&
indices)
const 353 std::vector<void const*>
result;
358 <<
"The product type " << cet::demangle_symbol(
typeid(
T).
name())
359 <<
" does not support art::PtrVector\n";
363 template <
typename T>
371 <<
"Attempt to construct " << cet::demangle_symbol(
typeid(*this).name())
372 <<
" from nullptr.\n";
static product_typeids_t get()
static void insert_if_sampled_product(Sampled< T > &obj, std::string const &dataset, SubRunID const &id, std::unique_ptr< EDProduct > product)
unsigned do_getRangeSetID() const override
T const * operator->() const
std::unique_ptr< EDProduct > do_makePartner(std::type_info const &wanted_type) const override
decltype(std::declval< T const >().size()) size_expression_t
std::unique_ptr< EDProduct > do_createEmptySampledProduct(InputTag const &tag) const override
enable_if_same_t< FT, decltype(f), R > enable_if_function_exists_t
void do_insertIfSampledProduct(std::string const &dataset, SubRunID const &id, std::unique_ptr< EDProduct > product) override
static std::type_info const * type_id()
std::type_info const * typeInfo_() const override
bool isPresent_() const override
static short Class_Version()
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
void do_combine(EDProduct const *product) override
void setPtr(COLLECTION const &coll, std::type_info const &iToType, unsigned long iIndex, void const *&oPtr)
static void aggregate(T &, T const &)
void const * do_getElementAddress(std::type_info const &toType, unsigned long index) const override
T const * product() const
std::vector< void const * > do_getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices) const override
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
void getElementAddresses(Collection const &coll, std::type_info const &iToType, std::vector< unsigned long > const &indices, std::vector< void const * > &oPtr)
void insert(std::string const &dataset, SubRunID const &id, T &&value)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
static std::vector< void const * > get(T const &)
std::map< product_metatype, TypeID > product_typeids_t
std::vector< void const * > getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices) const
product_typeids_t do_getTypeIDs() const override
static std::unique_ptr< EDProduct > create_empty_sampled_product(InputTag const &)
static std::unique_ptr< EDProduct > create_empty_sampled_product(InputTag const &tag)
std::string productSize() const override
std::vector< void const * > getView() const override
static void insert_if_sampled_product(T &, std::string const &dataset, SubRunID const &, std::unique_ptr< EDProduct >)
void do_setRangeSetID(unsigned) override
constexpr ProductStatus present() noexcept