LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::PtrRemapper Class Reference

#include "PtrRemapper.h"

Public Member Functions

template<typename PROD , typename SIZE_TYPE >
Ptr< PROD > operator() (Ptr< PROD > const &oldPtr, SIZE_TYPE offset) const
 
template<typename PROD , typename SIZE_TYPE >
PtrVector< PROD > operator() (PtrVector< PROD > const &old, SIZE_TYPE offset) const
 
template<typename InIter , typename OutIter , typename SIZE_TYPE >
void operator() (InIter beg, InIter end, OutIter out, SIZE_TYPE offset) const
 
template<typename OutIter , typename PROD , typename OFFSETS >
void operator() (std::vector< PROD const * > const &in, OutIter out, OFFSETS const &offsets) const
 
template<typename CONT , typename OutIter , typename PROD , typename OFFSETS >
void operator() (std::vector< PROD const * > const &in, OutIter out, OFFSETS const &offsets, CONT const &(*extractor)(PROD const *)) const
 
template<typename CONT , typename OutIter , typename PROD , typename OFFSETS >
void operator() (std::vector< PROD const * > const &in, OutIter out, OFFSETS const &offsets, CONT const &(PROD::*extractor)() const) const
 
template<typename CONT , typename OutIter , typename PROD , typename OFFSETS >
void operator() (std::vector< PROD const * > const &in, OutIter out, OFFSETS const &offsets, CONT const PROD::*data) const
 
template<typename PROD , typename OutIter , typename CONT , typename X , typename OFFSETS >
void operator() (std::vector< PROD const * > const &in, OutIter out, OFFSETS const &offsets, CONT const &(X::*extractor)(PROD const *), X &x) const
 
template<typename PROD , typename OutIter , typename CONT , typename X , typename OFFSETS >
void operator() (std::vector< PROD const * > const &in, OutIter out, OFFSETS const &offsets, CONT const &(X::*extractor)(PROD const *) const, X const &x) const
 
template<typename CONT , typename CALLBACK , typename OutIter , typename PROD , typename OFFSETS >
void operator() (std::vector< PROD const * > const &in, OutIter out, OFFSETS const &offsets, CALLBACK extractor) const
 
template<typename PROD >
ProductPtr< PROD > operator() (ProductPtr< PROD > const &oldPtr) const
 
template<typename PROD >
ProductPtr< PROD > operator() (std::vector< ProductPtr< PROD > const * > const &in) const
 
template<typename PROD , typename T >
ProductPtr< T > operator() (std::vector< PROD const * > const &in, ProductPtr< T > const PROD::*data) const
 
template<typename PROD , typename T >
ProductPtr< T > operator() (std::vector< PROD const * > const &in, ProductPtr< T > const &(PROD::*extractor)() const) const
 
template<typename PROD , typename SIZE_TYPE >
art::Ptr< PROD > operator() (Ptr< PROD > const &oldPtr, SIZE_TYPE const offset) const
 
template<typename PROD , typename SIZE_TYPE >
art::PtrVector< PROD > operator() (PtrVector< PROD > const &old, SIZE_TYPE const offset) const
 
template<typename PROD , typename OutIter , typename CONT , typename X , typename OFFSETS >
void operator() (std::vector< PROD const * > const &in, OutIter out, OFFSETS const &offsets, CONT const &(X::*)(PROD const *), X &x) const
 
template<typename PROD >
art::ProductPtr< PROD > operator() (ProductPtr< PROD > const &oldPtr) const
 
template<typename PROD >
art::ProductPtr< PROD > operator() (std::vector< ProductPtr< PROD > const * > const &in) const
 
template<typename PROD , typename T >
art::ProductPtr< T > operator() (std::vector< PROD const * > const &in, ProductPtr< T > const PROD::*data) const
 
template<typename PROD , typename T >
art::ProductPtr< T > operator() (std::vector< PROD const * > const &in, ProductPtr< T > const &(PROD::*extractor)() const) const
 

Private Types

using ProdTransMap_t = std::map< ProductID, ProductID >
 

Private Member Functions

RefCore newRefCore_ (ProductID const incomingProductID) const
 

Static Private Member Functions

template<typename PROD >
static ProductPtr< PROD > samePtrAs (ProductPtr< PROD > result, ProductPtr< PROD > old)
 
template<typename T >
static auto unknownProduct_ (ProductID const id)
 

Private Attributes

ProdTransMap_t prodTransMap_ {}
 
