CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::PrincipalGetAdapter Class Reference

#include <PrincipalGetAdapter.h>

Public Types

typedef std::vector< BasicHandleBasicHandleVec
 

Public Member Functions

template<typename PROD >
bool checkIfComplete () const
 
BranchDescription const & getBranchDescription (TypeID const &type, std::string const &productInstanceName) const
 
BasicHandle getByLabel_ (TypeID const &tid, InputTag const &tag, ModuleCallingContext const *mcc) const
 
BasicHandle getByLabel_ (TypeID const &tid, std::string const &label, std::string const &instance, std::string const &process, ModuleCallingContext const *mcc) const
 
BasicHandle getByToken_ (TypeID const &id, KindOfType kindOfType, EDGetToken token, ModuleCallingContext const *mcc) const
 
template<typename PROD >
void getManyByType (std::vector< Handle< PROD > > &results, ModuleCallingContext const *mcc) const
 
void getManyByType_ (TypeID const &tid, BasicHandleVec &results, ModuleCallingContext const *mcc) const
 
BasicHandle getMatchingSequenceByLabel_ (TypeID const &typeID, InputTag const &tag, ModuleCallingContext const *mcc) const
 
BasicHandle getMatchingSequenceByLabel_ (TypeID const &typeID, std::string const &label, std::string const &instance, std::string const &process, ModuleCallingContext const *mcc) const
 
bool isComplete () const
 
PrincipalGetAdapteroperator= (PrincipalGetAdapter const &)=delete
 
Principalprincipal ()
 
Principal const & principal () const
 
 PrincipalGetAdapter (Principal &pcpl, ModuleDescription const &md)
 
 PrincipalGetAdapter (PrincipalGetAdapter const &)=delete
 
ProcessHistory const & processHistory () const
 
EDProductGetter const * prodGetter () const
 
void setConsumer (EDConsumerBase const *iConsumer)
 
 ~PrincipalGetAdapter ()
 

Private Member Functions

BranchType const & branchType () const
 
BasicHandle makeFailToGetException (KindOfType, TypeID const &, EDGetToken) const
 
void throwAmbiguousException (TypeID const &productType, EDGetToken token) const
 

Private Attributes

EDConsumerBase const * consumer_
 
ModuleDescription const & md_
 
Principalprincipal_
 

Detailed Description

Definition at line 125 of file PrincipalGetAdapter.h.

Member Typedef Documentation

Definition at line 160 of file PrincipalGetAdapter.h.

Constructor & Destructor Documentation

PrincipalGetAdapter::PrincipalGetAdapter ( Principal pcpl,
ModuleDescription const &  md 
)

Definition at line 20 of file PrincipalGetAdapter.cc.

21  :
22  //putProducts_(),
23  principal_(pcpl),
24  md_(md),
25  consumer_(nullptr)
26  {
27  }
EDConsumerBase const * consumer_
ModuleDescription const & md_
PrincipalGetAdapter::~PrincipalGetAdapter ( )

Definition at line 29 of file PrincipalGetAdapter.cc.

29  {
30  }
edm::PrincipalGetAdapter::PrincipalGetAdapter ( PrincipalGetAdapter const &  )
delete

Member Function Documentation

BranchType const & PrincipalGetAdapter::branchType ( ) const
private

Definition at line 137 of file PrincipalGetAdapter.cc.

References edm::Principal::branchType(), and principal_.

Referenced by getByToken_().

137  {
138  return principal_.branchType();
139  }
BranchType const & branchType() const
Definition: Principal.h:165
template<typename PROD >
bool PrincipalGetAdapter::checkIfComplete ( ) const
inline
BranchDescription const & PrincipalGetAdapter::getBranchDescription ( TypeID const &  type,
std::string const &  productInstanceName 
) const

Definition at line 216 of file PrincipalGetAdapter.cc.

References assert(), edm::ProductHolderBase::branchDescription(), edm::hlt::Exception, edm::TypeID::friendlyClassName(), edm::Principal::getProductHolderByIndex(), edm::ProductHolderIndexHelper::index(), cmsHarvester::index, edm::errors::InsertFailure, md_, edm::ModuleDescription::moduleLabel(), principal_, edm::ModuleDescription::processName(), edm::PRODUCT_TYPE, edm::ProductHolderIndexInvalid, edm::Principal::productLookup(), and edm::Principal::productRegistry().

Referenced by edm::Event::getRefBeforePut(), edm::LuminosityBlock::put(), edm::Run::put(), and edm::Event::put().

