1 #ifndef art_Framework_Core_PtrRemapper_h 2 #define art_Framework_Core_PtrRemapper_h 211 #include "cetlib/exempt_ptr.h" 217 class ProdToProdMapBuilder;
219 namespace PtrRemapperDetail {
221 template <
typename PROD>
229 template <
typename CONT,
typename PROD,
typename CALLBACK>
243 template <
typename CONT,
typename PROD>
258 template <
typename CONT,
typename PROD>
285 template <
typename PROD,
typename SIZE_TYPE>
289 template <
typename PROD,
typename SIZE_TYPE>
291 SIZE_TYPE offset)
const;
294 template <
typename InIter,
typename OutIter,
typename SIZE_TYPE>
295 void operator()(InIter beg, InIter
end, OutIter out, SIZE_TYPE offset)
const;
298 template <
typename OutIter,
typename PROD,
typename OFFSETS>
301 OFFSETS
const& offsets)
const;
304 template <
typename CONT,
typename OutIter,
typename PROD,
typename OFFSETS>
305 void operator()(std::vector<PROD const*>
const& in,
307 OFFSETS
const& offsets,
308 CONT
const& (*extractor)(PROD
const*))
const;
311 template <
typename CONT,
typename OutIter,
typename PROD,
typename OFFSETS>
312 void operator()(std::vector<PROD const*>
const& in,
314 OFFSETS
const& offsets,
315 CONT
const& (PROD::*extractor)()
const)
const;
318 template <
typename CONT,
typename OutIter,
typename PROD,
typename OFFSETS>
319 void operator()(std::vector<PROD const*>
const& in,
321 OFFSETS
const& offsets,
322 CONT
const PROD::*data)
const;
325 template <
typename PROD,
330 void operator()(std::vector<PROD const*>
const& in,
332 OFFSETS
const& offsets,
333 CONT
const& (X::*extractor)(PROD
const*),
337 template <
typename PROD,
342 void operator()(std::vector<PROD const*>
const& in,
344 OFFSETS
const& offsets,
345 CONT
const& (X::*extractor)(PROD
const*)
const,
349 template <
typename CONT,
354 void operator()(std::vector<PROD const*>
const& in,
356 OFFSETS
const& offsets,
357 CALLBACK extractor)
const;
364 template <
typename PROD>
368 template <
typename PROD>
373 template <
typename PROD,
typename T>
378 template <
typename PROD,
typename T>
389 template <
typename PROD>
397 <<
"PtrRemapper: cannot create output " 399 <<
"\ndue to conflicting IDs in input ProductPtrs: " << old.
id()
400 <<
" vs. " << result.id() <<
"\nContact artists@fnal.gov for guidance.\n";
403 template <
typename T>
408 <<
"PtrRemapper: cannot create output " 409 <<
TypeID{
typeid(T)}.className() <<
" with ProductID: " <<
id 410 <<
"\nbecause the product is not known. Perhaps the output product " 411 "was misspecified for product mixing.\n";
417 cet::exempt_ptr<Event const> event_{
nullptr};
425 template <
typename PROD,
typename SIZE_TYPE>
428 SIZE_TYPE
const offset)
const 430 if (!oldPtr.
id().isValid() || oldPtr.
isNull()) {
434 auto core = newRefCore_(oldPtr.
id());
435 if (core.productGetter()) {
436 return Ptr<PROD>{core.
id(), oldPtr.
key() + offset, core.productGetter()};
439 throw unknownProduct_<Ptr<PROD>>(core.id());
443 template <
typename PROD,
typename SIZE_TYPE>
446 SIZE_TYPE
const offset)
const 452 std::back_inserter(result),
458 template <
typename InIter,
typename OutIter,
typename SIZE_TYPE>
463 SIZE_TYPE
const offset)
const 470 for (
auto i = beg; i !=
end; ++i) {
481 template <
typename OutIter,
typename PROD,
typename OFFSETS>
485 OFFSETS
const& offsets)
const 490 PtrRemapperDetail::simpleProdReturner<PROD>);
494 template <
typename CONT,
typename OutIter,
typename PROD,
typename OFFSETS>
498 OFFSETS
const& offsets,
499 CONT
const& (*extractor)(PROD
const*))
const 501 this->operator()<CONT, CONT
const& (*)(PROD
const*)>(in,
508 template <
typename CONT,
typename OutIter,
typename PROD,
typename OFFSETS>
512 OFFSETS
const& offsets,
513 CONT
const& (PROD::*extractor)()
const)
const 515 this->operator()<CONT, CONT
const& (PROD::*)()
const>(
in,
522 template <
typename CONT,
typename OutIter,
typename PROD,
typename OFFSETS>
526 OFFSETS
const& offsets,
527 CONT
const PROD::*data)
const 529 this->operator()<CONT, CONT
const PROD::*>(
in, out, offsets, data);
533 template <
typename PROD,
541 OFFSETS
const& offsets,
542 CONT
const& (X::*)(PROD
const*),
545 this->operator()<CONT>(
546 in, out, offsets, [&
x](
auto& elem) { elem.extractor(x); });
550 template <
typename PROD,
558 OFFSETS
const& offsets,
559 CONT
const& (X::*)(PROD
const*)
const,
562 this->operator()<CONT>(
563 in, out, offsets, [&
x](
auto& elem) { elem.extractor(x); });
567 template <
typename CONT,
575 OFFSETS
const& offsets,
576 CALLBACK extractor)
const 578 if (in.size() != offsets.size()) {
580 <<
"Collection size of " << in.size()
581 <<
" disagrees with offset container size of " << offsets.size() <<
".\n";
584 auto const e = in.end();
585 auto off_iter = offsets.begin();
587 for (; i !=
e; ++i, ++off_iter) {
588 CONT
const& cont{returner.operator()(*i)};
589 this->
operator()(cont.begin(), cont.end(), out, *off_iter);
598 template <
typename PROD>
602 if (!oldPtr.
id().isValid()) {
606 auto core = newRefCore_(oldPtr.
id());
607 if (core.productGetter()) {
611 throw unknownProduct_<ProductPtr<PROD>>(core.id());
615 template <
typename PROD>
621 for (
auto const* ptr : in) {
622 result = samePtrAs(remap(*ptr), result);
628 template <
typename PROD,
typename T>
634 for (
auto const* ptr : in) {
635 result = samePtrAs(this->
operator()(ptr->*data), result);
641 template <
typename PROD,
typename T>
648 for (
auto const* ptr : in) {
649 result = samePtrAs(this->
operator()((ptr->*extractor)()), result);
static ProductPtr< PROD > samePtrAs(ProductPtr< PROD > result, ProductPtr< PROD > old)
ContReturner(CALLBACK callback)
void reserve(size_type n)
CONT const &(PROD::*)() const CALLBACK
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
CONT const PROD::* CALLBACK
CONT const & operator()(PROD const *prod) const
CONT const & operator()(PROD const *prod) const
ContReturner(CALLBACK callback)
CONT const & operator()(PROD const *prod) const
key_type key() const noexcept
std::map< ProductID, ProductID > ProdTransMap_t
PROD const & simpleProdReturner(PROD const *prod)
bool isNull() const noexcept
ProductID id() const noexcept
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
static auto unknownProduct_(ProductID const id)
ProductID id() const noexcept
Ptr< PROD > operator()(Ptr< PROD > const &oldPtr, SIZE_TYPE offset) const
ContReturner(CALLBACK callback)