cet::exempt_ptr< Event const > event_ {nullptr}
 

Friends

class ProdToProdMapBuilder
 

Detailed Description

Definition at line 275 of file PtrRemapper.h.

Member Typedef Documentation

Definition at line 385 of file PtrRemapper.h.

Member Function Documentation

art::RefCore art::PtrRemapper::newRefCore_ ( ProductID const  incomingProductID) const
private

Definition at line 4 of file PtrRemapper.cc.

References util::cend(), event_, art::errors::LogicError, and prodTransMap_.

5 {
6  auto iter = prodTransMap_.find(incomingProductID);
7  if (iter == cend(prodTransMap_)) {
9  << "PtrRemapper: could not find old ProductID " << incomingProductID
10  << " in translation table: already translated?\n";
11  }
12  return {iter->second, nullptr, event_->productGetter(iter->second)};
13 }
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:93
cet::exempt_ptr< Event const > event_
Definition: PtrRemapper.h:417
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ProdTransMap_t prodTransMap_
Definition: PtrRemapper.h:416
template<typename PROD , typename SIZE_TYPE >
Ptr<PROD> art::PtrRemapper::operator() ( Ptr< PROD > const &  oldPtr,
SIZE_TYPE  offset 
) const
template<typename PROD , typename SIZE_TYPE >
PtrVector<PROD> art::PtrRemapper::operator() ( PtrVector< PROD > const &  old,
SIZE_TYPE  offset 
) const
template<typename InIter , typename OutIter , typename SIZE_TYPE >
void art::PtrRemapper::operator() ( InIter  beg,
InIter  end,
OutIter  out,
SIZE_TYPE  offset 
) const

Definition at line 460 of file PtrRemapper.h.

References util::end(), and art::PtrRemapperDetail::ContReturner< CONT, PROD, CALLBACK >::operator()().

464 {
465  // Need to assume that all Ptr containers and consistent internally
466  // and with each other due to a lack of productGetters.
467 
468  // Not using transform here allows instantiation for iterator to
469  // collection of Ptr or collection of PtrVector.
470  for (auto i = beg; i != end; ++i) {
471  // Note: this could be signature 1 OR 2 of operator(). If the user
472  // calls this signature (3) with iterators into a collection of
473  // PtrVector, then the call order will be 3, 2, 3, 1 due to the
474  // templates that will be instantiated i.e. the relationship
475  // between signatures 2 and 3 is *not* infinitely recursive.
476  *out++ = this->operator()(*i, offset); // 1 OR 2.
477  }
478 }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
Ptr< PROD > operator()(Ptr< PROD > const &oldPtr, SIZE_TYPE offset) const
template<typename OutIter , typename PROD , typename OFFSETS >
void art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
OutIter  out,
OFFSETS const &  offsets 
) const

Definition at line 483 of file PtrRemapper.h.

References art::PtrRemapperDetail::ContReturner< CONT, PROD, CALLBACK >::operator()().

486 {
487  this->operator()(in,
488  out,
489  offsets,
490  PtrRemapperDetail::simpleProdReturner<PROD>); // 5.
491 }
Ptr< PROD > operator()(Ptr< PROD > const &oldPtr, SIZE_TYPE offset) const
template<typename CONT , typename OutIter , typename PROD , typename OFFSETS >
void art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
OutIter  out,
OFFSETS const &  offsets,
CONT const &(*)(PROD const *)  extractor 
) const

Definition at line 496 of file PtrRemapper.h.

500 {
501  this->operator()<CONT, CONT const& (*)(PROD const*)>(in,
502  out,
503  offsets,
504  extractor); // 10.
505 }
template<typename CONT , typename OutIter , typename PROD , typename OFFSETS >
void art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
OutIter  out,
OFFSETS const &  offsets,
CONT const &(PROD::*)() const  extractor 
) const

Definition at line 510 of file PtrRemapper.h.

References in.

514 {
515  this->operator()<CONT, CONT const& (PROD::*)() const>(in,
516  out,
517  offsets,
518  extractor); // 10.
519 }
template<typename CONT , typename OutIter , typename PROD , typename OFFSETS >
void art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
OutIter  out,
OFFSETS const &  offsets,
CONT const PROD::*  data 
) const

Definition at line 524 of file PtrRemapper.h.

References in, and X.

