CMS 3D CMS Logo

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

#include <RefCore.h>

Public Member Functions

WrapperBase const * getProductPtr (std::type_info const &type, EDProductGetter const *prodGetter) const
 
WrapperBase const * getThinnedProductPtr (std::type_info const &type, unsigned int &thinnedKey, EDProductGetter const *prodGetter) const
 
ProductID id () const
 
bool isAvailable () const
 
bool isNonnull () const
 
bool isNull () const
 
bool isThinnedAvailable (unsigned int thinnedKey, EDProductGetter const *prodGetter) const
 
bool isTransient () const
 
int isTransientInt () const
 
void nullPointerForTransientException (std::type_info const &type) const
 
bool operator! () const
 
RefCoreoperator= (RefCore const &)
 
RefCoreoperator= (RefCore &&)=default
 
EDProductGetter const * productGetter () const
 
void productNotFoundException (std::type_info const &type) const
 
void const * productPtr () const
 
void pushBackItem (RefCore const &productToBeInserted, bool checkPointer)
 
void pushBackRefItem (RefCore const &productToBeInserted)
 
 RefCore ()
 
 RefCore (ProductID const &theId, void const *prodPtr, EDProductGetter const *prodGetter, bool transient)
 
 RefCore (RefCore const &)
 
 RefCore (RefCore &&iOther)
 
void setProductGetter (EDProductGetter const *prodGetter) const
 
void setProductPtr (void const *prodPtr) const
 
void swap (RefCore &)
 
WrapperBase const * tryToGetProductPtr (std::type_info const &type, EDProductGetter const *prodGetter) const
 
bool tryToSetProductPtrForFirstTime (void const *prodPtr) const
 
void wrongTypeException (std::type_info const &expectedType, std::type_info const &actualType) const
 

Private Member Functions

bool cachePtrIsInvalid () const
 
 RefCore (void const *iCache, ProcessIndex iProcessIndex, ProductIndex iProductIndex)
 
void setCacheIsProductGetter (EDProductGetter const *iGetter) const
 
void setCacheIsProductPtr (const void *iItem) const
 
void setId (ProductID const &iId)
 
void setTransient ()
 

Private Attributes

std::atomic< void const * > cachePtr_
 
ProcessIndex processIndex_
 
ProductIndex productIndex_
 

Friends

class RefCoreWithIndex
 

Detailed Description

Definition at line 23 of file RefCore.h.

Constructor & Destructor Documentation

edm::RefCore::RefCore ( )
inline

Definition at line 28 of file RefCore.h.

ProductIndex productIndex_
Definition: RefCore.h:132
ProcessIndex processIndex_
Definition: RefCore.h:131
std::atomic< void const * > cachePtr_
Definition: RefCore.h:122
edm::RefCore::RefCore ( ProductID const &  theId,
void const *  prodPtr,
EDProductGetter const *  prodGetter,
bool  transient 
)

Definition at line 34 of file RefCore.cc.

References setCacheIsProductGetter(), and setTransient().

34  :
35  cachePtr_(prodPtr),
36  processIndex_(theId.processIndex()),
37  productIndex_(theId.productIndex())
38  {
39  if(transient) {
40  setTransient();
41  }
42  if(prodPtr==nullptr && prodGetter!=nullptr) {
43  setCacheIsProductGetter(prodGetter);
44  }
45  }
ProductIndex productIndex_
Definition: RefCore.h:132
ProcessIndex processIndex_
Definition: RefCore.h:131
std::atomic< void const * > cachePtr_
Definition: RefCore.h:122
void setCacheIsProductGetter(EDProductGetter const *iGetter) const
Definition: RefCore.h:113
void setTransient()
Definition: RefCore.h:111
edm::RefCore::RefCore ( RefCore const &  iOther)

Definition at line 47 of file RefCore.cc.

47  :
48  cachePtr_(iOther.cachePtr_.load()),
49  processIndex_(iOther.processIndex_),
50  productIndex_(iOther.productIndex_) {}
ProductIndex productIndex_
Definition: RefCore.h:132
ProcessIndex processIndex_
Definition: RefCore.h:131
std::atomic< void const * > cachePtr_
Definition: RefCore.h:122
edm::RefCore::RefCore ( RefCore &&  iOther)
inline

