LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::Assns< L, R, void > Class Template Reference

#include "Assns.h"

Inheritance diagram for art::Assns< L, R, void >:
art::detail::AssnsBase

Public Types

using left_t = L
 
using right_t = R
 
using partner_t = art::Assns< right_t, left_t, void >
 
using assn_t = typename ptrs_t::value_type
 
using const_iterator = typename ptrs_t::const_iterator
 
using size_type = typename ptrs_t::size_type
 

Public Member Functions

 Assns ()
 
 Assns (partner_t const &other)
 
virtual ~Assns ()=default
 
const_iterator begin () const
 
const_iterator end () const
 
assn_t const & operator[] (size_type index) const
 
assn_t const & at (size_type index) const
 
size_type size () const
 
std::string className () const
 
void addSingle (Ptr< left_t > const &left, Ptr< right_t > const &right)
 
template<typename Ls >
void addMany (Ls const &lefts, Ptr< right_t > const &right)
 
template<typename Rs >
void addMany (Ptr< left_t > const &left, Rs const &rights)
 
void swap (art::Assns< L, R, void > &other)
 
std::unique_ptr< EDProductmakePartner (std::type_info const &wanted_wrapper_type) const
 
void aggregate (Assns const &) const
 

Static Public Member Functions

static short Class_Version ()
 

Protected Member Functions

virtual void swap_ (art::Assns< L, R, void > &other)
 
virtual std::unique_ptr< EDProductmakePartner_ (std::type_info const &wanted_wrapper_type) const
 

Private Types

using ptrs_t = std::vector< std::pair< Ptr< left_t >, Ptr< right_t >>>
 
using ptr_data_t = std::vector< std::pair< RefCore, std::size_t >>
 

Private Member Functions

virtual bool left_first () const
 
void fill_transients () override
 
void fill_from_transients () override
 

Private Attributes

ptrs_t ptrs_ {}
 
ptr_data_t ptr_data_1_ {}
 transient More...
 
ptr_data_t ptr_data_2_ {}
 

Friends

class detail::AssnsStreamer
 
class art::Assns< right_t, left_t, void >
 

Detailed Description

template<typename L, typename R>
class art::Assns< L, R, void >

Definition at line 124 of file Assns.h.

Member Typedef Documentation

template<typename L , typename R >
using art::Assns< L, R, void >::assn_t = typename ptrs_t::value_type

Definition at line 135 of file Assns.h.

template<typename L , typename R >
using art::Assns< L, R, void >::const_iterator = typename ptrs_t::const_iterator

Definition at line 136 of file Assns.h.

template<typename L , typename R >
using art::Assns< L, R, void >::left_t = L

Definition at line 126 of file Assns.h.

template<typename L , typename R >
using art::Assns< L, R, void >::partner_t = art::Assns<right_t, left_t, void>

Definition at line 128 of file Assns.h.

template<typename L , typename R >
using art::Assns< L, R, void >::ptr_data_t = std::vector<std::pair<RefCore, std::size_t>>
private

Definition at line 132 of file Assns.h.

template<typename L , typename R >
using art::Assns< L, R, void >::ptrs_t = std::vector<std::pair<Ptr<left_t>, Ptr<right_t>>>
private

Definition at line 131 of file Assns.h.

template<typename L , typename R >
using art::Assns< L, R, void >::right_t = R

Definition at line 127 of file Assns.h.

template<typename L , typename R >
using art::Assns< L, R, void >::size_type = typename ptrs_t::size_type

Definition at line 138 of file Assns.h.

Constructor & Destructor Documentation

template<typename L , typename R >
art::Assns< L, R, void >::Assns ( )
inline

Definition at line 302 of file Assns.h.

303 {}
template<typename L , typename R >
art::Assns< L, R, void >::Assns ( partner_t const &  other)
inline

Definition at line 306 of file Assns.h.

References art::Assns< L, R, D >::size().

307 {
308  ptrs_.reserve(other.ptrs_.size());
309  cet::transform_all(
310  other.ptrs_, std::back_inserter(ptrs_), [](auto const& pr) {
311  using pr_t = typename ptrs_t::value_type;
312  return pr_t{pr.second, pr.first};
313  });
314 }
template<typename L , typename R >
virtual art::Assns< L, R, void >::~Assns ( )
virtualdefault

Member Function Documentation

template<typename L , typename R >
template<typename Ls >
void art::Assns< L, R, void >::addMany ( Ls const &  lefts,
Ptr< right_t > const &  right 
)
inline

Definition at line 370 of file Assns.h.

References art::Assns< L, R, D >::addSingle(), and art::left().

