CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::RefCoreWithIndex Class Reference

#include <RefCoreWithIndex.h>

Public Member Functions

WrapperBase const * getProductPtr (std::type_info const &type, EDProductGetter const *prodGetter) const
 
ProductID id () const
 
unsigned int index () const
 
bool isAvailable () const
 
bool isNonnull () const
 
bool isNull () const
 
bool isTransient () const
 
int isTransientInt () const
 
void nullPointerForTransientException (std::type_info const &type) const
 
bool operator! () const
 
RefCoreWithIndexoperator= (RefCoreWithIndex const &)
 
RefCoreWithIndexoperator= (RefCoreWithIndex &&iOther) noexcept
 
EDProductGetter const * productGetter () const
 
void productNotFoundException (std::type_info const &type) const
 
void const * productPtr () const
 
void pushBackItem (RefCoreWithIndex const &productToBeInserted, bool checkPointer)
 
 RefCoreWithIndex ()
 
 RefCoreWithIndex (ProductID const &theId, void const *prodPtr, EDProductGetter const *prodGetter, bool transient, unsigned int elementIndex)
 
 RefCoreWithIndex (RefCore const &iCore, unsigned int)
 
 RefCoreWithIndex (RefCoreWithIndex const &)
 
 RefCoreWithIndex (RefCoreWithIndex &&iOther) noexcept
 
void setProductGetter (EDProductGetter const *prodGetter) const
 
void setProductPtr (void const *prodPtr) const
 
void swap (RefCoreWithIndex &)
 
RefCore const & toRefCore () const
 
bool tryToSetProductPtrForFirstTime (void const *prodPtr) const
 
void wrongTypeException (std::type_info const &expectedType, std::type_info const &actualType) const
 
 ~RefCoreWithIndex () noexcept
 

Private Member Functions

void setCacheIsProductGetter (EDProductGetter const *iGetter) const
 
void setCacheIsProductPtr (void const *iItem) const
 
void setId (ProductID const &iId)
 
void setTransient ()
 
RefCoretoUnConstRefCore ()
 

Private Attributes

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

Detailed Description

Definition at line 25 of file RefCoreWithIndex.h.

Constructor & Destructor Documentation

edm::RefCoreWithIndex::RefCoreWithIndex ( )
inline

Definition at line 27 of file RefCoreWithIndex.h.

References operator=().

edm::RefCoreWithIndex::RefCoreWithIndex ( ProductID const &  theId,
void const *  prodPtr,
EDProductGetter const *  prodGetter,
bool  transient,
unsigned int  elementIndex 
)

Definition at line 6 of file RefCoreWithIndex.cc.

References setCacheIsProductGetter(), and setTransient().

6  :
7  cachePtr_(prodPtr),
8  processIndex_(theId.processIndex()),
9  productIndex_(theId.productIndex()),
10  elementIndex_(iIndex)
11  {
12  if(transient) {
13  setTransient();
14  }
15  if(prodPtr==nullptr && prodGetter!=nullptr) {
16  setCacheIsProductGetter(prodGetter);
17  }
18  }
std::atomic< void const * > cachePtr_
void setCacheIsProductGetter(EDProductGetter const *iGetter) const
edm::RefCoreWithIndex::RefCoreWithIndex ( RefCore const &  iCore,
unsigned int  iIndex 
)

Definition at line 20 of file RefCoreWithIndex.cc.

References edm::RefCore::cachePtr_, and cachePtr_.

20  :
21  processIndex_(iCore.processIndex_),
22  productIndex_(iCore.productIndex_),
23  elementIndex_(iIndex){
24  cachePtr_.store(iCore.cachePtr_.load(std::memory_order_relaxed), std::memory_order_relaxed);
25  }
std::atomic< void const * > cachePtr_
edm::RefCoreWithIndex::RefCoreWithIndex ( RefCoreWithIndex const &  iOther)

Definition at line 27 of file RefCoreWithIndex.cc.

References cachePtr_.

27  :
28  processIndex_(iOther.processIndex_),
29  productIndex_(iOther.productIndex_),
30  elementIndex_(iOther.elementIndex_){
31  cachePtr_.store(iOther.cachePtr_.load(std::memory_order_relaxed), std::memory_order_relaxed);
32  }
std::atomic< void const * > cachePtr_
edm::RefCoreWithIndex::RefCoreWithIndex ( RefCoreWithIndex &&  iOther)
inlinenoexcept

Definition at line 37 of file RefCoreWithIndex.h.

References cachePtr_.

37  :
38  processIndex_(iOther.processIndex_),
39  productIndex_(iOther.productIndex_),elementIndex_(iOther.elementIndex_) {
40  cachePtr_.store(iOther.cachePtr_.load(std::memory_order_relaxed), std::memory_order_relaxed);
41  }
std::atomic< void const * > cachePtr_
edm::RefCoreWithIndex::~RefCoreWithIndex ( )
inlinenoexcept