Definition at line 37 of file RefCore.h.

37  : cachePtr_(iOther.cachePtr_.load()), processIndex_(iOther.processIndex_),
38  productIndex_(iOther.productIndex_) {}
ProductIndex productIndex_
Definition: RefCore.h:132
ProcessIndex processIndex_
Definition: RefCore.h:131
std::atomic< void const * > cachePtr_
Definition: RefCore.h:122
edm::RefCore::RefCore ( void const *  iCache,
ProcessIndex  iProcessIndex,
ProductIndex  iProductIndex 
)
inlineprivate

Definition at line 108 of file RefCore.h.

108  :
109  cachePtr_(iCache), processIndex_(iProcessIndex), productIndex_(iProductIndex) {}
ProductIndex productIndex_
Definition: RefCore.h:132
ProcessIndex processIndex_
Definition: RefCore.h:131
std::atomic< void const * > cachePtr_
Definition: RefCore.h:122

Member Function Documentation

bool edm::RefCore::cachePtrIsInvalid ( ) const
inlineprivate

Definition at line 115 of file RefCore.h.

References cachePtr_, and edm::refcoreimpl::kCacheIsProductPtrMask.

Referenced by getProductPtr(), pushBackItem(), and tryToGetProductPtr().

115 { return 0 == (reinterpret_cast<std::uintptr_t>(cachePtr_.load()) & refcoreimpl::kCacheIsProductPtrMask); }
const std::uintptr_t kCacheIsProductPtrMask
std::atomic< void const * > cachePtr_
Definition: RefCore.h:122
WrapperBase const * edm::RefCore::getProductPtr ( std::type_info const &  type,
EDProductGetter const *  prodGetter 
) const

Definition at line 60 of file RefCore.cc.

References assert(), cachePtrIsInvalid(), edm::WrapperBase::dynamicTypeInfo(), edm::EDProductGetter::getIt(), id(), isTransient(), edm::ProductID::isValid(), productNotFoundException(), throwInvalidRefFromNoCache(), throwInvalidRefFromNullOrInvalidRef(), and wrongTypeException().

Referenced by edm::refcore::getProduct_(), edm::RefCoreWithIndex::getProductPtr(), and edm::refcore::getProductWithCoreFromRef_().

60  {
61  // The following invariant would be nice to establish in all
62  // constructors, but we can not be sure that the context in which
63  // EDProductGetter::instance() is called will be one where a
64  // non-null pointer is returned. The biggest question in the
65  // various times at which Root makes RefCore instances, and how
66  // old ones might be recycled.
67  //
68  // If our ProductID is non-null, we must have a way to get at the
69  // product (unless it has been dropped). This means either we
70  // already have the pointer to the product, or we have a valid
71  // EDProductGetter to use.
72  //
73  // assert(!id_.isValid() || productGetter() || prodPtr_);
74 
75  ProductID tId = id();
76  assert (!isTransient());
77  if (!tId.isValid()) {
79  }
80 
81  //if (productPtr() == 0 && productGetter() == 0) {
82  if (cachePtrIsInvalid()) {
83  throwInvalidRefFromNoCache(TypeID(type),tId);
84  }
85  WrapperBase const* product = prodGetter->getIt(tId);
86  if (product == nullptr) {
88  }
89  if(!(type == product->dynamicTypeInfo())) {
90  wrongTypeException(type, product->dynamicTypeInfo());
91  }
92  return product;
93  }
type
Definition: HCALResponse.h:21
assert(m_qm.get())
bool cachePtrIsInvalid() const
Definition: RefCore.h:115
void productNotFoundException(std::type_info const &type) const
Definition: RefCore.cc:140
static void throwInvalidRefFromNullOrInvalidRef(const edm::TypeID &id)
Definition: RefCore.cc:9
ProductID id() const
Definition: RefCore.h:42
bool isTransient() const
Definition: RefCore.h:99
static void throwInvalidRefFromNoCache(const edm::TypeID &id, edm::ProductID const &prodID)
Definition: RefCore.cc:19
void wrongTypeException(std::type_info const &expectedType, std::type_info const &actualType) const
Definition: RefCore.cc:150
WrapperBase const * edm::RefCore::getThinnedProductPtr ( std::type_info const &  type,
unsigned int &  thinnedKey,
EDProductGetter const *  prodGetter 
) const

