![]() |
![]() |
#include <RefCore.h>
Classes | |
struct | CheckTransientOnWrite |
Public Member Functions | |
EDProduct const * | getProductPtr (std::type_info const &type) const |
ProductID | id () 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 |
EDProductGetter const * | productGetter () const |
void | productNotFoundException (std::type_info const &type) const |
void const * | productPtr () const |
void | pushBackItem (RefCore const &productToBeInserted, bool checkPointer) |
RefCore () | |
RefCore (ProductID const &theId, void const *prodPtr, EDProductGetter const *prodGetter, bool transient) | |
void | setProductGetter (EDProductGetter const *prodGetter) const |
void | setProductPtr (void const *prodPtr) const |
void | swap (RefCore &) |
void | wrongTypeException (std::type_info const &expectedType, std::type_info const &actualType) const |
Private Member Functions | |
bool | cacheIsProductPtr () const |
void | setCacheIsProductPtr (bool iState) const |
void | setId (ProductID const &iId) |
void | setTransient () |
Private Attributes | |
void const * | cachePtr_ |
ProcessIndex | processIndex_ |
ProductIndex | productIndex_ |
CheckTransientOnWrite | transient_ |
edm::RefCore::RefCore | ( | ) | [inline] |
Definition at line 19 of file RefCore.h.
: cachePtr_(0),processIndex_(0),productIndex_(0), transient_() {}
edm::RefCore::RefCore | ( | ProductID const & | theId, |
void const * | prodPtr, | ||
EDProductGetter const * | prodGetter, | ||
bool | transient | ||
) |
Definition at line 34 of file RefCore.cc.
: cachePtr_(prodPtr?prodPtr:prodGetter), processIndex_(theId.processIndex()), productIndex_(theId.productIndex()), transient_(transient,prodPtr!=0 || prodGetter==0) {}
bool edm::RefCore::cacheIsProductPtr | ( | ) | const [inline, private] |
Definition at line 84 of file RefCore.h.
References edm::RefCore::CheckTransientOnWrite::cacheIsProductPtr_, and transient_.
Referenced by productGetter(), and productPtr().
{ return transient_.cacheIsProductPtr_; }
EDProduct const * edm::RefCore::getProductPtr | ( | std::type_info const & | type | ) | const |
Definition at line 42 of file RefCore.cc.
References cachePtr_, edm::EDProductGetter::getIt(), id(), isTransient(), edm::ProductID::isValid(), productGetter(), productNotFoundException(), throwInvalidRefFromNoCache(), and throwInvalidRefFromNullOrInvalidRef().
Referenced by edm::refcore::getProductPtr_().
{ // The following invariant would be nice to establish in all // constructors, but we can not be sure that the context in which // EDProductGetter::instance() is called will be one where a // non-null pointer is returned. The biggest question in the // various times at which Root makes RefCore instances, and how // old ones might be recycled. // // If our ProductID is non-null, we must have a way to get at the // product (unless it has been dropped). This means either we // already have the pointer to the product, or we have a valid // EDProductGetter to use. // // assert(!id_.isValid() || productGetter() || prodPtr_); ProductID tId = id(); assert (!isTransient()); if (!tId.isValid()) { throwInvalidRefFromNullOrInvalidRef(TypeID(type)); } //if (productPtr() == 0 && productGetter() == 0) { if (cachePtr_ == 0) { throwInvalidRefFromNoCache(TypeID(type),tId); } EDProduct const* product = productGetter()->getIt(tId); if ( 0 == product) { productNotFoundException(type); } return product; }
ProductID edm::RefCore::id | ( | void | ) | const [inline] |
Definition at line 23 of file RefCore.h.
References processIndex_, and productIndex_.
Referenced by bitPackRefInfo(), edm::Ptr< pat::MET >::getData_(), getProductPtr(), edm::RefProd< TrackingRecHitCollection >::id(), edm::PtrVectorBase::id(), edm::RefToBaseProd< T >::id(), edm::Ref< TrackingRecHitCollection >::id(), edm::RefVector< TrackingRecHitCollection >::id(), edm::Ptr< pat::MET >::id(), isAvailable(), isNonnull(), edm::operator<(), edm::operator==(), productNotFoundException(), pushBackItem(), and wrongTypeException().
{return ProductID(processIndex_,productIndex_);}
bool edm::RefCore::isAvailable | ( | ) | const |
Definition at line 103 of file RefCore.cc.
References edm::EDProductGetter::getIt(), id(), edm::ProductID::isValid(), productGetter(), and productPtr().
Referenced by edm::Ptr< pat::MET >::isAvailable(), edm::PtrVectorBase::isAvailable(), edm::RefVector< TrackingRecHitCollection >::isAvailable(), edm::Ref< TrackingRecHitCollection >::isAvailable(), and edm::RefProd< TrackingRecHitCollection >::isAvailable().
{ ProductID tId = id(); return productPtr() != 0 || (tId.isValid() && productGetter() != 0 && 0 != productGetter()->getIt(tId)); }
bool edm::RefCore::isNonnull | ( | ) | const [inline] |
Definition at line 37 of file RefCore.h.
References id(), isTransient(), edm::ProductID::isValid(), and productPtr().
Referenced by edm::PtrVectorBase::isNonnull(), edm::RefProd< TrackingRecHitCollection >::isNonnull(), isNull(), and pushBackItem().
{return isTransient() ? productPtr() != 0 : id().isValid();}
bool edm::RefCore::isNull | ( | ) | const [inline] |
Definition at line 34 of file RefCore.h.
References isNonnull().
Referenced by operator!(), and pushBackItem().
{return !isNonnull(); }
bool edm::RefCore::isTransient | ( | ) | const [inline] |
Definition at line 64 of file RefCore.h.
References transient_, and edm::RefCore::CheckTransientOnWrite::transient_.
Referenced by edm::getProduct(), getProductPtr(), edm::refcore::getProductPtr_(), isNonnull(), edm::Ptr< pat::MET >::isTransient(), edm::RefVector< TrackingRecHitCollection >::isTransient(), edm::Ref< TrackingRecHitCollection >::isTransient(), edm::PtrVectorBase::isTransient(), edm::RefProd< TrackingRecHitCollection >::isTransient(), edm::operator<(), edm::operator==(), and pushBackItem().
{return transient_.transient_;}
int edm::RefCore::isTransientInt | ( | ) | const [inline] |
Definition at line 66 of file RefCore.h.
References transient_, and edm::RefCore::CheckTransientOnWrite::transient_.
{return transient_.transient_ ? 1 : 0;}
void edm::RefCore::nullPointerForTransientException | ( | std::type_info const & | type | ) | const |
Definition at line 95 of file RefCore.cc.
References Exception, and edm::errors::InvalidReference.
Referenced by edm::getProduct().
{ throw edm::Exception(errors::InvalidReference) << "RefCore: A request to resolve a transient reference to a product of type: " << TypeID(type) << "\ncan not be satisfied because the pointer to the product is null.\n"; }
bool edm::RefCore::operator! | ( | ) | const [inline] |
EDProductGetter const* edm::RefCore::productGetter | ( | ) | const [inline] |
Definition at line 47 of file RefCore.h.
References cacheIsProductPtr(), cachePtr_, and compareJSON::const.
Referenced by getProductPtr(), isAvailable(), edm::RefVector< TrackingRecHitCollection >::productGetter(), edm::Ref< TrackingRecHitCollection >::productGetter(), edm::RefProd< TrackingRecHitCollection >::productGetter(), edm::RefToBaseProd< T >::productGetter(), edm::PtrVectorBase::productGetter(), edm::Ptr< pat::MET >::productGetter(), and pushBackItem().
{ return (!cacheIsProductPtr())? static_cast<EDProductGetter const*>(cachePtr_): static_cast<EDProductGetter const*>(0); }
void edm::RefCore::productNotFoundException | ( | std::type_info const & | type | ) | const |
Definition at line 75 of file RefCore.cc.
References Exception, id(), and edm::errors::ProductNotFound.
Referenced by edm::Ptr< pat::MET >::getData_(), and getProductPtr().
{ throw edm::Exception(errors::ProductNotFound) << "RefCore: A request to resolve a reference to a product of type '" << TypeID(type) << "' with ProductID '" << id() << "'" << "\ncan not be satisfied because the product cannot be found." << "\nProbably the branch containing the product is not stored in the input file.\n"; }
void const* edm::RefCore::productPtr | ( | ) | const [inline] |
If productPtr is not 0 then productGetter will be 0 since only one is available at a time
Definition at line 26 of file RefCore.h.
References cacheIsProductPtr(), cachePtr_, and compareJSON::const.
Referenced by edm::getProduct(), edm::RefProd< TrackingRecHitCollection >::hasCache(), edm::RefToBaseProd< T >::hasCache(), edm::Ref< TrackingRecHitCollection >::hasProductCache(), edm::RefVector< TrackingRecHitCollection >::hasProductCache(), edm::Ptr< pat::MET >::hasProductCache(), edm::PtrVectorBase::hasProductCache(), isAvailable(), isNonnull(), edm::operator<(), edm::operator==(), pushBackItem(), reco::PFCandidate::storeRefInfo(), and edm::RefToBaseProd< T >::viewPtr().
{return cacheIsProductPtr()?cachePtr_:static_cast<void const*>(0);}
void edm::RefCore::pushBackItem | ( | RefCore const & | productToBeInserted, |
bool | checkPointer | ||
) |
Definition at line 115 of file RefCore.cc.
References Exception, id(), edm::errors::InvalidReference, isNonnull(), isNull(), isTransient(), productGetter(), productPtr(), setId(), setProductGetter(), setProductPtr(), and setTransient().
Referenced by edm::PtrVectorBase::push_back_base(), and edm::RefVectorBase< key_type >::pushBack().
{ if (productToBeInserted.isNull() && !productToBeInserted.isTransient()) { throw edm::Exception(errors::InvalidReference,"Inconsistency") << "RefCore::pushBackItem: Ref or Ptr has invalid (zero) product ID, so it cannot be added to RefVector (PtrVector). " << "id should be (" << id() << ")\n"; } if (isNonnull()) { if (isTransient() != productToBeInserted.isTransient()) { if (productToBeInserted.isTransient()) { throw edm::Exception(errors::InvalidReference,"Inconsistency") << "RefCore::pushBackItem: Transient Ref or Ptr cannot be added to persistable RefVector (PtrVector). " << "id should be (" << id() << ")\n"; } else { throw edm::Exception(errors::InvalidReference,"Inconsistency") << "RefCore::pushBackItem: Persistable Ref or Ptr cannot be added to transient RefVector (PtrVector). " << "id is (" << productToBeInserted.id() << ")\n"; } } if (!productToBeInserted.isTransient() && id() != productToBeInserted.id()) { throw edm::Exception(errors::InvalidReference,"Inconsistency") << "RefCore::pushBackItem: Ref or Ptr is inconsistent with RefVector (PtrVector)" << "id = (" << productToBeInserted.id() << ") should be (" << id() << ")\n"; } if (productToBeInserted.isTransient() && checkPointer && productToBeInserted.isNonnull() && productToBeInserted != *this) { throw edm::Exception(errors::InvalidReference,"Inconsistency") << "RefCore::pushBackItem: Ref points into different collection than the RefVector.\n"; } } else { if (productToBeInserted.isTransient()) { setTransient(); } if (productToBeInserted.isNonnull()) { setId(productToBeInserted.id()); } } //Since productPtr and productGetter actually share the same pointer internally, // we want to be sure that if the productPtr is set we use that one and only if // it isn't set do we set the productGetter if available if (productPtr() == 0 && productToBeInserted.productPtr() != 0) { setProductPtr(productToBeInserted.productPtr()); } else if (productPtr() == 0 && productGetter() == 0 && productToBeInserted.productGetter() != 0) { setProductGetter(productToBeInserted.productGetter()); } }
void edm::RefCore::setCacheIsProductPtr | ( | bool | iState | ) | const [inline, private] |
Definition at line 83 of file RefCore.h.
References edm::RefCore::CheckTransientOnWrite::cacheIsProductPtr_, and transient_.
Referenced by setProductGetter(), and setProductPtr().
{transient_.cacheIsProductPtr_=iState;}
void edm::RefCore::setId | ( | ProductID const & | iId | ) | [inline, private] |
Definition at line 78 of file RefCore.h.
References edm::ProductID::processIndex(), processIndex_, edm::ProductID::productIndex(), and productIndex_.
Referenced by pushBackItem().
{ processIndex_ = iId.processIndex(); productIndex_ = iId.productIndex(); }
void edm::RefCore::setProductGetter | ( | EDProductGetter const * | prodGetter | ) | const |
Definition at line 109 of file RefCore.cc.
References cachePtr_, and setCacheIsProductPtr().
Referenced by edm::RefCoreStreamer::operator()(), pushBackItem(), and edm::PtrVectorBase::setProductGetter().
{ cachePtr_ = prodGetter; setCacheIsProductPtr(false); }
void edm::RefCore::setProductPtr | ( | void const * | prodPtr | ) | const [inline] |
Definition at line 28 of file RefCore.h.
References cachePtr_, and setCacheIsProductPtr().
Referenced by edm::Ptr< pat::MET >::getData_(), edm::refcore::getProductPtr_(), pushBackItem(), and edm::RefToBaseProd< T >::RefToBaseProd().
{ cachePtr_=prodPtr; setCacheIsProductPtr(true); }
void edm::RefCore::setTransient | ( | ) | [inline, private] |
Definition at line 82 of file RefCore.h.
References transient_, and edm::RefCore::CheckTransientOnWrite::transient_.
Referenced by pushBackItem().
{transient_.transient_ = true;}
void edm::RefCore::swap | ( | RefCore & | other | ) | [inline] |
Definition at line 117 of file RefCore.h.
References edm::RefCore::CheckTransientOnWrite::cacheIsProductPtr_, cachePtr_, processIndex_, productIndex_, transient_, and edm::RefCore::CheckTransientOnWrite::transient_.
Referenced by edm::swap(), edm::RefVectorBase< key_type >::swap(), and edm::PtrVectorBase::swap().
{ std::swap(processIndex_, other.processIndex_); std::swap(productIndex_, other.productIndex_); std::swap(cachePtr_, other.cachePtr_); std::swap(transient_.transient_, other.transient_.transient_); std::swap(transient_.cacheIsProductPtr_, other.transient_.cacheIsProductPtr_); }
void edm::RefCore::wrongTypeException | ( | std::type_info const & | expectedType, |
std::type_info const & | actualType | ||
) | const |
Definition at line 85 of file RefCore.cc.
References Exception, id(), and edm::errors::InvalidReference.
Referenced by edm::refcore::getProductPtr_().
{ throw edm::Exception(errors::InvalidReference,"WrongType") << "RefCore: A request to convert a contained product of type '" << TypeID(actualType) << "'\n" << " to type '" << TypeID(expectedType) << "'" << "\nfor ProductID '" << id() << "' can not be satisfied\n"; }
void const* edm::RefCore::cachePtr_ [mutable, private] |
Definition at line 89 of file RefCore.h.
Referenced by getProductPtr(), productGetter(), productPtr(), setProductGetter(), setProductPtr(), and swap().
ProcessIndex edm::RefCore::processIndex_ [private] |
ProductIndex edm::RefCore::productIndex_ [private] |
Definition at line 93 of file RefCore.h.
Referenced by cacheIsProductPtr(), isTransient(), isTransientInt(), setCacheIsProductPtr(), setTransient(), and swap().