Definition at line 51 of file RefCoreWithIndex.h.

51 {}

Member Function Documentation

WrapperBase const* edm::RefCoreWithIndex::getProductPtr ( std::type_info const &  type,
EDProductGetter const *  prodGetter 
) const
inline

Definition at line 105 of file RefCoreWithIndex.h.

References edm::RefCore::getProductPtr(), and toRefCore().

105  {
106  return toRefCore().getProductPtr(type,prodGetter);
107  }
type
Definition: HCALResponse.h:21
WrapperBase const * getProductPtr(std::type_info const &type, EDProductGetter const *prodGetter) const
Definition: RefCore.cc:61
RefCore const & toRefCore() const
ProductID edm::RefCoreWithIndex::id ( ) const
inline
unsigned int edm::RefCoreWithIndex::index ( ) const
inline
bool edm::RefCoreWithIndex::isAvailable ( ) const
inline

Definition at line 88 of file RefCoreWithIndex.h.

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

88  {
89  return toRefCore().isAvailable();
90  }
RefCore const & toRefCore() const
bool isAvailable() const
Definition: RefCore.cc:169
bool edm::RefCoreWithIndex::isNonnull ( ) const
inline

Definition at line 80 of file RefCoreWithIndex.h.

References ISNONNULL_IMPL.

Referenced by isNull().

#define ISNONNULL_IMPL
bool edm::RefCoreWithIndex::isNull ( ) const
inline

Definition at line 77 of file RefCoreWithIndex.h.

References isNonnull().

Referenced by operator!().

77 {return !isNonnull(); }
bool edm::RefCoreWithIndex::isTransient ( ) const
inline

Definition at line 123 of file RefCoreWithIndex.h.

References ISTRANSIENT_IMPL.

Referenced by isTransientInt(), and edm::RefCoreWithIndexStreamer::operator()().

#define ISTRANSIENT_IMPL
int edm::RefCoreWithIndex::isTransientInt ( ) const
inline

Definition at line 125 of file RefCoreWithIndex.h.

References isTransient().

125 {return isTransient() ? 1 : 0;}
void edm::RefCoreWithIndex::nullPointerForTransientException ( std::type_info const &  type) const
inline

Definition at line 117 of file RefCoreWithIndex.h.

References edm::RefCore::nullPointerForTransientException(), swap(), and toRefCore().

117  {
119  }
type
Definition: HCALResponse.h:21
RefCore const & toRefCore() const
void nullPointerForTransientException(std::type_info const &type) const
Definition: RefCore.cc:161
bool edm::RefCoreWithIndex::operator! ( ) const
inline

Definition at line 83 of file RefCoreWithIndex.h.

References isNull().

83 {return isNull();}
RefCoreWithIndex & edm::RefCoreWithIndex::operator= ( RefCoreWithIndex const &  iOther)

Definition at line 34 of file RefCoreWithIndex.cc.

References cachePtr_, elementIndex_, processIndex_, and productIndex_.

Referenced by RefCoreWithIndex().

34  {
35  cachePtr_.store(iOther.cachePtr_.load(std::memory_order_relaxed), std::memory_order_relaxed);
36  processIndex_ = iOther.processIndex_;
37  productIndex_ = iOther.productIndex_;
38  elementIndex_ = iOther.elementIndex_;
39  return *this;
40  }
std::atomic< void const * > cachePtr_
RefCoreWithIndex& edm::RefCoreWithIndex::operator= ( RefCoreWithIndex &&  iOther)
inlinenoexcept

Definition at line 43 of file RefCoreWithIndex.h.

References cachePtr_, elementIndex_, processIndex_, and productIndex_.

43  {
44  cachePtr_.store(iOther.cachePtr_.load(std::memory_order_relaxed), std::memory_order_relaxed);
45  processIndex_ = iOther.processIndex_;
46  productIndex_ = iOther.productIndex_;
47  elementIndex_ = iOther.elementIndex_;
48  return *this;
49  }
std::atomic< void const * > cachePtr_
EDProductGetter const* edm::RefCoreWithIndex::productGetter ( ) const
inline

Definition at line 97 of file RefCoreWithIndex.h.

References PRODUCTGETTER_IMPL.

97  {
99  }
#define PRODUCTGETTER_IMPL
void edm::RefCoreWithIndex::productNotFoundException ( std::type_info const &  type) const
inline

Definition at line 109 of file RefCoreWithIndex.h.

References edm::RefCore::productNotFoundException(), and toRefCore().

109  {
111  }
type
Definition: HCALResponse.h:21
RefCore const & toRefCore() const
void productNotFoundException(std::type_info const &type) const
Definition: RefCore.cc:141
void const* edm::RefCoreWithIndex::productPtr ( ) const
inline