Definition at line 114 of file RefCore.cc.

References edm::WrapperBase::dynamicTypeInfo(), edm::EDProductGetter::getThinnedProduct(), id(), productNotFoundException(), and wrongTypeException().

Referenced by edm::refcore::getThinnedProduct_().

114  {
115 
116  ProductID tId = id();
117  WrapperBase const* product = prodGetter->getThinnedProduct(tId, thinnedKey);
118 
119  if (product == nullptr) {
121  }
122  if(!(type == product->dynamicTypeInfo())) {
123  wrongTypeException(type, product->dynamicTypeInfo());
124  }
125  return product;
126  }
type
Definition: HCALResponse.h:21
void productNotFoundException(std::type_info const &type) const
Definition: RefCore.cc:140
ProductID id() const
Definition: RefCore.h:42
void wrongTypeException(std::type_info const &expectedType, std::type_info const &actualType) const
Definition: RefCore.cc:150
ProductID edm::RefCore::id ( ) const
inline
bool edm::RefCore::isAvailable ( ) const

Definition at line 168 of file RefCore.cc.

References id(), edm::ProductID::isValid(), productGetter(), and productPtr().

Referenced by edm::PtrVectorBase::isAvailable(), edm::RefCoreWithIndex::isAvailable(), edm::RefVector< C, T, F >::isAvailable(), and edm::RefProd< reco::CastorEgammaCollection >::isAvailable().

168  {
169  ProductID tId = id();
170  //If another thread changes the cache, it will change a non-null productGetter
171  // into a null productGeter but productPtr will be non-null
172  // Therefore reading productGetter() first is the safe order
173  auto prodGetter = productGetter();
174  auto prodPtr = productPtr();
175  return prodPtr != nullptr || (tId.isValid() && prodGetter != nullptr && prodGetter->getIt(tId) != nullptr);
176  }
void const * productPtr() const
Definition: RefCore.h:45
EDProductGetter const * productGetter() const
Definition: RefCore.h:77
ProductID id() const
Definition: RefCore.h:42
bool edm::RefCore::isNonnull ( ) const
inline
bool edm::RefCore::isNull ( ) const
inline

Definition at line 64 of file RefCore.h.

References isNonnull().

Referenced by operator!(), pushBackItem(), and pushBackRefItem().

64 {return !isNonnull(); }
bool isNonnull() const
Definition: RefCore.h:67
bool edm::RefCore::isThinnedAvailable ( unsigned int  thinnedKey,
EDProductGetter const *  prodGetter 
) const

Definition at line 129 of file RefCore.cc.

References edm::EDProductGetter::getThinnedProduct(), id(), edm::ProductID::isValid(), and productPtr().

Referenced by edm::refitem::IsThinnedAvailableImpl< C, unsigned int >::isThinnedAvailable_().

129  {
130  ProductID tId = id();
131  if(!tId.isValid() || prodGetter == nullptr) {
132  //another thread may have changed it
133  return nullptr != productPtr();
134  }
135  WrapperBase const* product = prodGetter->getThinnedProduct(tId, thinnedKey);
136  return product != nullptr;
137  }
void const * productPtr() const
Definition: RefCore.h:45
ProductID id() const
Definition: RefCore.h:42
bool edm::RefCore::isTransient ( ) const
inline
int edm::RefCore::isTransientInt ( ) const
inline

Definition at line 101 of file RefCore.h.

References isTransient().

101 {return isTransient() ? 1 : 0;}
bool isTransient() const
Definition: RefCore.h:99
void edm::RefCore::nullPointerForTransientException ( std::type_info const &  type) const

Definition at line 160 of file RefCore.cc.

References Exception, and edm::errors::InvalidReference.

