CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::PtrVectorBase Class Reference

#include <PtrVectorBase.h>

Inheritance diagram for edm::PtrVectorBase:
edm::PtrVector< T > edm::PtrVector< CaloCluster > edm::PtrVector< CaloTower > edm::PtrVector< Candidate > edm::PtrVector< reco::BaseTau > edm::PtrVector< reco::BasicJet > edm::PtrVector< reco::CaloCluster > edm::PtrVector< reco::CaloJet > edm::PtrVector< reco::Candidate > edm::PtrVector< reco::CastorJetID > edm::PtrVector< reco::FFTBasicJet > edm::PtrVector< reco::FFTCaloJet > edm::PtrVector< reco::FFTGenJet > edm::PtrVector< reco::FFTJPTJet > edm::PtrVector< reco::FFTPFJet > edm::PtrVector< reco::FFTTrackJet > edm::PtrVector< reco::GenJet > edm::PtrVector< reco::GsfElectron > edm::PtrVector< reco::Jet > edm::PtrVector< reco::JetID > edm::PtrVector< reco::JPTJet > edm::PtrVector< reco::MET > edm::PtrVector< reco::Muon > edm::PtrVector< reco::PFCandidate > edm::PtrVector< reco::PFClusterJet > edm::PtrVector< reco::PFJet > edm::PtrVector< reco::PFTau > edm::PtrVector< reco::Photon > edm::PtrVector< reco::reco::PFCluster > edm::PtrVector< reco::TrackJet >

Public Types

typedef unsigned long key_type
 
typedef key_type size_type
 

Public Member Functions

size_type capacity () const
 Capacity of the RefVector. More...
 
void clear ()
 Clear the PtrVector. More...
 
bool empty () const
 Is the RefVector empty. More...
 
bool hasCache () const
 
bool hasProductCache () const
 
ProductID id () const
 Accessor for product ID. More...
 
bool isAvailable () const
 
bool isNonnull () const
 Checks for non-null. More...
 
bool isNull () const
 Checks for null. More...
 
bool isTransient () const
 
bool operator! () const
 Checks for null. More...
 
bool operator== (PtrVectorBase const &iRHS) const
 
void const * product () const
 
EDProductGetter const * productGetter () const
 Accessor for product getter. More...
 
 PtrVectorBase (ProductID const &productID, void const *prodPtr=0, EDProductGetter const *prodGetter=0)
 
void reserve (size_type n)
 Reserve space for RefVector. More...
 
void setProductGetter (EDProductGetter *iGetter) const
 
size_type size () const
 Size of the RefVector. More...
 
virtual ~PtrVectorBase ()
 

Protected Member Functions

template<typename TPtr >
TPtr makePtr (unsigned long iIndex) const
 
template<typename TPtr >
TPtr makePtr (std::vector< void const * >::const_iterator const iIt) const
 
 PtrVectorBase ()
 
void push_back_base (RefCore const &core, key_type iKey, void const *iData)
 
void swap (PtrVectorBase &other)
 swap More...
 
std::vector< void const * >
::const_iterator 
void_begin () const
 
std::vector< void const * >
::const_iterator 
void_end () const
 

Private Member Functions

void getProduct_ () const
 
virtual std::type_info const & typeInfo () const
 

Private Attributes

std::vector< void const * > cachedItems_
 
RefCore core_
 
std::vector< key_typeindicies_
 

Detailed Description

Definition at line 32 of file PtrVectorBase.h.

Member Typedef Documentation

typedef unsigned long edm::PtrVectorBase::key_type

Definition at line 35 of file PtrVectorBase.h.

Definition at line 36 of file PtrVectorBase.h.

Constructor & Destructor Documentation

edm::PtrVectorBase::PtrVectorBase ( ProductID const &  productID,
void const *  prodPtr = 0,
EDProductGetter const *  prodGetter = 0 
)
inlineexplicit

Definition at line 38 of file PtrVectorBase.h.

39  :
40  core_(productID, prodPtr, prodGetter, false), indicies_() {}
std::vector< key_type > indicies_
PtrVectorBase::~PtrVectorBase ( )
virtual

Definition at line 37 of file PtrVectorBase.cc.

37  {
38  }
PtrVectorBase::PtrVectorBase ( )
protected

Definition at line 34 of file PtrVectorBase.cc.

34  {
35  }

Member Function Documentation

size_type edm::PtrVectorBase::capacity ( ) const
inline

Capacity of the RefVector.

Definition at line 76 of file PtrVectorBase.h.

References indicies_.

76 {return indicies_.capacity();}
std::vector< key_type > indicies_
void edm::PtrVectorBase::clear ( void  )
inline
bool edm::PtrVectorBase::empty ( ) const
inline
void PtrVectorBase::getProduct_ ( ) const
private

Definition at line 76 of file PtrVectorBase.cc.

References cachedItems_, edm::hlt::Exception, edm::WrapperBase::fillPtrVector(), edm::EDProductGetter::getIt(), hasCache(), id(), indicies_, edm::errors::InvalidReference, edm::errors::LogicError, product(), productGetter(), and typeInfo().