If productPtr is not 0 then productGetter will be 0 since only one is available at a time

Definition at line 56 of file RefCoreWithIndex.h.

References PRODUCTPTR_IMPL.

#define PRODUCTPTR_IMPL
void edm::RefCoreWithIndex::pushBackItem ( RefCoreWithIndex const &  productToBeInserted,
bool  checkPointer 
)
inline

Definition at line 127 of file RefCoreWithIndex.h.

References edm::RefCore::pushBackItem(), toRefCore(), and toUnConstRefCore().

127  {
128  toUnConstRefCore().pushBackItem(productToBeInserted.toRefCore(),checkPointer);
129  }
void pushBackItem(RefCore const &productToBeInserted, bool checkPointer)
Definition: RefCore.cc:194
void edm::RefCoreWithIndex::setCacheIsProductGetter ( EDProductGetter const *  iGetter) const
inlineprivate

Definition at line 141 of file RefCoreWithIndex.h.

References SETCACHEISPRODUCTGETTER_IMPL.

Referenced by RefCoreWithIndex().

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

Definition at line 140 of file RefCoreWithIndex.h.

References SETCACHEISPRODUCTPTR_IMPL.

Referenced by setProductPtr().

#define SETCACHEISPRODUCTPTR_IMPL(_item_)
void edm::RefCoreWithIndex::setId ( ProductID const &  iId)
inlineprivate

Definition at line 136 of file RefCoreWithIndex.h.

References edm::RefCore::setId(), and toUnConstRefCore().

136  {
137  toUnConstRefCore().setId(iId);
138  }
void setId(ProductID const &iId)
Definition: RefCore.cc:185
void edm::RefCoreWithIndex::setProductGetter ( EDProductGetter const *  prodGetter) const
inline

Definition at line 101 of file RefCoreWithIndex.h.

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

101  {
102  toRefCore().setProductGetter(prodGetter);
103  }
RefCore const & toRefCore() const
void setProductGetter(EDProductGetter const *prodGetter) const
Definition: RefCore.cc:180
void edm::RefCoreWithIndex::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 62 of file RefCoreWithIndex.h.

References setCacheIsProductPtr().

62  {
63  setCacheIsProductPtr(prodPtr);
64  }
void setCacheIsProductPtr(void const *iItem) const
void edm::RefCoreWithIndex::setTransient ( )
inlineprivate

Definition at line 139 of file RefCoreWithIndex.h.

References SETTRANSIENT_IMPL.

Referenced by RefCoreWithIndex().

#define SETTRANSIENT_IMPL
void edm::RefCoreWithIndex::swap ( RefCoreWithIndex other)
inline

Definition at line 162 of file RefCoreWithIndex.h.

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

Referenced by nullPointerForTransientException(), and edm::swap().

162  {
163  std::swap(processIndex_, other.processIndex_);
164  std::swap(productIndex_, other.productIndex_);
165  other.cachePtr_.store(cachePtr_.exchange(other.cachePtr_.load()));
166  std::swap(elementIndex_,other.elementIndex_);
167  }
std::atomic< void const * > cachePtr_
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
RefCore const& edm::RefCoreWithIndex::toRefCore ( ) const
inline
RefCore& edm::RefCoreWithIndex::toUnConstRefCore ( )
inlineprivate

Definition at line 132 of file RefCoreWithIndex.h.

Referenced by pushBackItem(), and setId().

132  {
133  return *reinterpret_cast<RefCore*>(this);
134  }
bool edm::RefCoreWithIndex::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 70 of file RefCoreWithIndex.h.

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

70  {
72  }
std::atomic< void const * > cachePtr_
bool tryToSetCacheItemForFirstTime(std::atomic< void const * > &iCache, void const *iNewValue)
void edm::RefCoreWithIndex::wrongTypeException ( std::type_info const &  expectedType,
std::type_info const &  actualType 
) const
inline

Definition at line 113 of file RefCoreWithIndex.h.

References toRefCore(), and edm::RefCore::wrongTypeException().

113  {
114  toRefCore().wrongTypeException(expectedType,actualType);
115  }
RefCore const & toRefCore() const
void wrongTypeException(std::type_info const &expectedType, std::type_info const &actualType) const
Definition: RefCore.cc:151

Member Data Documentation

std::atomic<void const*> edm::RefCoreWithIndex::cachePtr_
mutableprivate
unsigned int edm::RefCoreWithIndex::elementIndex_
private

Definition at line 156 of file RefCoreWithIndex.h.

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

ProcessIndex edm::RefCoreWithIndex::processIndex_
private

Definition at line 154 of file RefCoreWithIndex.h.

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

ProductIndex edm::RefCoreWithIndex::productIndex_
private

Definition at line 155 of file RefCoreWithIndex.h.

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