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
 
ConstBranchDescription const & getBranchDescription (TypeID const &type, std::string const &productInstanceName) const
 
BasicHandle getByLabel_ (TypeID const &tid, InputTag const &tag) const
 
BasicHandle getByLabel_ (TypeID const &tid, std::string const &label, std::string const &instance, std::string const &process) const
 
BasicHandle getByToken_ (TypeID const &id, KindOfType kindOfType, EDGetToken token) const
 
template<typename PROD >
void getManyByType (std::vector< Handle< PROD > > &results) const
 
void getManyByType_ (TypeID const &tid, BasicHandleVec &results) const
 
BasicHandle getMatchingSequenceByLabel_ (TypeID const &typeID, InputTag const &tag) const
 
BasicHandle getMatchingSequenceByLabel_ (TypeID const &typeID, std::string const &label, std::string const &instance, std::string const &process) 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 126 of file PrincipalGetAdapter.h.

Member Typedef Documentation

Definition at line 161 of file PrincipalGetAdapter.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file PrincipalGetAdapter.cc.

20  :
21  //putProducts_(),
22  principal_(pcpl),
23  md_(md) {
24  }
ModuleDescription const & md_
PrincipalGetAdapter::~PrincipalGetAdapter ( )

Definition at line 26 of file PrincipalGetAdapter.cc.

26  {
27  }
edm::PrincipalGetAdapter::PrincipalGetAdapter ( PrincipalGetAdapter const &  )
delete

Member Function Documentation

BranchType const & PrincipalGetAdapter::branchType ( ) const
private

Definition at line 137 of file PrincipalGetAdapter.cc.

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

Definition at line 205 of file PrincipalGetAdapter.cc.

References edm::ProductHolderBase::branchDescription(), edm::hlt::Exception, edm::TypeID::friendlyClassName(), getHLTprescales::index, edm::ProductHolderIndexHelper::index(), edm::errors::InsertFailure, edm::PRODUCT_TYPE, and edm::ProductHolderIndexInvalid.

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

206  {
207  ProductHolderIndexHelper const& productHolderIndexHelper = principal_.productLookup();
208  ProductHolderIndex index = productHolderIndexHelper.index(PRODUCT_TYPE, type, md_.moduleLabel().c_str(),productInstanceName.c_str(), md_.processName().c_str());
209  if(index == ProductHolderIndexInvalid) {
211  << "Illegal attempt to 'put' an unregistered product.\n"
212  << "No product is registered for\n"
213  << " process name: '" << md_.processName() << "'\n"
214  << " module label: '" << md_.moduleLabel() << "'\n"
215  << " product friendly class name: '" << type.friendlyClassName() << "'\n"
216  << " product instance name: '" << productInstanceName << "'\n"
217 
218  << "The ProductRegistry contains:\n"
220  << '\n';
221  }
222  ProductHolderBase const* phb = principal_.getProductByIndex(index, false, false);
223  assert(phb != nullptr);
224  return phb->branchDescription();
225  }
type
Definition: HCALResponse.h:21
ProductRegistry const & productRegistry() const
Definition: Principal.h:135
ConstProductPtr getProductByIndex(ProductHolderIndex const &oid, bool resolveProd, bool fillOnDemand) const
Definition: Principal.cc:408
std::string const & processName() const
unsigned int ProductHolderIndex
std::string const & moduleLabel() const
ModuleDescription const & md_
ProductHolderIndexHelper const & productLookup() const
Definition: Principal.h:137
BasicHandle PrincipalGetAdapter::getByLabel_ ( TypeID const &  tid,
InputTag const &  tag 
) const
BasicHandle PrincipalGetAdapter::getByLabel_ ( TypeID const &  tid,
std::string const &  label,
std::string const &  instance,
std::string const &  process 
) const

Definition at line 148 of file PrincipalGetAdapter.cc.

References edm::PRODUCT_TYPE.

