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, ServiceToken const &token, 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)
 
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 460 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().

460  {
461  // Check if the types match.
462  TypeID typeID(prod.dynamicTypeInfo());
463  if(typeID !=TypeID{branchDescription().unwrappedType().unvalidatedTypeInfo()}) {
464  // Types do not match.
466  << "Product on branch " << branchDescription().branchName() << " is of wrong type.\n"
467  << "It is supposed to be of type " << branchDescription().className() << ".\n"
468  << "It is actually of type " << typeID.className() << ".\n";
469  }
470  }
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 79 of file ProductResolvers.cc.

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

Referenced by getProductData(), and putOrMergeProduct_().

79  {
80  assert(status() == ProductStatus::ProductSet);
81  if(not iFrom) { return;}
82 
83  checkType(*iFrom);
84 
86  if(original->isMergeable()) {
87  original->mergeProduct(iFrom.get());
88  } else if(original->hasIsProductEqual()) {
89  if(!original->isProductEqual(iFrom.get())) {
90  auto const& bd = branchDescription();
91  edm::LogError("RunLumiMerging")
92  << "ProductResolver::mergeTheProduct\n"
93  << "Two run/lumi products for the same run/lumi which should be equal are not\n"
94  << "Using the first, ignoring the second\n"
95  << "className = " << bd.className() << "\n"
96  << "moduleLabel = " << bd.moduleLabel() << "\n"
97  << "instance = " << bd.productInstanceName() << "\n"
98  << "process = " << bd.processName() << "\n";
99  }
100  } else {
101  auto const& bd = branchDescription();
102  edm::LogWarning("RunLumiMerging")
103  << "ProductResolver::mergeTheProduct\n"
104  << "Run/lumi product has neither a mergeProduct nor isProductEqual function\n"
105  << "Using the first, ignoring the second in merge\n"
106  << "className = " << bd.className() << "\n"
107  << "moduleLabel = " << bd.moduleLabel() << "\n"
108  << "instance = " << bd.productInstanceName() << "\n"
109  << "process = " << bd.processName() << "\n";
110  }
111  }
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 496 of file ProductResolvers.cc.

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

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

496  {
497  auto s = status();
498  return (s != defaultStatus() ) or (s == ProductStatus::ProductDeleted);
499  }
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 509 of file ProductResolvers.cc.

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

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

509  {
510  if (iSkipCurrentProcess and isFromCurrentProcess() ) {
511  return false;
512  }
514  if(getProductData().wrapper()->isPresent()) {
515  return true;
516  }
517  }
518  return false;
519  }
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 447 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().

447  {
448  if(not prod) {return;}
449  if(status() == defaultStatus()) {
450  //resolveProduct has not been called or it failed
451  putProduct(std::move(prod));
452  } else {
453  mergeProduct(std::move(prod));
454  }
455  }
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 534 of file ProductResolvers.cc.

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

Referenced by 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 45 of file ProductResolvers.cc.

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

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

474  {
475  if(edp) {
476  checkType(*edp);
479  } else {
480  setFailedStatus();
481  }
482  }
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 29 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().

29  {
31  exception << "ProductResolverBase::resolveProduct_: The product matching all criteria was already deleted\n"
32  << "Looking for type: " << branchDescription().unwrappedTypeID() << "\n"
33  << "Looking for module label: " << moduleLabel() << "\n"
34  << "Looking for productInstanceName: " << productInstanceName() << "\n"
35  << (processName().empty() ? "" : "Looking for process: ") << processName() << "\n"
36  << "This means there is a configuration error.\n"
37  << "The module which is asking for this data must be configured to state that it will read this data.";
38  throw exception;
39 
40  }
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