Referenced by edm::getProduct(), edm::getProductWithCoreFromRef(), edm::getThinnedProduct(), edm::RefCoreWithIndex::nullPointerForTransientException(), and edm::tryToGetProductWithCoreFromRef().

160  {
162  << "RefCore: A request to resolve a transient reference to a product of type: "
163  << TypeID(type)
164  << "\ncan not be satisfied because the pointer to the product is null.\n";
165  }
type
Definition: HCALResponse.h:21
bool edm::RefCore::operator! ( ) const
inline

Definition at line 70 of file RefCore.h.

References isNull().

70 {return isNull();}
bool isNull() const
Definition: RefCore.h:64
RefCore & edm::RefCore::operator= ( RefCore const &  iOther)

Definition at line 52 of file RefCore.cc.

References cachePtr_, processIndex_, and productIndex_.

52  {
53  cachePtr_ = iOther.cachePtr_.load();
54  processIndex_ = iOther.processIndex_;
55  productIndex_ = iOther.productIndex_;
56  return *this;
57  }
ProductIndex productIndex_
Definition: RefCore.h:132
ProcessIndex processIndex_
Definition: RefCore.h:131
std::atomic< void const * > cachePtr_
Definition: RefCore.h:122
RefCore& edm::RefCore::operator= ( RefCore &&  )
default
EDProductGetter const* edm::RefCore::productGetter ( ) const
inline
void edm::RefCore::productNotFoundException ( std::type_info const &  type) const

Definition at line 140 of file RefCore.cc.

References Exception, id(), and edm::errors::ProductNotFound.

Referenced by edm::Ptr< PileUpPFCandidate >::getData_(), getProductPtr(), getThinnedProductPtr(), and edm::RefCoreWithIndex::productNotFoundException().

140  {
142  << "RefCore: A request to resolve a reference to a product of type '"
143  << TypeID(type)
144  << "' with ProductID '" << id() << "'"
145  << "\ncan not be satisfied because the product cannot be found."
146  << "\nProbably the branch containing the product is not stored in the input file.\n";
147  }
type
Definition: HCALResponse.h:21
ProductID id() const
Definition: RefCore.h:42
void const* edm::RefCore::productPtr ( ) const
inline
void edm::RefCore::pushBackItem ( RefCore const &  productToBeInserted,
bool  checkPointer 
)

Definition at line 193 of file RefCore.cc.

References cachePtrIsInvalid(), Exception, id(), edm::errors::InvalidReference, isNonnull(), isNull(), isTransient(), productGetter(), productPtr(), setId(), setProductGetter(), setProductPtr(), and setTransient().

Referenced by edm::PtrVectorBase::push_back_base(), edm::RefCoreWithIndex::pushBackItem(), and reco::TrackExtraBase::setHits().