151  {
153  }
static PFTauRenderPlugin instance
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag) const
Definition: Principal.cc:421
tuple process
Definition: LaserDQM_cfg.py:3
BasicHandle PrincipalGetAdapter::getByToken_ ( TypeID const &  id,
KindOfType  kindOfType,
EDGetToken  token 
) const

Definition at line 156 of file PrincipalGetAdapter.cc.

References h, getHLTprescales::index, edm::InEvent, edm::BasicHandle::isValid(), edm::ProductHolderIndexAmbiguous, edm::ProductHolderIndexInvalid, edm::throwAmbiguousException(), unlikely, and edm::EDGetToken::willSkipCurrentProcess().

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

156  {
158  if( unlikely(index == ProductHolderIndexInvalid)) {
159  return makeFailToGetException(kindOfType,id,token);
160  } else if( unlikely(index == ProductHolderIndexAmbiguous)) {
161  // This deals with ambiguities where the process is specified
162  throwAmbiguousException(id, token);
163  }
164  bool ambiguous = false;
165  BasicHandle h = principal_.getByToken(kindOfType,id,index, token.willSkipCurrentProcess(), ambiguous);
166  if (ambiguous) {
167  // This deals with ambiguities where the process is not specified
168  throwAmbiguousException(id, token);
169  } else if(!h.isValid()) {
170  return makeFailToGetException(kindOfType,id,token);
171  }
172  return h;
173  }
ProductHolderIndex indexFrom(EDGetToken, BranchType, TypeID const &) const
EDConsumerBase const * consumer_
unsigned int ProductHolderIndex
#define unlikely(x)
Definition: Likely.h:21
BasicHandle getByToken(KindOfType kindOfType, TypeID const &typeID, ProductHolderIndex index, bool skipCurrentProcess, bool &ambiguous) const
Definition: Principal.cc:451
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) const
inline

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

310  {
311  BasicHandleVec bhv;
312  this->getManyByType_(TypeID(typeid(PROD)), bhv);
313 
314  // Go through the returned handles; for each element,
315  // 1. create a Handle<PROD> and
316  //
317  // This function presents an exception safety difficulty. If an
318  // exception is thrown when converting a handle, the "got
319  // products" record will be wrong.
320  //
321  // Since EDProducers are not allowed to use this function,
322  // the problem does not seem too severe.
323  //
324  // Question: do we even need to keep track of the "got products"
325  // for this function, since it is *not* to be used by EDProducers?
326  std::vector<Handle<PROD> > products;
327 
328  typename BasicHandleVec::const_iterator it = bhv.begin();
329  typename BasicHandleVec::const_iterator end = bhv.end();
330 
331  while (it != end) {
333  convert_handle(*it, result); // throws on conversion error
334  products.push_back(result);
335  ++it;
336  }
337  results.swap(products);
338  }
void getManyByType_(TypeID const &tid, BasicHandleVec &results) const
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:38
void convert_handle(BasicHandle const &bh, Handle< T > &result)
Definition: ConvertHandle.h:19
#define PROD(A, B)
std::vector< BasicHandle > BasicHandleVec
void PrincipalGetAdapter::getManyByType_ ( TypeID const &  tid,
BasicHandleVec results 
) const

Definition at line 194 of file PrincipalGetAdapter.cc.

Referenced by getManyByType().

195  {
197  }
void getManyByType(TypeID const &typeID, BasicHandleVec &results) const
Definition: Principal.cc:472
BasicHandle PrincipalGetAdapter::getMatchingSequenceByLabel_ ( TypeID const &  typeID,
InputTag const &  tag 
) const

Definition at line 176 of file PrincipalGetAdapter.cc.

References edm::ELEMENT_TYPE.

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

177  {
178  return principal_.getByLabel(ELEMENT_TYPE, typeID, tag);
179  }
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag) const
Definition: Principal.cc:421
BasicHandle PrincipalGetAdapter::getMatchingSequenceByLabel_ ( TypeID const &  typeID,
std::string const &  label,
std::string const &  instance,
std::string const &  process 
) const