Referenced by void_begin(), and void_end().

76  {
77  if(hasCache()) {
78  return;
79  }
80  if(indicies_.size() == 0) {
81  return;
82  }
83  if(0 == productGetter()) {
84  throw Exception(errors::LogicError) << "Tried to get data for a PtrVector which has no EDProductGetter\n";
85  }
86  WrapperBase const* product = productGetter()->getIt(id());
87 
88  if(product == nullptr) {
89  throw Exception(errors::InvalidReference) << "Asked for data from a PtrVector which refers to a non-existent product which id " << id() << "\n";
90  }
91  product->fillPtrVector(typeInfo(), indicies_, cachedItems_);
92  }
virtual std::type_info const & typeInfo() const
ProductID id() const
Accessor for product ID.
Definition: PtrVectorBase.h:56
std::vector< key_type > indicies_
virtual WrapperBase const * getIt(ProductID const &) const =0
std::vector< void const * > cachedItems_
bool hasCache() const
Definition: PtrVectorBase.h:61
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: PtrVectorBase.h:59
void const * product() const
Definition: PtrVectorBase.h:92
bool edm::PtrVectorBase::hasCache ( ) const
inline

Definition at line 61 of file PtrVectorBase.h.

References cachedItems_.

Referenced by getProduct_(), and makePtr().

61 { return !cachedItems_.empty(); }
std::vector< void const * > cachedItems_
bool edm::PtrVectorBase::hasProductCache ( ) const
inline

Definition at line 63 of file PtrVectorBase.h.

References core_, and edm::RefCore::productPtr().

63 { return 0 == core_.productPtr(); }
void const * productPtr() const
Definition: RefCore.h:32
ProductID edm::PtrVectorBase::id ( void  ) const
inline

Accessor for product ID.

Definition at line 56 of file PtrVectorBase.h.

References core_, and edm::RefCore::id().

Referenced by getProduct_(), pf2pat::TopProjectorAlgo< Top, Bottom >::printAncestors(), and pf2pat::TopProjectorAlgo< Top, Bottom >::processCollection().

56 {return core_.id();}
ProductID id() const
Definition: RefCore.h:29
bool edm::PtrVectorBase::isAvailable ( ) const
inline

True if the data is in memory or is available in the Event No type checking is done.

Definition at line 67 of file PtrVectorBase.h.

References core_, and edm::RefCore::isAvailable().

67 { return core_.isAvailable(); }
bool isAvailable() const
Definition: RefCore.cc:112
bool edm::PtrVectorBase::isNonnull ( ) const
inline

Checks for non-null.

Definition at line 50 of file PtrVectorBase.h.

References core_, and edm::RefCore::isNonnull().

Referenced by isNull().

50 { return core_.isNonnull(); }
bool isNonnull() const
Definition: RefCore.h:43
bool edm::PtrVectorBase::isNull ( ) const
inline
bool edm::PtrVectorBase::isTransient ( ) const
inline

Definition at line 90 of file PtrVectorBase.h.

References core_, and edm::RefCore::isTransient().

Referenced by makePtr().

90 {return core_.isTransient();}
bool isTransient() const
Definition: RefCore.h:69
template<typename TPtr >
TPtr edm::PtrVectorBase::makePtr ( unsigned long  iIndex) const
inlineprotected

Definition at line 114 of file PtrVectorBase.h.

References cachedItems_, hasCache(), indicies_, isTransient(), and productGetter().

114  {
115  if (isTransient()) {
116  return TPtr(reinterpret_cast<typename TPtr::value_type const*>(cachedItems_[iIndex]),
117  indicies_[iIndex]);
118  }
119  if (hasCache()) {
120  return TPtr(this->id(),
121  reinterpret_cast<typename TPtr::value_type const*>(cachedItems_[iIndex]),
122  indicies_[iIndex]);
123  }
124  return TPtr(this->id(), indicies_[iIndex], productGetter());
125  }
bool isTransient() const
Definition: PtrVectorBase.h:90
std::vector< key_type > indicies_
std::vector< void const * > cachedItems_
bool hasCache() const
Definition: PtrVectorBase.h:61
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: PtrVectorBase.h:59
template<typename TPtr >
TPtr edm::PtrVectorBase::makePtr ( std::vector< void const * >::const_iterator const  iIt) const
inlineprotected

Definition at line 128 of file PtrVectorBase.h.

References cachedItems_, hasCache(), indicies_, isTransient(), and productGetter().

128  {
129  if (isTransient()) {
130  return TPtr(reinterpret_cast<typename TPtr::value_type const*>(*iIt),
131  indicies_[iIt - cachedItems_.begin()]);
132  }
133  if (hasCache()) {
134  return TPtr(this->id(),
135  reinterpret_cast<typename TPtr::value_type const*>(*iIt),
136  indicies_[iIt - cachedItems_.begin()]);
137  }
138  return TPtr(this->id(), indicies_[iIt - cachedItems_.begin()], productGetter());
139  }
bool isTransient() const
Definition: PtrVectorBase.h:90
std::vector< key_type > indicies_
std::vector< void const * > cachedItems_
bool hasCache() const
Definition: PtrVectorBase.h:61
EDProductGetter const * productGetter() const
Accessor for product getter.
Definition: PtrVectorBase.h:59
bool edm::PtrVectorBase::operator! ( ) const
inline

