CMS 3D CMS Logo

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 &&iOther) noexcept
 
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) noexcept
 
void setProductGetter (EDProductGetter const *prodGetter) const
 
void setProductPtr (void const *prodPtr) const
 
void swap (RefCore &) noexcept
 
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
 
 ~RefCore () noexcept
 

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 21 of file RefCore.h.

Constructor & Destructor Documentation

edm::RefCore::RefCore ( )
inline

Definition at line 26 of file RefCore.h.

References operator=().

26 : cachePtr_(nullptr),processIndex_(0),productIndex_(0){}
ProductIndex productIndex_
Definition: RefCore.h:133
ProcessIndex processIndex_
Definition: RefCore.h:132
std::atomic< void const * > cachePtr_
Definition: RefCore.h:126
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:133
ProcessIndex processIndex_
Definition: RefCore.h:132
std::atomic< void const * > cachePtr_
Definition: RefCore.h:126
void setCacheIsProductGetter(EDProductGetter const *iGetter) const
Definition: RefCore.h:120
void setTransient()
Definition: RefCore.h:118
edm::RefCore::RefCore ( RefCore const &  iOther)

Definition at line 47 of file RefCore.cc.

References cachePtr_.

47  :
48  processIndex_(iOther.processIndex_),
49  productIndex_(iOther.productIndex_) {
50  cachePtr_.store(iOther.cachePtr_.load(std::memory_order_relaxed), std::memory_order_relaxed);
51  }
ProductIndex productIndex_
Definition: RefCore.h:133
ProcessIndex processIndex_
Definition: RefCore.h:132
std::atomic< void const * > cachePtr_
Definition: RefCore.h:126
edm::RefCore::RefCore ( RefCore &&  iOther)
inlinenoexcept

Definition at line 34 of file RefCore.h.

References cachePtr_.

34  :
35  processIndex_(iOther.processIndex_),
36  productIndex_(iOther.productIndex_) {
37  cachePtr_.store(iOther.cachePtr_.load(std::memory_order_relaxed), std::memory_order_relaxed);
38  }
ProductIndex productIndex_
Definition: RefCore.h:133
ProcessIndex processIndex_
Definition: RefCore.h:132
std::atomic< void const * > cachePtr_
Definition: RefCore.h:126
edm::RefCore::~RefCore ( )
inlinenoexcept

Definition at line 47 of file RefCore.h.

47 {}
edm::RefCore::RefCore ( void const *  iCache,
ProcessIndex  iProcessIndex,
ProductIndex  iProductIndex 
)
inlineprivate

Definition at line 115 of file RefCore.h.

References setId().

115  :
116  cachePtr_(iCache), processIndex_(iProcessIndex), productIndex_(iProductIndex) {}
ProductIndex productIndex_
Definition: RefCore.h:133
ProcessIndex processIndex_
Definition: RefCore.h:132
std::atomic< void const * > cachePtr_
Definition: RefCore.h:126

Member Function Documentation

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

Definition at line 121 of file RefCore.h.

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

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

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

Definition at line 61 of file RefCore.cc.

References 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(), edm::refcore::getProductWithCoreFromRef_(), and productGetter().

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

Definition at line 115 of file RefCore.cc.

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

Referenced by edm::refcore::getThinnedProduct_(), and productGetter().

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