371 {
372  static_assert(std::is_same_v<typename Ls::value_type, art::Ptr<L>>,
373  "\n\nart error: The first argument must be a container whose "
374  "value_type is art::Ptr<L>\n"
375  " corresponding to an Assns<L, R(, D)> object.\n");
376  for (auto const& left : lefts) {
377  addSingle(left, right);
378  }
379 }
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:102
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right)
Definition: Assns.h:361
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:94
template<typename L , typename R >
template<typename Rs >
void art::Assns< L, R, void >::addMany ( Ptr< left_t > const &  left,
Rs const &  rights 
)
inline

Definition at line 384 of file Assns.h.

References art::Assns< L, R, D >::addSingle(), and art::right().

385 {
386  static_assert(std::is_same_v<typename Rs::value_type, art::Ptr<R>>,
387  "\n\nart error: The second argument must be a container whose "
388  "value_type is art::Ptr<R>\n"
389  " corresponding to an Assns<L, R(, D)> object.\n");
390  for (auto const& right : rights) {
391  addSingle(left, right);
392  }
393 }
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:102
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right)
Definition: Assns.h:361
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:94
template<typename L , typename R >
void art::Assns< L, R, void >::addSingle ( Ptr< left_t > const &  left,
Ptr< right_t > const &  right 
)
inline

Definition at line 361 of file Assns.h.

363 {
364  ptrs_.emplace_back(left, right);
365 }
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:102
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:94
template<typename L , typename R >
void art::Assns< L, R, void >::aggregate ( Assns< L, R, void > const &  ) const
inline

Definition at line 174 of file Assns.h.

References fhicl::other.

175  {}
template<typename L , typename R >
art::Assns< L, R, void >::assn_t const & art::Assns< L, R, void >::at ( size_type  index) const
inline

Definition at line 339 of file Assns.h.

340 {
341  return ptrs_.at(index);
342 }
template<typename L , typename R >
art::Assns< L, R, void >::const_iterator art::Assns< L, R, void >::begin ( ) const
inline

Definition at line 318 of file Assns.h.

319 {
320  return ptrs_.begin();
321 }
template<typename L , typename R >
static short art::Assns< L, R, void >::Class_Version ( )
inlinestatic

Definition at line 168 of file Assns.h.

169  {
170  return 11;
171  }
template<typename L , typename R >
std::string art::Assns< L, R, void >::className ( ) const
inline

Definition at line 353 of file Assns.h.

References art::TypeID::className().

354 {
355  TypeID const assns_type{typeid(Assns<L, R, void>)};
356  return assns_type.className();
357 }
template<typename L , typename R >
art::Assns< L, R, void >::const_iterator art::Assns< L, R, void >::end ( void  ) const
inline

Definition at line 325 of file Assns.h.

326 {
327  return ptrs_.end();
328 }
template<typename L , typename R >
void art::Assns< L, R, void >::fill_from_transients ( )
overrideprivatevirtual

Implements art::detail::AssnsBase.

Definition at line 465 of file Assns.h.

466 {
467  if (!ptr_data_1_.empty()) {
468  assert(ptr_data_1_.size() == ptr_data_2_.size() &&
469  ptr_data_2_.size() == ptrs_.size() &&
470  "Assns: internal inconsistency between transient and persistent "
471  "member data.");
472  // Multiple output modules: nothing to do on second and subsequent
473  // calls.
474  return;
475  }
478  l_ref.reserve(ptrs_.size());
479  r_ref.reserve(ptrs_.size());
480  for (auto const& pr : ptrs_) {
481  l_ref.emplace_back(pr.first.refCore(), pr.first.key());
482  r_ref.emplace_back(pr.second.refCore(), pr.second.key());
483  }
484 }
virtual bool left_first() const
Definition: Assns.h:434
std::vector< std::pair< RefCore, std::size_t >> ptr_data_t
Definition: Assns.h:132
ptr_data_t ptr_data_2_
Definition: Assns.h:210
ptr_data_t ptr_data_1_
transient
Definition: Assns.h:209
template<typename L , typename R >
void art::Assns< L, R, void >::fill_transients ( )
overrideprivatevirtual

Implements art::detail::AssnsBase.

Definition at line 443 of file Assns.h.

References util::cbegin(), util::cend(), e, art::Ptr< T >::id(), r, and art::Assns< L, R, D >::swap().

