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 get (SelectorBase const &, Handle< PROD > &result) const
 
BasicHandle get_ (TypeID const &tid, SelectorBase const &) const
 
ConstBranchDescription const & getBranchDescription (TypeID const &type, std::string const &productInstanceName) const
 
template<typename PROD >
bool getByLabel (std::string const &label, Handle< PROD > &result) const
 
template<typename PROD >
bool getByLabel (std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
 
template<typename PROD >
bool getByLabel (InputTag const &tag, Handle< PROD > &result) const
 same as above, but using the InputTag class More...
 
BasicHandle getByLabel_ (TypeID const &tid, std::string const &label, std::string const &productInstanceName, std::string const &processName) const
 
BasicHandle getByLabel_ (TypeID const &tid, InputTag const &tag) const
 
template<typename PROD >
bool getByType (Handle< PROD > &result) const
 
BasicHandle getByType_ (TypeID const &tid) const
 
template<typename PROD >
void getMany (SelectorBase const &, std::vector< Handle< PROD > > &results) const
 
void getMany_ (TypeID const &tid, SelectorBase const &sel, BasicHandleVec &results) const
 
template<typename PROD >
void getManyByType (std::vector< Handle< PROD > > &results) const
 
void getManyByType_ (TypeID const &tid, BasicHandleVec &results) const
 
int getMatchingSequence_ (TypeID const &typeID, SelectorBase const &selector, BasicHandle &result) const
 
int getMatchingSequenceByLabel_ (TypeID const &typeID, std::string const &label, std::string const &productInstanceName, BasicHandle &result) const
 
int getMatchingSequenceByLabel_ (TypeID const &typeID, std::string const &label, std::string const &productInstanceName, std::string const &processName, BasicHandle &result) const
 
Principalprincipal ()
 
Principal const & principal () const
 
 PrincipalGetAdapter (Principal &pcpl, ModuleDescription const &md)
 
ProcessHistory const & processHistory () const
 
EDProductGetter const * prodGetter () const
 
 ~PrincipalGetAdapter ()
 

Private Member Functions

BranchType const & branchType () const
 
PrincipalGetAdapter const & operator= (PrincipalGetAdapter const &)
 
 PrincipalGetAdapter (PrincipalGetAdapter const &)
 

Private Attributes

ModuleDescription const & md_
 
Principalprincipal_
 

Detailed Description

Definition at line 113 of file PrincipalGetAdapter.h.

Member Typedef Documentation

Definition at line 162 of file PrincipalGetAdapter.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file PrincipalGetAdapter.cc.

16  :
17  //putProducts_(),
18  principal_(pcpl),
19  md_(md) {
20  }
ModuleDescription const & md_
PrincipalGetAdapter::~PrincipalGetAdapter ( )

Definition at line 22 of file PrincipalGetAdapter.cc.

22  {
23  }
edm::PrincipalGetAdapter::PrincipalGetAdapter ( PrincipalGetAdapter const &  )
private

Member Function Documentation

BranchType const & PrincipalGetAdapter::branchType ( ) const
private

Definition at line 48 of file PrincipalGetAdapter.cc.

48  {
49  return principal_.branchType();
50  }
BranchType const & branchType() const
Definition: Principal.h:147
template<typename PROD >
bool PrincipalGetAdapter::get ( SelectorBase const &  sel,
Handle< PROD > &  result 
) const
inline

Definition at line 317 of file PrincipalGetAdapter.h.

References edm::HandleBase::clear(), edm::convert_handle(), edm::BasicHandle::failedToGet(), get_(), and PROD.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), edm::LuminosityBlock::get(), edm::Run::get(), edm::Event::get(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), and betterConfigParser.BetterConfigParser::getResultingSection().

318  {
319  result.clear();
320  BasicHandle bh = this->get_(TypeID(typeid(PROD)),sel);
321  convert_handle(bh, result); // throws on conversion error
322  if (bh.failedToGet()) {
323  return false;
324  }
325  return true;
326  }
void convert_handle(BasicHandle const &bh, Handle< T > &result)
Definition: ConvertHandle.h:19
#define PROD(A, B)
BasicHandle get_(TypeID const &tid, SelectorBase const &) const
BasicHandle PrincipalGetAdapter::get_ ( TypeID const &  tid,
SelectorBase const &  sel 
) const

Definition at line 53 of file PrincipalGetAdapter.cc.

Referenced by get().