217  {
218  ProductHolderIndexHelper const& productHolderIndexHelper = principal_.productLookup();
219  ProductHolderIndex index = productHolderIndexHelper.index(PRODUCT_TYPE, type, md_.moduleLabel().c_str(),productInstanceName.c_str(), md_.processName().c_str());
220  if(index == ProductHolderIndexInvalid) {
222  << "Illegal attempt to 'put' an unregistered product.\n"
223  << "No product is registered for\n"
224  << " product friendly class name: '" << type.friendlyClassName() << "'\n"
225  << " module label: '" << md_.moduleLabel() << "'\n"
226  << " product instance name: '" << productInstanceName << "'\n"
227  << " process name: '" << md_.processName() << "'\n"
228 
229  << "The ProductRegistry contains:\n"
231  << '\n';
232  }
233  ProductHolderBase const* phb = principal_.getProductHolderByIndex(index);
234  assert(phb != nullptr);
235  return phb->branchDescription();
236  }
type
Definition: HCALResponse.h:21
ProductRegistry const & productRegistry() const
Definition: Principal.h:147
std::string const & processName() const
assert(m_qm.get())
unsigned int ProductHolderIndex
std::string const & moduleLabel() const
ConstProductHolderPtr getProductHolderByIndex(ProductHolderIndex const &oid) const
Definition: Principal.cc:448
ModuleDescription const & md_
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:149
BasicHandle PrincipalGetAdapter::getByLabel_ ( TypeID const &  tid,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 142 of file PrincipalGetAdapter.cc.

References consumer_, edm::Principal::getByLabel(), principal_, and edm::PRODUCT_TYPE.

Referenced by edm::LuminosityBlock::getByLabel(), edm::Run::getByLabel(), edm::Event::getByLabel(), edm::LuminosityBlock::getByLabelImpl(), edm::Run::getByLabelImpl(), and edm::Event::getByLabelImpl().

144  {
145  return principal_.getByLabel(PRODUCT_TYPE, typeID, tag, consumer_, mcc);
146  }
EDConsumerBase const * consumer_
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, ModuleCallingContext const *mcc) const
Definition: Principal.cc:455
BasicHandle PrincipalGetAdapter::getByLabel_ ( TypeID const &  tid,
std::string const &  label,
std::string const &  instance,
std::string const &  process,
ModuleCallingContext const *  mcc 
) const

Definition at line 149 of file PrincipalGetAdapter.cc.

References consumer_, edm::Principal::getByLabel(), principal_, and edm::PRODUCT_TYPE.

153  {
155  }
static PFTauRenderPlugin instance
EDConsumerBase const * consumer_
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, ModuleCallingContext const *mcc) const
Definition: Principal.cc:455
tuple process
Definition: LaserDQM_cfg.py:3
BasicHandle PrincipalGetAdapter::getByToken_ ( TypeID const &  id,
KindOfType  kindOfType,
EDGetToken  token,
ModuleCallingContext const *  mcc 
) const

Definition at line 158 of file PrincipalGetAdapter.cc.

References branchType(), consumer_, edm::Principal::getByToken(), h, cmsHarvester::index, edm::EDConsumerBase::indexFrom(), edm::BasicHandle::isValid(), makeFailToGetException(), principal_, edm::ProductHolderIndexAndSkipBit::productHolderIndex(), edm::ProductHolderIndexAmbiguous, edm::ProductHolderIndexInvalid, edm::ProductHolderIndexAndSkipBit::skipCurrentProcess(), throwAmbiguousException(), and unlikely.

Referenced by edm::LuminosityBlock::getByToken(), edm::Run::getByToken(), and edm::Event::getByToken().

159  {
160  ProductHolderIndexAndSkipBit indexAndBit = consumer_->indexFrom(token,branchType(),id);
161  ProductHolderIndex index = indexAndBit.productHolderIndex();
162  bool skipCurrentProcess = indexAndBit.skipCurrentProcess();
163  if( unlikely(index == ProductHolderIndexInvalid)) {
164  return makeFailToGetException(kindOfType,id,token);
165  } else if( unlikely(index == ProductHolderIndexAmbiguous)) {
166  // This deals with ambiguities where the process is specified
167  throwAmbiguousException(id, token);
168  }
169  bool ambiguous = false;
170  BasicHandle h = principal_.getByToken(kindOfType, id, index, skipCurrentProcess, ambiguous, mcc);
171  if (ambiguous) {
172  // This deals with ambiguities where the process is not specified
173  throwAmbiguousException(id, token);
174  } else if(!h.isValid()) {
175  return makeFailToGetException(kindOfType,id,token);
176  }
177  return h;
178  }
ProductHolderIndexAndSkipBit indexFrom(EDGetToken, BranchType, TypeID const &) const
EDConsumerBase const * consumer_
unsigned int ProductHolderIndex
#define unlikely(x)
BranchType const & branchType() const
BasicHandle getByToken(KindOfType kindOfType, TypeID const &typeID, ProductHolderIndex index, bool skipCurrentProcess, bool &ambiguous, ModuleCallingContext const *mcc) const
Definition: Principal.cc:489
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
BasicHandle makeFailToGetException(KindOfType, TypeID const &, EDGetToken) const
void throwAmbiguousException(TypeID const &productType, EDGetToken token) const
template<typename PROD >
void PrincipalGetAdapter::getManyByType ( std::vector< Handle< PROD > > &  results,
ModuleCallingContext const *  mcc 
) const
inline