Checks for null.

Definition at line 53 of file PtrVectorBase.h.

References isNull().

53 {return isNull();}
bool isNull() const
Checks for null.
Definition: PtrVectorBase.h:46
bool PtrVectorBase::operator== ( PtrVectorBase const &  iRHS) const

Definition at line 95 of file PtrVectorBase.cc.

References core_, cond::serialization::equal(), and indicies_.

95  {
96  if(core_ != iRHS.core_) {
97  return false;
98  }
99  if(indicies_.size() != iRHS.indicies_.size()){
100  return false;
101  }
102  return std::equal(indicies_.begin(),
103  indicies_.end(),
104  iRHS.indicies_.begin());
105  return true;
106  }
bool equal(const T &first, const T &second)
Definition: Equal.h:34
std::vector< key_type > indicies_
void const* edm::PtrVectorBase::product ( ) const
inline

Definition at line 92 of file PtrVectorBase.h.

Referenced by getProduct_().

92  {
93  return 0;
94  }
EDProductGetter const* edm::PtrVectorBase::productGetter ( ) const
inline

Accessor for product getter.

Definition at line 59 of file PtrVectorBase.h.

References core_, and edm::RefCore::productGetter().

Referenced by getProduct_(), and makePtr().

59 {return core_.productGetter();}
EDProductGetter const * productGetter() const
Definition: RefCore.h:53
void PtrVectorBase::push_back_base ( RefCore const &  core,
key_type  iKey,
void const *  iData 
)
protected

Definition at line 57 of file PtrVectorBase.cc.

References cachedItems_, core_, indicies_, and edm::RefCore::pushBackItem().

Referenced by edm::PtrVector< reco::FFTJPTJet >::push_back().

57  {
58  core_.pushBackItem(core, false);
59  //Did we already push a 'non-cached' Ptr into the container or is this a 'non-cached' Ptr?
60  if(indicies_.size() == cachedItems_.size()) {
61  if(iData) {
62  cachedItems_.push_back(iData);
63  } else if(key_traits<key_type>::value == iKey) {
64  cachedItems_.push_back(0);
65  } else {
66  cachedItems_.clear();
67  }
68  }
69  indicies_.push_back(iKey);
70  }
void pushBackItem(RefCore const &productToBeInserted, bool checkPointer)
Definition: RefCore.cc:133
std::vector< key_type > indicies_
std::vector< void const * > cachedItems_
void edm::PtrVectorBase::reserve ( size_type  n)
inline

Reserve space for RefVector.

Definition at line 86 of file PtrVectorBase.h.

References cachedItems_, and indicies_.

86 {indicies_.reserve(n); cachedItems_.reserve(n);}
std::vector< key_type > indicies_
std::vector< void const * > cachedItems_
void edm::PtrVectorBase::setProductGetter ( EDProductGetter iGetter) const
inline

Definition at line 88 of file PtrVectorBase.h.

References core_, and edm::RefCore::setProductGetter().

88 { core_.setProductGetter(iGetter); }
void setProductGetter(EDProductGetter const *prodGetter) const
Definition: RefCore.cc:118
size_type edm::PtrVectorBase::size ( void  ) const
inline
void PtrVectorBase::swap ( PtrVectorBase other)
protected

swap

Definition at line 50 of file PtrVectorBase.cc.

References cachedItems_, core_, indicies_, and edm::RefCore::swap().

Referenced by edm::PtrVector< reco::FFTJPTJet >::swap().

50  {
51  core_.swap(other.core_);
52  indicies_.swap(other.indicies_);
53  cachedItems_.swap(other.cachedItems_);
54  }
void swap(RefCore &)
Definition: RefCore.h:116
std::vector< key_type > indicies_
std::vector< void const * > cachedItems_
virtual std::type_info const& edm::PtrVectorBase::typeInfo ( ) const
inlineprivatevirtual
std::vector<void const*>::const_iterator edm::PtrVectorBase::void_begin ( ) const
inlineprotected

Definition at line 104 of file PtrVectorBase.h.

References cachedItems_, and getProduct_().

Referenced by edm::PtrVector< reco::FFTJPTJet >::begin().

104  {
105  getProduct_();
106  return cachedItems_.begin();
107  }
void getProduct_() const
std::vector< void const * > cachedItems_
std::vector<void const*>::const_iterator edm::PtrVectorBase::void_end ( ) const
inlineprotected

Definition at line 108 of file PtrVectorBase.h.

References cachedItems_, and getProduct_().

Referenced by edm::PtrVector< reco::FFTJPTJet >::end().

108  {
109  getProduct_();
110  return cachedItems_.end();
111  }
void getProduct_() const
std::vector< void const * > cachedItems_

Member Data Documentation

std::vector<void const*> edm::PtrVectorBase::cachedItems_
mutableprivate
RefCore edm::PtrVectorBase::core_
private
std::vector<key_type> edm::PtrVectorBase::indicies_
private