528 {
529  this->operator()<CONT, CONT const PROD::*>(in, out, offsets, data); // 10.
530 }
ifstream in
Definition: comparison.C:7
template<typename PROD , typename OutIter , typename CONT , typename X , typename OFFSETS >
void art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
OutIter  out,
OFFSETS const &  offsets,
CONT const &(X::*)(PROD const *)  extractor,
X x 
) const
template<typename PROD , typename OutIter , typename CONT , typename X , typename OFFSETS >
void art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
OutIter  out,
OFFSETS const &  offsets,
CONT const &(X::*)(PROD const *) const  extractor,
X const &  x 
) const

Definition at line 556 of file PtrRemapper.h.

References in, and x.

561 {
562  this->operator()<CONT>(
563  in, out, offsets, [&x](auto& elem) { elem.extractor(x); }); // 10.
564 }
Float_t x
Definition: compare.C:6
ifstream in
Definition: comparison.C:7
template<typename CONT , typename CALLBACK , typename OutIter , typename PROD , typename OFFSETS >
void art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
OutIter  out,
OFFSETS const &  offsets,
CALLBACK  extractor 
) const

Definition at line 573 of file PtrRemapper.h.

References e, art::errors::LogicError, and art::PtrRemapperDetail::ContReturner< CONT, PROD, CALLBACK >::operator()().

577 {
578  if (in.size() != offsets.size()) {
580  << "Collection size of " << in.size()
581  << " disagrees with offset container size of " << offsets.size() << ".\n";
582  }
583  auto i = in.begin();
584  auto const e = in.end();
585  auto off_iter = offsets.begin();
586  PtrRemapperDetail::ContReturner<CONT, PROD, CALLBACK> returner{extractor};
587  for (; i != e; ++i, ++off_iter) {
588  CONT const& cont{returner.operator()(*i)};
589  this->operator()(cont.begin(), cont.end(), out, *off_iter); // 3.
590  }
591 }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
Ptr< PROD > operator()(Ptr< PROD > const &oldPtr, SIZE_TYPE offset) const
Float_t e
Definition: plot.C:35
template<typename PROD >
ProductPtr<PROD> art::PtrRemapper::operator() ( ProductPtr< PROD > const &  oldPtr) const
template<typename PROD >
ProductPtr<PROD> art::PtrRemapper::operator() ( std::vector< ProductPtr< PROD > const * > const &  in) const
template<typename PROD , typename T >
ProductPtr<T> art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
ProductPtr< T > const PROD::*  data 
) const
template<typename PROD , typename T >
ProductPtr<T> art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
ProductPtr< T > const &(PROD::*)() const  extractor 
) const
template<typename PROD , typename SIZE_TYPE >
art::Ptr<PROD> art::PtrRemapper::operator() ( Ptr< PROD > const &  oldPtr,
SIZE_TYPE const  offset 
) const

Definition at line 427 of file PtrRemapper.h.

References art::Ptr< T >::id(), art::Ptr< T >::isNull(), and art::Ptr< T >::key().

429 {
430  if (!oldPtr.id().isValid() || oldPtr.isNull()) {
431  return {};
432  }
433 
434  auto core = newRefCore_(oldPtr.id());
435  if (core.productGetter()) {
436  return Ptr<PROD>{core.id(), oldPtr.key() + offset, core.productGetter()};
437  }
438 
439  throw unknownProduct_<Ptr<PROD>>(core.id());
440 }
RefCore newRefCore_(ProductID const incomingProductID) const
Definition: PtrRemapper.cc:4
constexpr ProductID id() const noexcept
Definition: RefCore.h:50
template<typename PROD , typename SIZE_TYPE >
art::PtrVector<PROD> art::PtrRemapper::operator() ( PtrVector< PROD > const &  old,
SIZE_TYPE const  offset 
) const

Definition at line 445 of file PtrRemapper.h.

References art::PtrVector< T >::begin(), art::PtrVector< T >::end(), art::PtrRemapperDetail::ContReturner< CONT, PROD, CALLBACK >::operator()(), art::PtrVector< T >::reserve(), and art::PtrVector< T >::size().

447 {
448  PtrVector<PROD> result;
449  result.reserve(old.size());
450  this->operator()(old.begin(),
451  old.end(),
452  std::back_inserter(result),
453  offset); // 3.
454  return result;
455 }
Ptr< PROD > operator()(Ptr< PROD > const &oldPtr, SIZE_TYPE offset) const
template<typename PROD , typename OutIter , typename CONT , typename X , typename OFFSETS >
void art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
OutIter  out,
OFFSETS const &  offsets,
CONT const &  X::*)(PROD const *,
X x 
) const