Definition at line 315 of file PrincipalGetAdapter.h.

References edm::convert_handle(), end, getManyByType_(), PROD, edm::es::products(), query::result, and python.entryComment::results.

Referenced by edm::LuminosityBlock::getManyByType(), edm::Run::getManyByType(), and edm::Event::getManyByType().

316  {
317  BasicHandleVec bhv;
318  this->getManyByType_(TypeID(typeid(PROD)), bhv, mcc);
319 
320  // Go through the returned handles; for each element,
321  // 1. create a Handle<PROD> and
322  //
323  // This function presents an exception safety difficulty. If an
324  // exception is thrown when converting a handle, the "got
325  // products" record will be wrong.
326  //
327  // Since EDProducers are not allowed to use this function,
328  // the problem does not seem too severe.
329  //
330  // Question: do we even need to keep track of the "got products"
331  // for this function, since it is *not* to be used by EDProducers?
332  std::vector<Handle<PROD> > products;
333 
334  typename BasicHandleVec::iterator it = bhv.begin();
335  typename BasicHandleVec::iterator end = bhv.end();
336 
337  while (it != end) {
339  convert_handle(std::move(*it), result); // throws on conversion error
340  products.push_back(result);
341  ++it;
342  }
343  results.swap(products);
344  }
ESProducts< T, S > products(const T &i1, const S &i2)
Definition: ESProducts.h:189
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:37
void convert_handle(BasicHandle &&bh, Handle< T > &result)
Definition: ConvertHandle.h:20
void getManyByType_(TypeID const &tid, BasicHandleVec &results, ModuleCallingContext const *mcc) const
#define PROD(A, B)
std::vector< BasicHandle > BasicHandleVec
void PrincipalGetAdapter::getManyByType_ ( TypeID const &  tid,
BasicHandleVec results,
ModuleCallingContext const *  mcc 
) const

Definition at line 204 of file PrincipalGetAdapter.cc.

References consumer_, edm::Principal::getManyByType(), and principal_.

Referenced by getManyByType().

206  {
208  }
EDConsumerBase const * consumer_
void getManyByType(TypeID const &typeID, BasicHandleVec &results, EDConsumerBase const *consumes, ModuleCallingContext const *mcc) const
Definition: Principal.cc:521
BasicHandle PrincipalGetAdapter::getMatchingSequenceByLabel_ ( TypeID const &  typeID,
InputTag const &  tag,
ModuleCallingContext const *  mcc 
) const

Definition at line 181 of file PrincipalGetAdapter.cc.

References consumer_, edm::ELEMENT_TYPE, edm::Principal::getByLabel(), and principal_.

Referenced by edm::Event::getByLabel().

183  {
184  return principal_.getByLabel(ELEMENT_TYPE, typeID, tag, consumer_, mcc);
185  }
EDConsumerBase const * consumer_
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, ModuleCallingContext const *mcc) const
Definition: Principal.cc:455
BasicHandle PrincipalGetAdapter::getMatchingSequenceByLabel_ ( TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process,
ModuleCallingContext const *  mcc 
) const

Definition at line 188 of file PrincipalGetAdapter.cc.

References consumer_, edm::ELEMENT_TYPE, edm::Principal::getByLabel(), h, and principal_.

192  {
194  typeID,
195  label,
196  instance,
197  process,
198  consumer_,
199  mcc);
200  return h;
201  }
static PFTauRenderPlugin instance
EDConsumerBase const * consumer_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag, EDConsumerBase const *consumes, ModuleCallingContext const *mcc) const
Definition: Principal.cc:455
tuple process
Definition: LaserDQM_cfg.py:3
bool PrincipalGetAdapter::isComplete ( ) const

Definition at line 244 of file PrincipalGetAdapter.cc.

References edm::Principal::isComplete(), and principal_.

Referenced by checkIfComplete().

244  {
245  return principal_.isComplete();
246  }
bool isComplete() const
Definition: Principal.h:193
BasicHandle PrincipalGetAdapter::makeFailToGetException ( KindOfType  kindOfType,
TypeID const &  productType,
EDGetToken  token 
) const
private

Definition at line 100 of file PrincipalGetAdapter.cc.

References consumer_, cppFunctionSkipper::exception, HLT_25ns14e33_v1_cff::labels, edm::EDConsumerBase::labelsForToken(), edm::makeHandleExceptionFactory(), edm::EDConsumerBase::Labels::module, edm::EDConsumerBase::Labels::process, edm::PRODUCT_TYPE, edm::EDConsumerBase::Labels::productInstance, and edm::errors::ProductNotFound.