Definition at line 182 of file PrincipalGetAdapter.cc.

References edm::ELEMENT_TYPE.

185  {
187  typeID,
188  label,
189  instance,
190  process);
191  }
static PFTauRenderPlugin instance
BasicHandle getByLabel(KindOfType kindOfType, TypeID const &typeID, InputTag const &inputTag) const
Definition: Principal.cc:421
tuple process
Definition: LaserDQM_cfg.py:3
bool PrincipalGetAdapter::isComplete ( ) const

Definition at line 233 of file PrincipalGetAdapter.cc.

Referenced by checkIfComplete().

233  {
234  return principal_.isComplete();
235  }
bool isComplete() const
Definition: Principal.h:177
BasicHandle PrincipalGetAdapter::makeFailToGetException ( KindOfType  kindOfType,
TypeID const &  productType,
EDGetToken  token 
) const
private

Definition at line 104 of file PrincipalGetAdapter.cc.

References cppFunctionSkipper::exception, edm::hlt::Exception, reco_calib_source_client_cfg::labels, edm::EDConsumerBase::Labels::module, edm::EDConsumerBase::Labels::process, edm::PRODUCT_TYPE, edm::EDConsumerBase::Labels::productInstance, and edm::errors::ProductNotFound.

106  {
107  EDConsumerBase::Labels labels;
108  consumer_->labelsForToken(token,labels);
109  boost::shared_ptr<cms::Exception> exception(new Exception(errors::ProductNotFound));
110  if (kindOfType == PRODUCT_TYPE) {
111  *exception << "Principal::getByToken: Found zero products matching all criteria\nLooking for type: " << productType << "\n"
112  << "Looking for module label: " << labels.module << "\n" << "Looking for productInstanceName: " << labels.productInstance << "\n"
113  << (0==labels.process[0] ? "" : "Looking for process: ") << labels.process << "\n";
114  } else {
115  *exception << "Principal::getByToken: Found zero products matching all criteria\nLooking for a container with elements of type: " << productType << "\n"
116  << "Looking for module label: " << labels.module << "\n" << "Looking for productInstanceName: " << labels.productInstance << "\n"
117  << (0==labels.process[0] ? "" : "Looking for process: ") << labels.process << "\n";
118  }
119  return BasicHandle(exception);
120  }
EDConsumerBase const * consumer_
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 156 of file PrincipalGetAdapter.h.

References principal_.

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

Definition at line 200 of file PrincipalGetAdapter.cc.

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

200  {
201  return principal_.processHistory();
202  }
ProcessHistory const & processHistory() const
Definition: Principal.h:125
EDProductGetter const * PrincipalGetAdapter::prodGetter ( ) const

Definition at line 228 of file PrincipalGetAdapter.cc.

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

228  {
229  return principal_.prodGetter();
230  }
EDProductGetter const * prodGetter() const
Definition: Principal.h:92
void edm::PrincipalGetAdapter::setConsumer ( EDConsumerBase const *  iConsumer)
inline

Definition at line 138 of file PrincipalGetAdapter.h.

References consumer_.

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

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

Definition at line 123 of file PrincipalGetAdapter.cc.

References cppFunctionSkipper::exception, reco_calib_source_client_cfg::labels, edm::EDConsumerBase::Labels::module, edm::EDConsumerBase::Labels::process, and edm::EDConsumerBase::Labels::productInstance.

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

Definition at line 223 of file PrincipalGetAdapter.h.

Referenced by setConsumer().

ModuleDescription const& edm::PrincipalGetAdapter::md_
private

Definition at line 221 of file PrincipalGetAdapter.h.

Principal& edm::PrincipalGetAdapter::principal_
private

Definition at line 217 of file PrincipalGetAdapter.h.

Referenced by principal().