193  {
194  if (productToBeInserted.isNull() && !productToBeInserted.isTransient()) {
195  throw edm::Exception(errors::InvalidReference,"Inconsistency")
196  << "RefCore::pushBackItem: Ref or Ptr has invalid (zero) product ID, so it cannot be added to RefVector (PtrVector). "
197  << "id should be (" << id() << ")\n";
198  }
199  if (isNonnull()) {
200  if (isTransient() != productToBeInserted.isTransient()) {
201  if (productToBeInserted.isTransient()) {
202  throw edm::Exception(errors::InvalidReference,"Inconsistency")
203  << "RefCore::pushBackItem: Transient Ref or Ptr cannot be added to persistable RefVector (PtrVector). "
204  << "id should be (" << id() << ")\n";
205  } else {
206  throw edm::Exception(errors::InvalidReference,"Inconsistency")
207  << "RefCore::pushBackItem: Persistable Ref or Ptr cannot be added to transient RefVector (PtrVector). "
208  << "id is (" << productToBeInserted.id() << ")\n";
209  }
210  }
211  if (!productToBeInserted.isTransient() && id() != productToBeInserted.id()) {
212  throw edm::Exception(errors::InvalidReference,"Inconsistency")
213  << "RefCore::pushBackItem: Ref or Ptr is inconsistent with RefVector (PtrVector)"
214  << "id = (" << productToBeInserted.id() << ") should be (" << id() << ")\n";
215  }
216  if (productToBeInserted.isTransient() && checkPointer && productToBeInserted.isNonnull() && productToBeInserted != *this) {
217  throw edm::Exception(errors::InvalidReference,"Inconsistency")
218  << "RefCore::pushBackItem: Ref points into different collection than the RefVector.\n";
219  }
220  } else {
221  if (productToBeInserted.isTransient()) {
222  setTransient();
223  }
224  if (productToBeInserted.isNonnull()) {
225  setId(productToBeInserted.id());
226  }
227  }
228  //Since productPtr and productGetter actually share the same pointer internally,
229  // we want to be sure that if the productPtr is set we use that one and only if
230  // it isn't set do we set the productGetter if available
231  if (productPtr() == nullptr && productToBeInserted.productPtr() != nullptr) {
232  setProductPtr(productToBeInserted.productPtr());
233  } else {
234  auto getter = productToBeInserted.productGetter();
235  if (cachePtrIsInvalid() && getter != nullptr) {
236  setProductGetter(getter);
237  }
238  }
239  }
void setProductPtr(void const *prodPtr) const
Definition: RefCore.h:51
bool isNonnull() const
Definition: RefCore.h:67
bool cachePtrIsInvalid() const
Definition: RefCore.h:115
void const * productPtr() const
Definition: RefCore.h:45
void setId(ProductID const &iId)
Definition: RefCore.cc:184
ProductID id() const
Definition: RefCore.h:42
bool isTransient() const
Definition: RefCore.h:99
void setProductGetter(EDProductGetter const *prodGetter) const
Definition: RefCore.cc:179
ProductIndex id() const
Definition: ProductID.h:38
void setTransient()
Definition: RefCore.h:111
void edm::RefCore::pushBackRefItem ( RefCore const &  productToBeInserted)

Definition at line 242 of file RefCore.cc.

References Exception, id(), edm::errors::InvalidReference, isNonnull(), isNull(), isTransient(), productGetter(), setId(), setProductGetter(), and setTransient().

Referenced by edm::RefVectorBase< key_type >::pushBack().

242  {
243  if (productToBeInserted.isNull() && !productToBeInserted.isTransient()) {
244  throw edm::Exception(errors::InvalidReference,"Inconsistency")
245  << "RefCore::pushBackRefItem: Ref has invalid (zero) product ID, so it cannot be added to RefVector."
246  << "id should be (" << id() << ")\n";
247  }
248  if (isNonnull() || isTransient()) {
249  if (isTransient() != productToBeInserted.isTransient()) {
250  if (productToBeInserted.isTransient()) {
251  throw edm::Exception(errors::InvalidReference,"Inconsistency")
252  << "RefCore::pushBackRefItem: Transient Ref cannot be added to persistable RefVector. "
253  << "id should be (" << id() << ")\n";
254  } else {
255  throw edm::Exception(errors::InvalidReference,"Inconsistency")
256  << "RefCore::pushBackRefItem: Persistable Ref cannot be added to transient RefVector. "
257  << "id is (" << productToBeInserted.id() << ")\n";
258  }
259  }
260  if (!productToBeInserted.isTransient() && id() != productToBeInserted.id()) {
261  throw edm::Exception(errors::InvalidReference,"Inconsistency")
262  << "RefCore::pushBackRefItem: Ref is inconsistent with RefVector"
263  << "id = (" << productToBeInserted.id() << ") should be (" << id() << ")\n";
264  }
265  } else {
266  if (productToBeInserted.isTransient()) {
267  setTransient();
268  }
269  if (productToBeInserted.isNonnull()) {
270  setId(productToBeInserted.id());
271  }
272  }
273  auto prodGetter = productToBeInserted.productGetter();
274  if (productGetter() == 0 && prodGetter != 0) {
275  setProductGetter(prodGetter);
276  }
277  }
bool isNonnull() const
Definition: RefCore.h:67
void setId(ProductID const &iId)
Definition: RefCore.cc:184
EDProductGetter const * productGetter() const
Definition: RefCore.h:77
ProductID id() const
Definition: RefCore.h:42
bool isTransient() const
Definition: RefCore.h:99
void setProductGetter(EDProductGetter const *prodGetter) const
Definition: RefCore.cc:179
ProductIndex id() const
Definition: ProductID.h:38
void setTransient()
Definition: RefCore.h:111
void edm::RefCore::setCacheIsProductGetter ( EDProductGetter const *  iGetter) const
inlineprivate