53  {
54  return principal_.getBySelector(tid, sel);
55  }
BasicHandle getBySelector(TypeID const &tid, SelectorBase const &s) const
Definition: Principal.cc:335
ConstBranchDescription const & PrincipalGetAdapter::getBranchDescription ( TypeID const &  type,
std::string const &  productInstanceName 
) const

Definition at line 138 of file PrincipalGetAdapter.cc.

References revisionDML::branchType(), edm::TransientProductLookupMap::equal_range(), edm::hlt::Exception, edm::TypeID::friendlyClassName(), and edm::errors::InsertFailure.

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

139  {
141  std::pair<TransientProductLookupMap::const_iterator, TransientProductLookupMap::const_iterator> range =
142  tplm.equal_range(TypeInBranchType(type,branchType()),md_.moduleLabel(),productInstanceName);
143 
144  //NOTE: getBranchDescription should only be called by a EDProducer and therefore the processName should
145  // match the first one returned by equal_range since they are ordered by time. However, there is one test
146  // which violates this rule (FWCore/Framework/test/Event_t.cpp. I do not see a go way to 'fix' it so
147  // I'll allow the same behavior it depends upon
148  bool foundMatch = false;
149  if(range.first != range.second) {
150  foundMatch = true;
151  while(md_.processName() != range.first->branchDescription()->processName()) {
152  ++range.first;
153  if(range.first == range.second || range.first->isFirst()) {
154  foundMatch = false;
155  break;
156  }
157  }
158  }
159  if(!foundMatch) {
161  << "Illegal attempt to 'put' an unregistered product.\n"
162  << "No product is registered for\n"
163  << " process name: '" << md_.processName() << "'\n"
164  << " module label: '" << md_.moduleLabel() << "'\n"
165  << " product friendly class name: '" << type.friendlyClassName() << "'\n"
166  << " product instance name: '" << productInstanceName << "'\n"
167 
168  << "The ProductRegistry contains:\n"
170  << '\n';
171  }
172  return *(range.first->branchDescription());
173  }
type
Definition: HCALResponse.h:22
ProductRegistry const & productRegistry() const
Definition: Principal.h:132
std::string const & processName() const
std::string const & moduleLabel() const
BranchType const & branchType() const
TransientProductLookupMap & productLookup() const
ModuleDescription const & md_
template<typename PROD >
bool PrincipalGetAdapter::getByLabel ( std::string const &  label,
Handle< PROD > &  result 
) const
inline

Definition at line 331 of file PrincipalGetAdapter.h.

References edm::HandleBase::clear().

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

332  {
333  result.clear();
334  return getByLabel(label, std::string(), result);
335  }
bool getByLabel(std::string const &label, Handle< PROD > &result) const
template<typename PROD >
bool PrincipalGetAdapter::getByLabel ( std::string const &  label,
std::string const &  productInstanceName,
Handle< PROD > &  result 
) const
inline

Definition at line 353 of file PrincipalGetAdapter.h.

References edm::HandleBase::clear(), edm::convert_handle(), edm::BasicHandle::failedToGet(), getByLabel_(), and PROD.

355  {
356  result.clear();
357  BasicHandle bh = this->getByLabel_(TypeID(typeid(PROD)), label, productInstanceName, std::string());
358  convert_handle(bh, result); // throws on conversion error
359  if (bh.failedToGet()) {
360  return false;
361  }
362  return true;
363  }
void convert_handle(BasicHandle const &bh, Handle< T > &result)
Definition: ConvertHandle.h:19
BasicHandle getByLabel_(TypeID const &tid, std::string const &label, std::string const &productInstanceName, std::string const &processName) const
#define PROD(A, B)
template<typename PROD >
bool PrincipalGetAdapter::getByLabel ( InputTag const &  tag,
Handle< PROD > &  result 
) const
inline

same as above, but using the InputTag class

Definition at line 340 of file PrincipalGetAdapter.h.

References edm::HandleBase::clear(), edm::convert_handle(), edm::BasicHandle::failedToGet(), getByLabel_(), and PROD.

340  {
341  result.clear();
342  BasicHandle bh = this->getByLabel_(TypeID(typeid(PROD)), tag);
343  convert_handle(bh, result); // throws on conversion error
344  if (bh.failedToGet()) {
345  return false;
346  }
347  return true;
348  }
void convert_handle(BasicHandle const &bh, Handle< T > &result)
Definition: ConvertHandle.h:19
BasicHandle getByLabel_(TypeID const &tid, std::string const &label, std::string const &productInstanceName, std::string const &processName) const
#define PROD(A, B)
BasicHandle PrincipalGetAdapter::getByLabel_ ( TypeID const &  tid,
std::string const &  label,
std::string const &  productInstanceName,
std::string const &  processName 
) const