444 {
445  // Precondition: ptr_data_1_.size() = ptr_data_2_.size();
446  ptrs_.clear();
447  ptrs_.reserve(ptr_data_1_.size());
448  ptr_data_t const& l_ref = left_first() ? ptr_data_1_ : ptr_data_2_;
449  ptr_data_t const& r_ref = left_first() ? ptr_data_2_ : ptr_data_1_;
450 
451  for (auto l = cbegin(l_ref), e = cend(l_ref), r = cbegin(r_ref); l != e;
452  ++l, ++r) {
453  ptrs_.emplace_back(
454  Ptr<left_t>{l->first.id(), l->second, l->first.productGetter()},
455  Ptr<right_t>{r->first.id(), r->second, r->first.productGetter()});
456  }
457  // Empty persistent representation.
458  ptr_data_t tmp1, tmp2;
459  ptr_data_1_.swap(tmp1);
460  ptr_data_2_.swap(tmp2);
461 }
TRandom r
Definition: spectrum.C:23
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:93
virtual bool left_first() const
Definition: Assns.h:434
std::vector< std::pair< RefCore, std::size_t >> ptr_data_t
Definition: Assns.h:132
decltype(auto) constexpr cbegin(T &&obj)
ADL-aware version of std::cbegin.
Definition: StdUtils.h:85
ptr_data_t ptr_data_2_
Definition: Assns.h:210
Float_t e
Definition: plot.C:35
ptr_data_t ptr_data_1_
transient
Definition: Assns.h:209
template<typename L , typename R >
bool art::Assns< L, R, void >::left_first ( ) const
inlineprivatevirtual

Definition at line 434 of file Assns.h.

435 {
436  static bool const lf_s = (art::TypeID{typeid(left_t)}.friendlyClassName() <
437  art::TypeID{typeid(right_t)}.friendlyClassName());
438  return lf_s;
439 }
template<typename L , typename R >
std::unique_ptr< art::EDProduct > art::Assns< L, R, void >::makePartner ( std::type_info const &  wanted_wrapper_type) const
inline

Definition at line 404 of file Assns.h.

References art::Assns< L, R, D >::makePartner_().

406 {
407  return makePartner_(wanted_wrapper_type);
408 }
virtual std::unique_ptr< EDProduct > makePartner_(std::type_info const &wanted_wrapper_type) const
Definition: Assns.h:422
template<typename L , typename R >
std::unique_ptr< art::EDProduct > art::Assns< L, R, void >::makePartner_ ( std::type_info const &  wanted_wrapper_type) const
protectedvirtual

Definition at line 422 of file Assns.h.

References art::detail::throwPartnerException().

424 {
425  if (wanted_wrapper_type != typeid(Wrapper<partner_t>)) {
426  detail::throwPartnerException(typeid(*this), wanted_wrapper_type);
427  }
428  return std::make_unique<Wrapper<partner_t>>(
429  std::make_unique<partner_t>(*this));
430 }
void throwPartnerException(std::type_info const &generator, std::type_info const &wanted_wrapper_type)
template<typename L , typename R >
art::Assns< L, R, void >::assn_t const & art::Assns< L, R, void >::operator[] ( size_type  index) const
inline

Definition at line 332 of file Assns.h.

333 {
334  return ptrs_[index];
335 }
template<typename L , typename R >
art::Assns< L, R, void >::size_type art::Assns< L, R, void >::size ( void  ) const
inline

Definition at line 346 of file Assns.h.

347 {
348  return ptrs_.size();
349 }
template<typename L , typename R >
void art::Assns< L, R, void >::swap ( art::Assns< L, R, void > &  other)
inline

Definition at line 397 of file Assns.h.

References art::Assns< L, R, D >::swap_().

398 {
399  swap_(other);
400 }
virtual void swap_(art::Assns< L, R, void > &other)
Definition: Assns.h:412
template<typename L , typename R >
void art::Assns< L, R, void >::swap_ ( art::Assns< L, R, void > &  other)
inlineprotectedvirtual

Definition at line 412 of file Assns.h.

References ptr_data_1_, ptr_data_2_, ptrs_, and art::swap().

413 {
414  using std::swap;
415  swap(ptrs_, other.ptrs_);
416  swap(ptr_data_1_, other.ptr_data_1_);
417  swap(ptr_data_2_, other.ptr_data_2_);
418 }
void swap(art::Assns< L, R, void > &other)
Definition: Assns.h:397
void swap(lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &a, lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &b)
ptr_data_t ptr_data_2_
Definition: Assns.h:210
ptr_data_t ptr_data_1_
transient
Definition: Assns.h:209

Friends And Related Function Documentation

template<typename L , typename R >
friend class art::Assns< right_t, left_t, void >
friend

Definition at line 185 of file Assns.h.

template<typename L , typename R >
friend class detail::AssnsStreamer
friend

Definition at line 184 of file Assns.h.

Member Data Documentation

template<typename L , typename R >
ptr_data_t art::Assns< L, R, void >::ptr_data_1_ {}
private

transient

Definition at line 209 of file Assns.h.

Referenced by swap_().

template<typename L , typename R >
ptr_data_t art::Assns< L, R, void >::ptr_data_2_ {}
private

Definition at line 210 of file Assns.h.

Referenced by swap_().

template<typename L , typename R >
ptrs_t art::Assns< L, R, void >::ptrs_ {}
private

Definition at line 208 of file Assns.h.

Referenced by swap_().


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