LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::PtrVectorBase Class Referenceabstract

#include "PtrVectorBase.h"

Inheritance diagram for art::PtrVectorBase:
art::PtrVector< T > art::PtrVector< GenParticle > art::PtrVector< recob::EndPoint2D > art::PtrVector< recob::Hit > art::PtrVector< recob::Seed > art::PtrVector< recob::Track > art::PtrVector< recob::Vertex >

Public Types

using key_type = unsigned long
 
using indices_t = std::vector< key_type >
 
using size_type = indices_t::size_type
 

Public Member Functions

virtual ~PtrVectorBase ()=default
 
bool isNonnull () const noexcept
 
bool isNull () const noexcept
 
bool isAvailable () const
 
ProductID id () const noexcept
 
EDProductGetter const * productGetter () const noexcept
 
void setProductGetter (EDProductGetter const *) noexcept
 
template<typename T >
art::Ptr< T >::key_type key (Ptr< T > const &ptr) const noexcept
 

Protected Member Functions

 PtrVectorBase ()=default
 
void clear ()
 
void swap (PtrVectorBase &)
 
void updateCore (RefCore const &core)
 
bool operator== (PtrVectorBase const &) const noexcept
 

Private Member Functions

void reserve (size_type n)
 
void fillPtrs () const
 
template<typename T >
Ptr< T >::key_type key (Ptr< T > const &ptr) const noexcept
 
virtual void fill_offsets (indices_t &indices)=0
 
virtual void fill_from_offsets (indices_t const &indices) const =0
 
virtual void zeroTransients ()=0
 

Private Attributes

RefCore core_
 
indices_t indicies_
 

Friends

class art::detail::PtrVectorBaseStreamer
 

Detailed Description

Definition at line 19 of file PtrVectorBase.h.

Member Typedef Documentation

Definition at line 22 of file PtrVectorBase.h.

using art::PtrVectorBase::key_type = unsigned long

Definition at line 21 of file PtrVectorBase.h.

using art::PtrVectorBase::size_type = indices_t::size_type

Definition at line 23 of file PtrVectorBase.h.

Constructor & Destructor Documentation

virtual art::PtrVectorBase::~PtrVectorBase ( )
virtualdefault
art::PtrVectorBase::PtrVectorBase ( )
protecteddefault

Member Function Documentation

void art::PtrVectorBase::clear ( )
inlineprotected

Definition at line 98 of file PtrVectorBase.h.

References tmp.

Referenced by art::PtrVector< T >::assign(), and art::PtrVector< T >::clear().

99 {
100  core_ = RefCore{};
101  indices_t tmp;
102  indicies_.swap(tmp); // Free up memory
103 }
Float_t tmp
Definition: plot.C:35
std::vector< key_type > indices_t
Definition: PtrVectorBase.h:22
virtual void art::PtrVectorBase::fill_from_offsets ( indices_t const &  indices) const
privatepure virtual
void art::PtrVectorBase::fillPtrs ( ) const
private

Definition at line 5 of file PtrVectorBase.cc.

References fill_from_offsets(), indicies_, swap(), and tmp.

6 {
7  if (indicies_.size() == 0)
8  return; // Empty or already done.
10 
11  using std::swap;
12  indices_t tmp;
13  swap(indicies_, tmp); // Zero -- finished with these.
14 }
void swap(PtrVectorBase &)
Float_t tmp
Definition: plot.C:35
std::vector< key_type > indices_t
Definition: PtrVectorBase.h:22
virtual void fill_from_offsets(indices_t const &indices) const =0
void swap(lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &a, lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &b)
art::ProductID art::PtrVectorBase::id ( ) const
inlinenoexcept

Definition at line 80 of file PtrVectorBase.h.

Referenced by updateCore().

81 {
82  return core_.id();
83 }
constexpr ProductID id() const noexcept
Definition: RefCore.h:50
bool art::PtrVectorBase::isAvailable ( ) const
inline

Definition at line 74 of file PtrVectorBase.h.

75 {
76  return core_.isAvailable();
77 }
bool isAvailable() const
Definition: RefCore.cc:24
bool art::PtrVectorBase::isNonnull ( ) const
inlinenoexcept

Definition at line 62 of file PtrVectorBase.h.

References art::RefCore::isNonnull().

63 {
64  return core_.isNonnull();
65 }
constexpr bool isNonnull() const noexcept
Definition: RefCore.h:28
bool art::PtrVectorBase::isNull ( ) const
inlinenoexcept

Definition at line 68 of file PtrVectorBase.h.

Referenced by updateCore().