Definition at line 65 of file PrincipalGetAdapter.cc.

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

68  {
69  size_t cachedOffset = 0;
70  int fillCount = -1;
71  return principal_.getByLabel(tid, label, productInstanceName, processName, cachedOffset, fillCount);
72  }
BasicHandle getByLabel(TypeID const &tid, std::string const &label, std::string const &productInstanceName, std::string const &processName, size_t &cachedOffset, int &fillCount) const
Definition: Principal.cc:355
BasicHandle PrincipalGetAdapter::getByLabel_ ( TypeID const &  tid,
InputTag const &  tag 
) const

Definition at line 75 of file PrincipalGetAdapter.cc.

References edm::InputTag::cachedOffset(), edm::InputTag::fillCount(), edm::InputTag::instance(), edm::InputTag::label(), and edm::InputTag::process().

76  {
77 
79  return principal_.getByLabel(tid, tag.label(), tag.instance(), tag.process(), tag.cachedOffset(), tag.fillCount());
80  }
void maybeFlushCache(TypeID const &tid, InputTag const &tag) const
Definition: Principal.cc:731
BasicHandle getByLabel(TypeID const &tid, std::string const &label, std::string const &productInstanceName, std::string const &processName, size_t &cachedOffset, int &fillCount) const
Definition: Principal.cc:355
template<typename PROD >
bool PrincipalGetAdapter::getByType ( Handle< PROD > &  result) const
inline

Definition at line 402 of file PrincipalGetAdapter.h.

References edm::HandleBase::clear(), edm::convert_handle(), edm::BasicHandle::failedToGet(), getByType_(), and PROD.

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

402  {
403  result.clear();
404  BasicHandle bh = this->getByType_(TypeID(typeid(PROD)));
405  convert_handle(bh, result); // throws on conversion error
406  if (bh.failedToGet()) {
407  return false;
408  }
409  return true;
410  }
BasicHandle getByType_(TypeID const &tid) const
void convert_handle(BasicHandle const &bh, Handle< T > &result)
Definition: ConvertHandle.h:19
#define PROD(A, B)
BasicHandle PrincipalGetAdapter::getByType_ ( TypeID const &  tid) const

Definition at line 83 of file PrincipalGetAdapter.cc.

Referenced by getByType().

83  {
84  return principal_.getByType(tid);
85  }
BasicHandle getByType(TypeID const &tid) const
Definition: Principal.cc:392
template<typename PROD >
void PrincipalGetAdapter::getMany ( SelectorBase const &  sel,
std::vector< Handle< PROD > > &  results 
) const
inline

Definition at line 368 of file PrincipalGetAdapter.h.

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

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

369  {
370  BasicHandleVec bhv;
371  this->getMany_(TypeID(typeid(PROD)), sel, bhv);
372 
373  // Go through the returned handles; for each element,
374  // 1. create a Handle<PROD> and
375  //
376  // This function presents an exception safety difficulty. If an
377  // exception is thrown when converting a handle, the "got
378  // products" record will be wrong.
379  //
380  // Since EDProducers are not allowed to use this function,
381  // the problem does not seem too severe.
382  //
383  // Question: do we even need to keep track of the "got products"
384  // for this function, since it is *not* to be used by EDProducers?
385  std::vector<Handle<PROD> > products;
386 
387  typename BasicHandleVec::const_iterator it = bhv.begin();
388  typename BasicHandleVec::const_iterator end = bhv.end();
389 
390  while (it != end) {
392  convert_handle(*it, result); // throws on conversion error
393  products.push_back(result);
394  ++it;
395  }
396  results.swap(products);
397  }
ESProducts< T, S > products(const T &i1, const S &i2)
Definition: ESProducts.h:189
tuple result
Definition: query.py:137
void getMany_(TypeID const &tid, SelectorBase const &sel, BasicHandleVec &results) const
#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::getMany_ ( TypeID const &  tid,
SelectorBase const &  sel,
BasicHandleVec results 
) const

Definition at line 58 of file PrincipalGetAdapter.cc.

Referenced by getMany().

60  {
62  }
void getMany(TypeID const &tid, SelectorBase const &, BasicHandleVec &results) const
Definition: Principal.cc:379
template<typename PROD >
void PrincipalGetAdapter::getManyByType ( std::vector< Handle< PROD > > &  results) const
inline

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