Definition at line 169 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(), edm::RefProd< Phase2TrackerCluster1Ds >::isAvailable(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< std::vector< E >, typename refhelper::ValueTrait< std::vector< E > >::value, typename refhelper::FindTrait< std::vector< E >, typename refhelper::ValueTrait< std::vector< E > >::value >::value >::isAvailable(), and operator!().

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

Definition at line 71 of file RefCore.h.

References isNonnull().

Referenced by operator!(), edm::RefToBaseProd< T >::operator->(), pushBackItem(), and pushBackRefItem().

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

Definition at line 130 of file RefCore.cc.

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

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

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

Definition at line 108 of file RefCore.h.

References isTransient(), pushBackItem(), and pushBackRefItem().

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

Definition at line 161 of file RefCore.cc.

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

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

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

Definition at line 77 of file RefCore.h.

References isAvailable(), and isNull().

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

Definition at line 53 of file RefCore.cc.

References cachePtr_, processIndex_, and productIndex_.

Referenced by RefCore().

53  {
54  cachePtr_.store(iOther.cachePtr_.load(std::memory_order_relaxed), std::memory_order_relaxed);
55  processIndex_ = iOther.processIndex_;
56  productIndex_ = iOther.productIndex_;
57  return *this;
58  }
ProductIndex productIndex_
Definition: RefCore.h:133
ProcessIndex processIndex_
Definition: RefCore.h:132
std::atomic< void const * > cachePtr_
Definition: RefCore.h:126
RefCore& edm::RefCore::operator= ( RefCore &&  iOther)
inlinenoexcept

Definition at line 40 of file RefCore.h.

References cachePtr_, processIndex_, and productIndex_.

40  {
41  cachePtr_.store(iOther.cachePtr_.load(std::memory_order_relaxed), std::memory_order_relaxed);
42  processIndex_ = iOther.processIndex_;
43  productIndex_ = iOther.productIndex_;
44  return *this;
45  }
ProductIndex productIndex_
Definition: RefCore.h:133
ProcessIndex processIndex_
Definition: RefCore.h:132
std::atomic< void const * > cachePtr_
Definition: RefCore.h:126
EDProductGetter const* edm::RefCore::productGetter ( ) const
inline
void edm::RefCore::productNotFoundException ( std::type_info const &  type) const

Definition at line 141 of file RefCore.cc.

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

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

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

Definition at line 194 of file RefCore.cc.

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

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

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

Definition at line 243 of file RefCore.cc.

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

Referenced by isTransientInt().

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

Definition at line 120 of file RefCore.h.

References SETCACHEISPRODUCTGETTER_IMPL.

Referenced by RefCore(), and setProductGetter().

#define SETCACHEISPRODUCTGETTER_IMPL(_getter_)
void edm::RefCore::setCacheIsProductPtr ( const void *  iItem) const
inlineprivate

Definition at line 119 of file RefCore.h.

References SETCACHEISPRODUCTPTR_IMPL.

Referenced by setProductPtr().

#define SETCACHEISPRODUCTPTR_IMPL(_item_)
void edm::RefCore::setId ( ProductID const &  iId)
private

Definition at line 185 of file RefCore.cc.

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

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

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

Definition at line 180 of file RefCore.cc.

References setCacheIsProductGetter().

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

180  {
181  setCacheIsProductGetter(prodGetter);
182  }
void setCacheIsProductGetter(EDProductGetter const *iGetter) const
Definition: RefCore.h:120
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 58 of file RefCore.h.

References setCacheIsProductPtr().

Referenced by edm::RefVector< std::vector< math::PtEtaPhiELorentzVectorD > >::at(), edm::refitem::findRefItem(), edm::Ptr< reco::Muon >::getData_(), edm::refcore::getProduct_(), edm::RefVector< std::vector< math::PtEtaPhiELorentzVectorD > >::operator[](), edm::Ptr< reco::Muon >::Ptr(), pushBackItem(), and edm::RefToBaseProd< T >::RefToBaseProd().

58  {
59  setCacheIsProductPtr(prodPtr);
60  }
void setCacheIsProductPtr(const void *iItem) const
Definition: RefCore.h:119
void edm::RefCore::setTransient ( )
inlineprivate

Definition at line 118 of file RefCore.h.

References SETTRANSIENT_IMPL.

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

#define SETTRANSIENT_IMPL
void edm::RefCore::swap ( RefCore other)
inlinenoexcept

Definition at line 157 of file RefCore.h.

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

Referenced by productGetter(), 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:133
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
ProcessIndex processIndex_
Definition: RefCore.h:132
std::atomic< void const * > cachePtr_
Definition: RefCore.h:126
WrapperBase const * edm::RefCore::tryToGetProductPtr ( std::type_info const &  type,
EDProductGetter const *  prodGetter 
) const

Definition at line 97 of file RefCore.cc.

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

Referenced by productGetter(), and edm::refcore::tryToGetProductWithCoreFromRef_().

97  {
98  ProductID tId = id();
99  assert (!isTransient());
100  if (!tId.isValid()) {
102  }
103 
104  if (cachePtrIsInvalid()) {
105  throwInvalidRefFromNoCache(TypeID(type),tId);
106  }
107  WrapperBase const* product = prodGetter->getIt(tId);
108  if(product != nullptr && !(type == product->dynamicTypeInfo())) {
109  wrongTypeException(type, product->dynamicTypeInfo());
110  }
111  return product;
112  }
type
Definition: HCALResponse.h:21
bool cachePtrIsInvalid() const
Definition: RefCore.h:121
static void throwInvalidRefFromNullOrInvalidRef(const edm::TypeID &id)
Definition: RefCore.cc:9
ProductID id() const
Definition: RefCore.h:49
bool isTransient() const
Definition: RefCore.h:106
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:151
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 66 of file RefCore.h.

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

Referenced by edm::RefToBaseProd< T >::operator->().

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

Definition at line 151 of file RefCore.cc.

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

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

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

Friends And Related Function Documentation

friend class RefCoreWithIndex
friend

Definition at line 24 of file RefCore.h.

Member Data Documentation

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

Definition at line 132 of file RefCore.h.

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

ProductIndex edm::RefCore::productIndex_
private

Definition at line 133 of file RefCore.h.

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