Definition at line 539 of file PtrRemapper.h.

References in, x, and X.

544 {
545  this->operator()<CONT>(
546  in, out, offsets, [&x](auto& elem) { elem.extractor(x); }); // 10.
547 }
Float_t x
Definition: compare.C:6
ifstream in
Definition: comparison.C:7
template<typename PROD >
art::ProductPtr<PROD> art::PtrRemapper::operator() ( ProductPtr< PROD > const &  oldPtr) const

Definition at line 600 of file PtrRemapper.h.

References art::ProductPtr< T >::id().

601 {
602  if (!oldPtr.id().isValid()) {
603  return {};
604  }
605 
606  auto core = newRefCore_(oldPtr.id());
607  if (core.productGetter()) {
608  return ProductPtr<PROD>{core.id(), core.productGetter()};
609  }
610 
611  throw unknownProduct_<ProductPtr<PROD>>(core.id());
612 }
RefCore newRefCore_(ProductID const incomingProductID) const
Definition: PtrRemapper.cc:4
constexpr ProductID id() const noexcept
Definition: RefCore.h:50
template<typename PROD >
art::ProductPtr<PROD> art::PtrRemapper::operator() ( std::vector< ProductPtr< PROD > const * > const &  in) const

Definition at line 617 of file PtrRemapper.h.

619 {
620  art::ProductPtr<PROD> result{};
621  for (auto const* ptr : in) {
622  result = samePtrAs(remap(*ptr), result);
623  }
624  return result;
625 }
static ProductPtr< PROD > samePtrAs(ProductPtr< PROD > result, ProductPtr< PROD > old)
Definition: PtrRemapper.h:391
template<typename PROD , typename T >
art::ProductPtr<T> art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
ProductPtr< T > const PROD::*  data 
) const

Definition at line 630 of file PtrRemapper.h.

632 {
633  art::ProductPtr<T> result{};
634  for (auto const* ptr : in) {
635  result = samePtrAs(this->operator()(ptr->*data), result);
636  }
637  return result;
638 }
static ProductPtr< PROD > samePtrAs(ProductPtr< PROD > result, ProductPtr< PROD > old)
Definition: PtrRemapper.h:391
template<typename PROD , typename T >
art::ProductPtr<T> art::PtrRemapper::operator() ( std::vector< PROD const * > const &  in,
ProductPtr< T > const &(PROD::*)() const  extractor 
) const

Definition at line 643 of file PtrRemapper.h.

646 {
647  art::ProductPtr<T> result{};
648  for (auto const* ptr : in) {
649  result = samePtrAs(this->operator()((ptr->*extractor)()), result);
650  }
651  return result;
652 }
static ProductPtr< PROD > samePtrAs(ProductPtr< PROD > result, ProductPtr< PROD > old)
Definition: PtrRemapper.h:391
template<typename PROD >
static ProductPtr<PROD> art::PtrRemapper::samePtrAs ( ProductPtr< PROD >  result,
ProductPtr< PROD >  old 
)
inlinestaticprivate

Definition at line 391 of file PtrRemapper.h.

References art::ProductPtr< T >::id(), and art::errors::LogicError.

392  {
393  if (old == ProductPtr<PROD>{} or result == old) {
394  return result;
395  }
397  << "PtrRemapper: cannot create output "
398  << TypeID{typeid(ProductPtr<PROD>)}.className()
399  << "\ndue to conflicting IDs in input ProductPtrs: " << old.id()
400  << " vs. " << result.id() << "\nContact artists@fnal.gov for guidance.\n";
401  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<typename T >
static auto art::PtrRemapper::unknownProduct_ ( ProductID const  id)
inlinestaticprivate

Definition at line 405 of file PtrRemapper.h.

References art::errors::LogicError.

406  {
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";
412  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66

Friends And Related Function Documentation

friend class ProdToProdMapBuilder
friend

Definition at line 384 of file PtrRemapper.h.

Member Data Documentation

cet::exempt_ptr<Event const> art::PtrRemapper::event_ {nullptr}
private

Definition at line 417 of file PtrRemapper.h.

Referenced by art::ProdToProdMapBuilder::getRemapper(), and newRefCore_().

ProdTransMap_t art::PtrRemapper::prodTransMap_ {}
private

Definition at line 416 of file PtrRemapper.h.

Referenced by art::ProdToProdMapBuilder::getRemapper(), and newRefCore_().


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