CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::DataManagingProductResolver Class Referenceabstract

#include <ProductResolvers.h>

Inheritance diagram for edm::DataManagingProductResolver:
edm::ProductResolverBase edm::InputProductResolver edm::ProducedProductResolver edm::PuttableProductResolver edm::UnscheduledProductResolver

Public Types

enum  ProductStatus {
  ProductStatus::ProductSet, ProductStatus::NotPut, ProductStatus::ResolveFailed, ProductStatus::ResolveNotRun,
  ProductStatus::ProductDeleted
}
 

Public Member Functions

void connectTo (ProductResolverBase const &, Principal const *) final
 
 DataManagingProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
void resetProductData_ (bool deleteEarly) override
 
void resetStatus ()
 
template<bool callResolver, typename FUNC >
ProductResolverBase::Resolution resolveProductImpl (FUNC resolver) const
 
- Public Member Functions inherited from edm::ProductResolverBase
BranchDescription const & branchDescription () const
 
std::string const & moduleLabel () const
 
ProductResolverBaseoperator= (ProductResolverBase const &)=delete
 
void prefetchAsync (WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
std::string const & processName () const
 
ProductID const & productID () const
 
std::string const & productInstanceName () const
 
ProductProvenance const * productProvenancePtr () const
 
bool productResolved () const
 
 ProductResolverBase ()
 
 ProductResolverBase (ProductResolverBase const &)=delete
 
TypeID productType () const
 
bool productUnavailable () const
 
bool productWasDeleted () const
 
bool productWasFetchedAndIsValid (bool iSkipCurrentProcess) const
 
Provenance const * provenance () const
 
bool provenanceAvailable () const
 
void putOrMergeProduct (std::unique_ptr< WrapperBase > edp) const
 
void putProduct (std::unique_ptr< WrapperBase > edp) const
 
void resetBranchDescription (std::shared_ptr< BranchDescription const > bd)
 
virtual void resetFailedFromThisProcess ()
 
void resetProductData ()
 
std::string const & resolvedModuleLabel () const
 
Resolution resolveProduct (Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
 
void retrieveAndMerge (Principal const &principal) const
 
void setProcessHistory (ProcessHistory const &ph)
 
void setProvenance (ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid)
 
virtual void setupUnscheduled (UnscheduledConfigurator const &)
 
bool singleProduct () const
 
StableProvenance const * stableProvenance () const
 
void unsafe_deleteProduct () const
 
bool unscheduledWasNotRun () const
 
void write (std::ostream &os) const
 
virtual ~ProductResolverBase ()
 

Protected Member Functions

ProductStatus defaultStatus () const
 
template<bool callResolver, typename FUNC >
Resolution resolveProductImpl (FUNC resolver) const
 
void setFailedStatus () const
 
void setProduct (std::unique_ptr< WrapperBase > edp) const
 
ProductStatus status () const
 

Private Member Functions

BranchDescription const & branchDescription_ () const final
 
void checkType (WrapperBase const &prod) const
 
ProductData const & getProductData () const
 
virtual bool isFromCurrentProcess () const =0
 
void mergeProduct (std::unique_ptr< WrapperBase > edp) const
 
ProductProvenance const * productProvenancePtr_ () const final
 
bool productResolved_ () const final
 
bool productUnavailable_ () const final
 
bool productWasDeleted_ () const final
 
bool productWasFetchedAndIsValid_ (bool iSkipCurrentProcess) const final
 
Provenance const * provenance_ () const final
 
void putOrMergeProduct_ (std::unique_ptr< WrapperBase > prod) const final
 
void resetBranchDescription_ (std::shared_ptr< BranchDescription const > bd) final
 
std::string const & resolvedModuleLabel_ () const final
 
void setProcessHistory_ (ProcessHistory const &ph) final
 
void setProvenance_ (ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid) final
 
bool singleProduct_ () const final
 
void throwProductDeletedException () const
 

Private Attributes

ProductStatus const defaultStatus_
 
ProductData productData_
 
std::atomic< ProductStatustheStatus_
 

Detailed Description

Definition at line 35 of file ProductResolvers.h.

Member Enumeration Documentation

Enumerator
ProductSet 
NotPut 
ResolveFailed 
ResolveNotRun 
ProductDeleted 

Definition at line 37 of file ProductResolvers.h.

37  {
38  ProductSet,
39  NotPut,
40  ResolveFailed,
41  ResolveNotRun,
42  ProductDeleted
43  };

Constructor & Destructor Documentation

edm::DataManagingProductResolver::DataManagingProductResolver ( std::shared_ptr< BranchDescription const >  bd,
ProductStatus  iDefaultStatus 
)
inline

Definition at line 45 of file ProductResolvers.h.

References connectTo().

46  productData_(bd),
47  theStatus_(iDefaultStatus),
48  defaultStatus_(iDefaultStatus){}
ProductStatus const defaultStatus_
std::atomic< ProductStatus > theStatus_

Member Function Documentation

BranchDescription const& edm::DataManagingProductResolver::branchDescription_ ( ) const
inlinefinalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 81 of file ProductResolvers.h.

References edm::ProductData::branchDescription(), and getProductData().

Referenced by edm::SingleChoiceNoProcessProductResolver::SingleChoiceNoProcessProductResolver().

81 {return *getProductData().branchDescription();}
std::shared_ptr< BranchDescription const > const & branchDescription() const
Definition: ProductData.h:26
ProductData const & getProductData() const
void edm::DataManagingProductResolver::checkType ( WrapperBase const &  prod) const
private

Definition at line 463 of file ProductResolvers.cc.

References edm::ProductResolverBase::branchDescription(), edm::BranchDescription::branchName(), edm::BranchDescription::className(), edm::WrapperBase::dynamicTypeInfo(), edm::errors::EventCorruption, Exception, edm::TypeWithDict::unvalidatedTypeInfo(), and edm::BranchDescription::unwrappedType().

Referenced by mergeProduct(), setFailedStatus(), and setProduct().

463  {
464  // Check if the types match.
465  TypeID typeID(prod.dynamicTypeInfo());
466  if(typeID !=TypeID{branchDescription().unwrappedType().unvalidatedTypeInfo()}) {
467  // Types do not match.
469  << "Product on branch " << branchDescription().branchName() << " is of wrong type.\n"
470  << "It is supposed to be of type " << branchDescription().className() << ".\n"
471  << "It is actually of type " << typeID.className() << ".\n";
472  }
473  }
std::string const & branchName() const
std::string const & className() const
TypeWithDict const & unwrappedType() const
std::type_info const & unvalidatedTypeInfo() const
Definition: TypeWithDict.h:75
BranchDescription const & branchDescription() const
void edm::DataManagingProductResolver::connectTo ( ProductResolverBase const &  iOther,
Principal const *   
)
finalvirtual
ProductStatus edm::DataManagingProductResolver::defaultStatus ( ) const
inlineprotected
ProductData const& edm::DataManagingProductResolver::getProductData ( ) const
inlineprivate
virtual bool edm::DataManagingProductResolver::isFromCurrentProcess ( ) const
privatepure virtual
void edm::DataManagingProductResolver::mergeProduct ( std::unique_ptr< WrapperBase edp) const
private

Definition at line 78 of file ProductResolvers.cc.

References edm::ProductResolverBase::branchDescription(), checkType(), getProductData(), definitions::original, ProductSet, status(), and edm::ProductData::unsafe_wrapper().

Referenced by getProductData(), and putOrMergeProduct_().

78  {
79  assert(status() == ProductStatus::ProductSet);
80  if(not iFrom) { return;}
81 
82  checkType(*iFrom);
83 
85  if(original->isMergeable()) {
86  original->mergeProduct(iFrom.get());
87  } else if(original->hasIsProductEqual()) {
88  if(!original->isProductEqual(iFrom.get())) {
89  auto const& bd = branchDescription();
90  edm::LogError("RunLumiMerging")
91  << "ProductResolver::mergeTheProduct\n"
92  << "Two run/lumi products for the same run/lumi which should be equal are not\n"
93  << "Using the first, ignoring the second\n"
94  << "className = " << bd.className() << "\n"
95  << "moduleLabel = " << bd.moduleLabel() << "\n"
96  << "instance = " << bd.productInstanceName() << "\n"
97  << "process = " << bd.processName() << "\n";
98  }
99  } else {
100  auto const& bd = branchDescription();
101  edm::LogWarning("RunLumiMerging")
102  << "ProductResolver::mergeTheProduct\n"
103  << "Run/lumi product has neither a mergeProduct nor isProductEqual function\n"
104  << "Using the first, ignoring the second in merge\n"
105  << "className = " << bd.className() << "\n"
106  << "moduleLabel = " << bd.moduleLabel() << "\n"
107  << "instance = " << bd.productInstanceName() << "\n"
108  << "process = " << bd.processName() << "\n";
109  }
110  }
void checkType(WrapperBase const &prod) const
ProductStatus status() const
BranchDescription const & branchDescription() const
ProductData const & getProductData() const
WrapperBase * unsafe_wrapper() const
Definition: ProductData.h:34
ProductProvenance const * edm::DataManagingProductResolver::productProvenancePtr_ ( ) const
finalprivatevirtual
bool edm::DataManagingProductResolver::productResolved_ ( ) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 499 of file ProductResolvers.cc.

References defaultStatus(), or, ProductDeleted, alignCSCRings::s, and status().

Referenced by getProductData(), and edm::SingleChoiceNoProcessProductResolver::SingleChoiceNoProcessProductResolver().

499  {
500  auto s = status();
501  return (s != defaultStatus() ) or (s == ProductStatus::ProductDeleted);
502  }
ProductStatus status() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
ProductStatus defaultStatus() const
bool edm::DataManagingProductResolver::productUnavailable_ ( ) const
finalprivatevirtual
bool edm::DataManagingProductResolver::productWasDeleted_ ( ) const
finalprivatevirtual
bool edm::DataManagingProductResolver::productWasFetchedAndIsValid_ ( bool  iSkipCurrentProcess) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 512 of file ProductResolvers.cc.

References getProductData(), isFromCurrentProcess(), ProductSet, status(), and wrapper.

Referenced by getProductData(), and edm::SingleChoiceNoProcessProductResolver::SingleChoiceNoProcessProductResolver().

512  {
513  if (iSkipCurrentProcess and isFromCurrentProcess() ) {
514  return false;
515  }
517  if(getProductData().wrapper()->isPresent()) {
518  return true;
519  }
520  }
521  return false;
522  }
ProductStatus status() const
virtual bool isFromCurrentProcess() const =0
ProductData const & getProductData() const
static HepMC::HEPEVT_Wrapper wrapper
Provenance const* edm::DataManagingProductResolver::provenance_ ( ) const
inlinefinalprivatevirtual
void edm::DataManagingProductResolver::putOrMergeProduct_ ( std::unique_ptr< WrapperBase prod) const
finalprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 450 of file ProductResolvers.cc.

References defaultStatus(), mergeProduct(), eostools::move(), edm::ProductResolverBase::putProduct(), and status().

Referenced by getProductData(), edm::AliasProductResolver::productWasFetchedAndIsValid_(), edm::ParentProcessProductResolver::productWasFetchedAndIsValid_(), and edm::SingleChoiceNoProcessProductResolver::SingleChoiceNoProcessProductResolver().

450  {
451  if(not prod) {return;}
452  if(status() == defaultStatus()) {
453  //resolveProduct has not been called or it failed
454  putProduct(std::move(prod));
455  } else {
456  mergeProduct(std::move(prod));
457  }
458  }
ProductStatus status() const
void putProduct(std::unique_ptr< WrapperBase > edp) const
void mergeProduct(std::unique_ptr< WrapperBase > edp) const
ProductStatus defaultStatus() const
def move(src, dest)
Definition: eostools.py:510
void edm::DataManagingProductResolver::resetBranchDescription_ ( std::shared_ptr< BranchDescription const >  bd)
inlinefinalprivatevirtual
void edm::DataManagingProductResolver::resetProductData_ ( bool  deleteEarly)
overridevirtual

Implements edm::ProductResolverBase.

Reimplemented in edm::UnscheduledProductResolver, edm::PuttableProductResolver, and edm::InputProductResolver.

Definition at line 537 of file ProductResolvers.cc.

References productData_, ProductDeleted, ProductSet, edm::ProductData::resetProductData(), resetStatus(), and theStatus_.

Referenced by edm::ProducedProductResolver::resetFailedFromThisProcess(), edm::InputProductResolver::resetProductData_(), edm::PuttableProductResolver::resetProductData_(), edm::UnscheduledProductResolver::resetProductData_(), resetStatus(), edm::AliasProductResolver::resolvedModuleLabel_(), edm::ParentProcessProductResolver::resolvedModuleLabel_(), edm::NoProcessProductResolver::resolvedModuleLabel_(), edm::SingleChoiceNoProcessProductResolver::resolvedModuleLabel_(), edm::InputProductResolver::unscheduledWasNotRun_(), edm::PuttableProductResolver::unscheduledWasNotRun_(), and edm::UnscheduledProductResolver::unscheduledWasNotRun_().

void edm::DataManagingProductResolver::resetStatus ( )
inline

Definition at line 52 of file ProductResolvers.h.

References defaultStatus_, resetProductData_(), setProduct(), and theStatus_.

Referenced by resetProductData_().

ProductStatus const defaultStatus_
std::atomic< ProductStatus > theStatus_
std::string const& edm::DataManagingProductResolver::resolvedModuleLabel_ ( ) const
inlinefinalprivatevirtual
template<bool callResolver, typename FUNC >
ProductResolverBase::Resolution edm::DataManagingProductResolver::resolveProductImpl ( FUNC  resolver) const

Definition at line 44 of file ProductResolvers.cc.

References getProductData(), ProductSet, edm::ProductResolverBase::productWasDeleted(), Resolution, ResolveNotRun, setFailedStatus(), status(), and throwProductDeletedException().

44  {
45 
46  if(productWasDeleted()) {
48  }
49  auto presentStatus = status();
50 
51  if(callResolver && presentStatus == ProductStatus::ResolveNotRun) {
52  //if resolver fails because of exception or not setting product
53  // make sure the status goes to failed
54  auto failedStatusSetter = [this](ProductStatus* presentStatus) {
55  if(this->status() == ProductStatus::ResolveNotRun) {
56  this->setFailedStatus();
57  }
58  *presentStatus = this->status();
59  };
60  std::unique_ptr<ProductStatus, decltype(failedStatusSetter)> failedStatusGuard(&presentStatus, failedStatusSetter);
61 
62  //If successful, this will call setProduct
63  resolver();
64  }
65 
66 
67  if (presentStatus == ProductStatus::ProductSet) {
68  auto pd = &getProductData();
69  if(pd->wrapper()->isPresent()) {
70  return Resolution(pd);
71  }
72  }
73 
74  return Resolution(nullptr);
75  }
ProductStatus status() const
ProductData const & getProductData() const
template<bool callResolver, typename FUNC >
Resolution edm::DataManagingProductResolver::resolveProductImpl ( FUNC  resolver) const
protected

Referenced by setFailedStatus().

void edm::DataManagingProductResolver::setFailedStatus ( ) const
inlineprotected
void edm::DataManagingProductResolver::setProcessHistory_ ( ProcessHistory const &  ph)
finalprivatevirtual
void edm::DataManagingProductResolver::setProduct ( std::unique_ptr< WrapperBase edp) const
protected

Definition at line 477 of file ProductResolvers.cc.

References checkType(), eostools::move(), productData_, ProductSet, setFailedStatus(), theStatus_, and edm::ProductData::unsafe_setWrapper().

Referenced by edm::InputProductResolver::putProduct_(), edm::ProducedProductResolver::putProduct_(), and resetStatus().

477  {
478  if(edp) {
479  checkType(*edp);
482  } else {
483  setFailedStatus();
484  }
485  }
void checkType(WrapperBase const &prod) const
void unsafe_setWrapper(std::unique_ptr< WrapperBase > iValue) const
Definition: ProductData.cc:38
std::atomic< ProductStatus > theStatus_
def move(src, dest)
Definition: eostools.py:510
void edm::DataManagingProductResolver::setProvenance_ ( ProductProvenanceRetriever const *  provRetriever,
ProcessHistory const &  ph,
ProductID const &  pid 
)
finalprivatevirtual
bool edm::DataManagingProductResolver::singleProduct_ ( ) const
finalprivatevirtual
ProductStatus edm::DataManagingProductResolver::status ( void  ) const
inlineprotected
void edm::DataManagingProductResolver::throwProductDeletedException ( ) const
private

Definition at line 28 of file ProductResolvers.cc.

References edm::ProductResolverBase::branchDescription(), cppFunctionSkipper::exception, edm::ProductResolverBase::moduleLabel(), edm::ProductResolverBase::processName(), edm::ProductResolverBase::productInstanceName(), and edm::BranchDescription::unwrappedTypeID().

Referenced by resolveProductImpl(), and setFailedStatus().

28  {
30  exception << "ProductResolverBase::resolveProduct_: The product matching all criteria was already deleted\n"
31  << "Looking for type: " << branchDescription().unwrappedTypeID() << "\n"
32  << "Looking for module label: " << moduleLabel() << "\n"
33  << "Looking for productInstanceName: " << productInstanceName() << "\n"
34  << (processName().empty() ? "" : "Looking for process: ") << processName() << "\n"
35  << "This means there is a configuration error.\n"
36  << "The module which is asking for this data must be configured to state that it will read this data.";
37  throw exception;
38 
39  }
std::string const & productInstanceName() const
std::string const & processName() const
TypeID unwrappedTypeID() const
BranchDescription const & branchDescription() const
std::string const & moduleLabel() const

Member Data Documentation

ProductStatus const edm::DataManagingProductResolver::defaultStatus_
private

Definition at line 93 of file ProductResolvers.h.

Referenced by defaultStatus(), and resetStatus().

ProductData edm::DataManagingProductResolver::productData_
private
std::atomic<ProductStatus> edm::DataManagingProductResolver::theStatus_
mutableprivate