69 {
70  return !isNonnull();
71 }
bool isNonnull() const noexcept
Definition: PtrVectorBase.h:62
template<typename T >
Ptr<T>::key_type art::PtrVectorBase::key ( Ptr< T > const &  ptr) const
privatenoexcept
template<typename T >
art::Ptr<T>::key_type art::PtrVectorBase::key ( Ptr< T > const &  ptr) const
inlinenoexcept

Definition at line 119 of file PtrVectorBase.h.

120 {
121  return ptr.key();
122 }
bool art::PtrVectorBase::operator== ( PtrVectorBase const &  other) const
inlineprotectednoexcept

Definition at line 125 of file PtrVectorBase.h.

References fhicl::other.

Referenced by art::PtrVector< T >::operator==().

126 {
127  return core_ == other.core_;
128 }
art::EDProductGetter const * art::PtrVectorBase::productGetter ( ) const
inlinenoexcept

Definition at line 86 of file PtrVectorBase.h.

Referenced by art::PtrVector< T >::fill_from_offsets().

87 {
88  return core_.productGetter();
89 }
EDProductGetter const * productGetter() const noexcept
Definition: RefCore.cc:41
void art::PtrVectorBase::reserve ( size_type  n)
inlineprivate

Definition at line 106 of file PtrVectorBase.h.

107 {
108  indicies_.reserve(n);
109 }
Char_t n[5]
void art::PtrVectorBase::setProductGetter ( EDProductGetter const *  g)
inlinenoexcept

Definition at line 92 of file PtrVectorBase.h.

93 {
95 }
void setProductGetter(EDProductGetter const *) noexcept
Definition: RefCore.cc:57
void art::PtrVectorBase::swap ( PtrVectorBase other)
inlineprotected

Definition at line 112 of file PtrVectorBase.h.

References core_.

Referenced by fillPtrs(), and art::PtrVector< T >::swap().

113 {
114  core_.swap(other.core_);
115 }
void swap(RefCore &other)
Definition: RefCore.cc:63
void art::PtrVectorBase::updateCore ( RefCore const &  core)
protected

Definition at line 17 of file PtrVectorBase.cc.

References core_, id(), art::RefCore::id(), art::errors::InvalidReference, isNull(), art::RefCore::isNull(), art::RefCore::productGetter(), art::RefCore::productPtr(), art::RefCore::setProductGetter(), and art::RefCore::setProductPtr().

Referenced by art::PtrVector< T >::assign(), art::PtrVector< T >::emplace_back(), art::PtrVector< T >::insert(), art::PtrVector< T >::PtrVector(), and art::PtrVector< T >::push_back().

18 {
19  if (productToBeInserted.isNull()) {
20  throw art::Exception(errors::InvalidReference, "Inconsistency")
21  << "art::PtrVectorBase::updateCore: Ptr has invalid (zero) product ID,\n"
22  "so it cannot be added to a PtrVector. id should be ("
23  << id() << ")\n";
24  }
25  if (isNull()) {
26  core_ = productToBeInserted;
27  return;
28  }
29  if (core_.id() != productToBeInserted.id()) {
30  throw art::Exception(errors::InvalidReference, "Inconsistency")
31  << "art::PtrVectorBase::updateCore: Ptr is inconsistent with\n"
32  "PtrVector. id = ("
33  << productToBeInserted.id() << "), should be (" << core_.id() << ")\n";
34  }
35  if (core_.productGetter() == nullptr &&
36  productToBeInserted.productGetter() != nullptr) {
37  core_.setProductGetter(productToBeInserted.productGetter());
38  }
39  if (core_.productPtr() == nullptr &&
40  productToBeInserted.productPtr() != nullptr) {
41  core_.setProductPtr(productToBeInserted.productPtr());
42  }
43 }
EDProductGetter const * productGetter() const noexcept
Definition: RefCore.cc:41
ProductID id() const noexcept
Definition: PtrVectorBase.h:80
bool isNull() const noexcept
Definition: PtrVectorBase.h:68
void setProductGetter(EDProductGetter const *) noexcept
Definition: RefCore.cc:57
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void const * productPtr() const noexcept
Definition: RefCore.cc:34
void setProductPtr(void const *prodPtr) const noexcept
Definition: RefCore.cc:48
constexpr ProductID id() const noexcept
Definition: RefCore.h:50

Friends And Related Function Documentation

friend class art::detail::PtrVectorBaseStreamer
friend

Definition at line 58 of file PtrVectorBase.h.

Member Data Documentation

RefCore art::PtrVectorBase::core_
private

Definition at line 51 of file PtrVectorBase.h.

Referenced by swap(), and updateCore().

indices_t art::PtrVectorBase::indicies_
mutableprivate

Definition at line 52 of file PtrVectorBase.h.

Referenced by fillPtrs().


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