Referenced by getByToken_().

102  {
103  EDConsumerBase::Labels labels;
104  consumer_->labelsForToken(token,labels);
105  //no need to copy memory since the exception will no occur after the
106  // const char* have been deleted
107  return BasicHandle(makeHandleExceptionFactory([labels,kindOfType,productType]()->std::shared_ptr<cms::Exception> {
108  std::shared_ptr<cms::Exception> exception(std::make_shared<Exception>(errors::ProductNotFound));
109  if (kindOfType == PRODUCT_TYPE) {
110  *exception << "Principal::getByToken: Found zero products matching all criteria\nLooking for type: " << productType << "\n"
111  << "Looking for module label: " << labels.module << "\n" << "Looking for productInstanceName: " << labels.productInstance << "\n"
112  << (0==labels.process[0] ? "" : "Looking for process: ") << labels.process << "\n";
113  } else {
114  *exception << "Principal::getByToken: Found zero products matching all criteria\nLooking for a container with elements of type: " << productType << "\n"
115  << "Looking for module label: " << labels.module << "\n" << "Looking for productInstanceName: " << labels.productInstance << "\n"
116  << (0==labels.process[0] ? "" : "Looking for process: ") << labels.process << "\n";
117  }
118  return exception;
119  }));
120  }
EDConsumerBase const * consumer_
std::shared_ptr< HandleExceptionFactory > makeHandleExceptionFactory(T &&iFunctor)
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
PrincipalGetAdapter& edm::PrincipalGetAdapter::operator= ( PrincipalGetAdapter const &  )
delete
Principal& edm::PrincipalGetAdapter::principal ( )
inline
Principal const& edm::PrincipalGetAdapter::principal ( ) const
inline

Definition at line 155 of file PrincipalGetAdapter.h.

References principal_.

155 {return principal_;}
ProcessHistory const & PrincipalGetAdapter::processHistory ( ) const

Definition at line 211 of file PrincipalGetAdapter.cc.

References principal_, and edm::Principal::processHistory().

Referenced by edm::LuminosityBlock::processHistory(), edm::Run::processHistory(), and edm::Event::processHistory().

211  {
212  return principal_.processHistory();
213  }
ProcessHistory const & processHistory() const
Definition: Principal.h:137
EDProductGetter const * PrincipalGetAdapter::prodGetter ( ) const

Definition at line 239 of file PrincipalGetAdapter.cc.

References principal_, and edm::Principal::prodGetter().

Referenced by edm::Event::getRefBeforePut().

239  {
240  return principal_.prodGetter();
241  }
EDProductGetter const * prodGetter() const
Definition: Principal.h:93
void edm::PrincipalGetAdapter::setConsumer ( EDConsumerBase const *  iConsumer)
inline

Definition at line 137 of file PrincipalGetAdapter.h.

References consumer_.

Referenced by edm::Run::setConsumer(), edm::Event::setConsumer(), and edm::LuminosityBlock::setConsumer().

137  {
138  consumer_ = iConsumer;
139  }
EDConsumerBase const * consumer_
void PrincipalGetAdapter::throwAmbiguousException ( TypeID const &  productType,
EDGetToken  token 
) const
private

Definition at line 123 of file PrincipalGetAdapter.cc.

References consumer_, cppFunctionSkipper::exception, HLT_25ns14e33_v1_cff::labels, edm::EDConsumerBase::labelsForToken(), edm::EDConsumerBase::Labels::module, edm::EDConsumerBase::Labels::process, and edm::EDConsumerBase::Labels::productInstance.

Referenced by getByToken_().

124  {
125  EDConsumerBase::Labels labels;
126  consumer_->labelsForToken(token,labels);
127  cms::Exception exception("AmbiguousProduct");
128  exception << "Principal::getByToken: More than 1 product matches all criteria\nLooking for a container with elements of type: " << productType << "\n"
129  << "Looking for module label: " << labels.module << "\n" << "Looking for productInstanceName: " << labels.productInstance << "\n"
130  << (0==labels.process[0] ? "" : "Looking for process: ") << labels.process << "\n"
131  << "This can only occur with get function calls using a Handle<View> argument.\n"
132  << "Try a get not using a View or change the instance name of one of the products";
133  throw exception;
134  }
EDConsumerBase const * consumer_
void labelsForToken(EDGetToken iToken, Labels &oLabels) const

Member Data Documentation

EDConsumerBase const* edm::PrincipalGetAdapter::consumer_
private
ModuleDescription const& edm::PrincipalGetAdapter::md_
private

Definition at line 226 of file PrincipalGetAdapter.h.

Referenced by getBranchDescription().

Principal& edm::PrincipalGetAdapter::principal_
private