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

virtual void connectTo (ProductResolverBase const &, Principal const *) override final
 
 DataManagingProductResolver (std::shared_ptr< BranchDescription const > bd, ProductStatus iDefaultStatus)
 
virtual 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

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

virtual BranchDescription const& edm::DataManagingProductResolver::branchDescription_ ( ) const
inlinefinaloverrideprivatevirtual

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 459 of file ProductResolvers.cc.

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

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

459  {
460  // Check if the types match.
461  TypeID typeID(prod.dynamicTypeInfo());
462  if(typeID != branchDescription().unwrappedTypeID()) {
463  // Types do not match.
465  << "Product on branch " << branchDescription().branchName() << " is of wrong type.\n"
466  << "It is supposed to be of type " << branchDescription().className() << ".\n"
467  << "It is actually of type " << typeID.className() << ".\n";
468  }
469  }
std::string const & branchName() const
std::string const & className() const
TypeID unwrappedTypeID() const
BranchDescription const & branchDescription() const
void edm::DataManagingProductResolver::connectTo ( ProductResolverBase const &  iOther,
Principal const *   
)
finaloverridevirtual
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
finaloverrideprivatevirtual
bool edm::DataManagingProductResolver::productResolved_ ( ) const
finaloverrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 495 of file ProductResolvers.cc.

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

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

495  {
496  auto s = status();
497  return (s != defaultStatus() ) or (s == ProductStatus::ProductDeleted);
498  }
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
finaloverrideprivatevirtual
bool edm::DataManagingProductResolver::productWasDeleted_ ( ) const
finaloverrideprivatevirtual
bool edm::DataManagingProductResolver::productWasFetchedAndIsValid_ ( bool  iSkipCurrentProcess) const
finaloverrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 508 of file ProductResolvers.cc.

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

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

508  {
509  if (iSkipCurrentProcess and isFromCurrentProcess() ) {
510  return false;
511  }
513  if(getProductData().wrapper()->isPresent()) {
514  return true;
515  }
516  }
517  return false;
518  }
ProductStatus status() const
virtual bool isFromCurrentProcess() const =0
ProductData const & getProductData() const
static HepMC::HEPEVT_Wrapper wrapper
virtual Provenance const* edm::DataManagingProductResolver::provenance_ ( ) const
inlinefinaloverrideprivatevirtual
void edm::DataManagingProductResolver::putOrMergeProduct_ ( std::unique_ptr< WrapperBase prod) const
finaloverrideprivatevirtual

Implements edm::ProductResolverBase.

Definition at line 446 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().

446  {
447  if(not prod) {return;}
448  if(status() == defaultStatus()) {
449  //resolveProduct has not been called or it failed
450  putProduct(std::move(prod));
451  } else {
452  mergeProduct(std::move(prod));
453  }
454  }
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
virtual void edm::DataManagingProductResolver::resetBranchDescription_ ( std::shared_ptr< BranchDescription const >  bd)
inlinefinaloverrideprivatevirtual
void edm::DataManagingProductResolver::resetProductData_ ( bool  deleteEarly)
overridevirtual

Implements edm::ProductResolverBase.

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

Definition at line 533 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_
virtual std::string const& edm::DataManagingProductResolver::resolvedModuleLabel_ ( ) const
inlinefinaloverrideprivatevirtual
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)
finaloverrideprivatevirtual
void edm::DataManagingProductResolver::setProduct ( std::unique_ptr< WrapperBase edp) const
protected

Definition at line 473 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().

473  {
474  if(edp) {
475  checkType(*edp);
478  } else {
479  setFailedStatus();
480  }
481  }
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 
)
finaloverrideprivatevirtual
bool edm::DataManagingProductResolver::singleProduct_ ( ) const
finaloverrideprivatevirtual
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