Definition at line 113 of file RefCore.h.

References SETCACHEISPRODUCTGETTER_IMPL.

Referenced by RefCore(), and setProductGetter().

#define SETCACHEISPRODUCTGETTER_IMPL(_getter_)
Definition: classes.h:107
void edm::RefCore::setCacheIsProductPtr ( const void *  iItem) const
inlineprivate

Definition at line 112 of file RefCore.h.

References SETCACHEISPRODUCTPTR_IMPL.

Referenced by setProductPtr().

#define SETCACHEISPRODUCTPTR_IMPL(_item_)
Definition: classes.h:105
void edm::RefCore::setId ( ProductID const &  iId)
private

Definition at line 184 of file RefCore.cc.

References edm::refcoreimpl::kCacheIsProductPtrBit, edm::refcoreimpl::kTransientBit, edm::ProductID::processIndex(), processIndex_, edm::ProductID::productIndex(), and productIndex_.

Referenced by pushBackItem(), pushBackRefItem(), and edm::RefCoreWithIndex::setId().

184  {
186  processIndex_ = iId.processIndex();
187  processIndex_ |= head;
188  productIndex_ = iId.productIndex();
189  }
ProductIndex productIndex_
Definition: RefCore.h:132
ProcessIndex processIndex_
Definition: RefCore.h:131
const std::uintptr_t kCacheIsProductPtrBit
const unsigned short kTransientBit
void edm::RefCore::setProductGetter ( EDProductGetter const *  prodGetter) const

Definition at line 179 of file RefCore.cc.

References setCacheIsProductGetter().

Referenced by pushBackItem(), pushBackRefItem(), edm::RefCoreWithIndex::setProductGetter(), and edm::PtrVectorBase::setProductGetter().

179  {
180  setCacheIsProductGetter(prodGetter);
181  }
void setCacheIsProductGetter(EDProductGetter const *iGetter) const
Definition: RefCore.h:113
void edm::RefCore::setProductPtr ( void const *  prodPtr) const
inline

This function is 'const' even though it changes an internal value becuase it is meant to be used as a way to store in a thread-safe way a cache of a value. This allows classes which use the RefCore to not have to declare it 'mutable'

Definition at line 51 of file RefCore.h.

References setCacheIsProductPtr().

Referenced by edm::RefVector< JetEisolAssociationCollection >::at(), edm::refitem::findRefItem(), edm::Ptr< PileUpPFCandidate >::getData_(), edm::refcore::getProduct_(), edm::RefVector< JetEisolAssociationCollection >::operator[](), edm::Ptr< PileUpPFCandidate >::Ptr(), pushBackItem(), and edm::RefToBaseProd< T >::RefToBaseProd().

51  {
52  setCacheIsProductPtr(prodPtr);
53  }
void setCacheIsProductPtr(const void *iItem) const
Definition: RefCore.h:112
void edm::RefCore::setTransient ( )
inlineprivate

Definition at line 111 of file RefCore.h.

References SETTRANSIENT_IMPL.

Referenced by pushBackItem(), pushBackRefItem(), and RefCore().

#define SETTRANSIENT_IMPL
Definition: classes.h:103
void edm::RefCore::swap ( RefCore other)
inline

Definition at line 157 of file RefCore.h.

References cachePtr_, processIndex_, productIndex_, and std::swap().

Referenced by edm::RefVectorBase< key_type >::swap(), edm::PtrVectorBase::swap(), and edm::swap().