415  {
416  BasicHandleVec bhv;
417  this->getManyByType_(TypeID(typeid(PROD)), bhv);
418 
419  // Go through the returned handles; for each element,
420  // 1. create a Handle<PROD> and
421  //
422  // This function presents an exception safety difficulty. If an
423  // exception is thrown when converting a handle, the "got
424  // products" record will be wrong.
425  //
426  // Since EDProducers are not allowed to use this function,
427  // the problem does not seem too severe.
428  //
429  // Question: do we even need to keep track of the "got products"
430  // for this function, since it is *not* to be used by EDProducers?
431  std::vector<Handle<PROD> > products;
432 
433  typename BasicHandleVec::const_iterator it = bhv.begin();
434  typename BasicHandleVec::const_iterator end = bhv.end();
435 
436  while (it != end) {
438  convert_handle(*it, result); // throws on conversion error
439  products.push_back(result);
440  ++it;
441  }
442  results.swap(products);
443  }
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 88 of file PrincipalGetAdapter.cc.

Referenced by getManyByType().

89  {
91  }
void getManyByType(TypeID const &tid, BasicHandleVec &results) const
Definition: Principal.cc:414
int PrincipalGetAdapter::getMatchingSequence_ ( TypeID const &  typeID,
SelectorBase const &  selector,
BasicHandle result 
) const

Definition at line 94 of file PrincipalGetAdapter.cc.

96  {
97  return principal_.getMatchingSequence(typeID,
98  selector,
99  result);
100  }
tuple result
Definition: query.py:137
size_t getMatchingSequence(TypeID const &typeID, SelectorBase const &selector, BasicHandle &result) const
Definition: Principal.cc:427
int PrincipalGetAdapter::getMatchingSequenceByLabel_ ( TypeID const &  typeID,
std::string const &  label,
std::string const &  productInstanceName,
BasicHandle result 
) const

Definition at line 103 of file PrincipalGetAdapter.cc.

References n, and EgammaValidation_Wenu_cff::sel.

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

106  {
107  Selector sel(ModuleLabelSelector(label) &&
108  ProductInstanceNameSelector(productInstanceName));
109 
110  int n = principal_.getMatchingSequence(typeID,
111  sel,
112  result);
113  return n;
114  }
tuple result
Definition: query.py:137
size_t getMatchingSequence(TypeID const &typeID, SelectorBase const &selector, BasicHandle &result) const
Definition: Principal.cc:427
Functor that operates on &lt;T&gt;
Definition: Selector.h:25
int PrincipalGetAdapter::getMatchingSequenceByLabel_ ( TypeID const &  typeID,
std::string const &  label,
std::string const &  productInstanceName,
std::string const &  processName,
BasicHandle result 
) const

Definition at line 117 of file PrincipalGetAdapter.cc.

References n, and EgammaValidation_Wenu_cff::sel.

121  {
122  Selector sel(ModuleLabelSelector(label) &&
123  ProductInstanceNameSelector(productInstanceName) &&
124  ProcessNameSelector(processName));
125 
126  int n = principal_.getMatchingSequence(typeID,
127  sel,
128  result);
129  return n;
130  }
tuple result
Definition: query.py:137
size_t getMatchingSequence(TypeID const &typeID, SelectorBase const &selector, BasicHandle &result) const
Definition: Principal.cc:427
Functor that operates on &lt;T&gt;
Definition: Selector.h:25
PrincipalGetAdapter const& edm::PrincipalGetAdapter::operator= ( PrincipalGetAdapter const &  )
private
Principal& edm::PrincipalGetAdapter::principal ( )
inline
Principal const& edm::PrincipalGetAdapter::principal ( ) const
inline

Definition at line 157 of file PrincipalGetAdapter.h.

References principal_.

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

Definition at line 133 of file PrincipalGetAdapter.cc.

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

133  {
134  return principal_.processHistory();
135  }
ProcessHistory const & processHistory() const
Definition: Principal.h:122
EDProductGetter const * PrincipalGetAdapter::prodGetter ( ) const

Definition at line 176 of file PrincipalGetAdapter.cc.

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

176  {
177  return principal_.prodGetter();
178  }
EDProductGetter const * prodGetter() const
Definition: Principal.h:89

Member Data Documentation

ModuleDescription const& edm::PrincipalGetAdapter::md_
private

Definition at line 237 of file PrincipalGetAdapter.h.

Principal& edm::PrincipalGetAdapter::principal_
private

Definition at line 233 of file PrincipalGetAdapter.h.

Referenced by principal().