157  {
158  std::swap(processIndex_, other.processIndex_);
159  std::swap(productIndex_, other.productIndex_);
160  other.cachePtr_.store(cachePtr_.exchange(other.cachePtr_.load()));
161  }
ProductIndex productIndex_
Definition: RefCore.h:132
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
ProcessIndex processIndex_
Definition: RefCore.h:131
std::atomic< void const * > cachePtr_
Definition: RefCore.h:122
WrapperBase const * edm::RefCore::tryToGetProductPtr ( std::type_info const &  type,
EDProductGetter const *  prodGetter 
) const

Definition at line 96 of file RefCore.cc.

References assert(), cachePtrIsInvalid(), edm::WrapperBase::dynamicTypeInfo(), edm::EDProductGetter::getIt(), id(), isTransient(), edm::ProductID::isValid(), throwInvalidRefFromNoCache(), throwInvalidRefFromNullOrInvalidRef(), and wrongTypeException().

Referenced by edm::refcore::tryToGetProductWithCoreFromRef_().

96  {
97  ProductID tId = id();
98  assert (!isTransient());
99  if (!tId.isValid()) {
101  }
102 
103  if (cachePtrIsInvalid()) {
104  throwInvalidRefFromNoCache(TypeID(type),tId);
105  }
106  WrapperBase const* product = prodGetter->getIt(tId);
107  if(product != nullptr && !(type == product->dynamicTypeInfo())) {
108  wrongTypeException(type, product->dynamicTypeInfo());
109  }
110  return product;
111  }
type
Definition: HCALResponse.h:21
assert(m_qm.get())
bool cachePtrIsInvalid() const
Definition: RefCore.h:115
static void throwInvalidRefFromNullOrInvalidRef(const edm::TypeID &id)
Definition: RefCore.cc:9
ProductID id() const
Definition: RefCore.h:42
bool isTransient() const
Definition: RefCore.h:99
static void throwInvalidRefFromNoCache(const edm::TypeID &id, edm::ProductID const &prodID)
Definition: RefCore.cc:19
void wrongTypeException(std::type_info const &expectedType, std::type_info const &actualType) const
Definition: RefCore.cc:150
bool edm::RefCore::tryToSetProductPtrForFirstTime ( void const *  prodPtr) const
inline

This function is 'const' even though it changes an internal value becuase it is meant to be used as a way to store in a thread-safe way a cache of a value. This allows classes which use the RefCore to not have to declare it 'mutable'

Definition at line 59 of file RefCore.h.

References cachePtr_, and edm::refcoreimpl::tryToSetCacheItemForFirstTime().

59  {
61  }
bool tryToSetCacheItemForFirstTime(std::atomic< void const * > &iCache, void const *iNewValue)
std::atomic< void const * > cachePtr_
Definition: RefCore.h:122
void edm::RefCore::wrongTypeException ( std::type_info const &  expectedType,
std::type_info const &  actualType 
) const

Definition at line 150 of file RefCore.cc.

References Exception, id(), and edm::errors::InvalidReference.

Referenced by edm::refcore::getProduct_(), getProductPtr(), edm::refcore::getProductWithCoreFromRef_(), getThinnedProductPtr(), tryToGetProductPtr(), and edm::RefCoreWithIndex::wrongTypeException().

150  {
151  throw edm::Exception(errors::InvalidReference,"WrongType")
152  << "RefCore: A request to convert a contained product of type '"
153  << TypeID(actualType) << "'\n"
154  << " to type '" << TypeID(expectedType) << "'"
155  << "\nfor ProductID '" << id()
156  << "' can not be satisfied\n";
157  }
ProductID id() const
Definition: RefCore.h:42

Friends And Related Function Documentation

friend class RefCoreWithIndex
friend

Definition at line 26 of file RefCore.h.

Member Data Documentation

std::atomic<void const*> edm::RefCore::cachePtr_
mutableprivate

Definition at line 122 of file RefCore.h.

Referenced by cachePtrIsInvalid(), operator=(), swap(), and tryToSetProductPtrForFirstTime().

ProcessIndex edm::RefCore::processIndex_
private

Definition at line 131 of file RefCore.h.

Referenced by operator=(), setId(), and swap().

ProductIndex edm::RefCore::productIndex_
private

Definition at line 132 of file RefCore.h.

Referenced by operator=(), setId(), and swap().