CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PrincipalGetAdapter.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
3 
4 #include <algorithm>
5 
12 
13 namespace edm {
14 
16  ModuleDescription const& md) :
17  //putProducts_(),
18  principal_(pcpl),
19  md_(md) {
20  }
21 
23  }
24 
25 
26  void
27  principal_get_adapter_detail::deleter::operator()(std::pair<EDProduct*, ConstBranchDescription const*> const p) const {
28  delete p.first;
29  }
30 
31  void
33  char const* principalType,
34  TypeID const& productType,
35  std::string const& productInstanceName) {
37  << principalType
38  << "::put: A null auto_ptr was passed to 'put'.\n"
39  << "The pointer is of type "
40  << productType
41  << ".\nThe specified productInstanceName was '"
42  << productInstanceName
43  << "'.\n";
44  }
45 
46  BranchType const&
48  return principal_.branchType();
49  }
50 
52  PrincipalGetAdapter::get_(TypeID const& tid, SelectorBase const& sel) const {
53  return principal_.getBySelector(tid, sel);
54  }
55 
56  void
58  SelectorBase const& sel,
59  BasicHandleVec& results) const {
60  principal_.getMany(tid, sel, results);
61  }
62 
65  std::string const& label,
66  std::string const& productInstanceName,
67  std::string const& processName) const {
68  size_t cachedOffset = 0;
69  int fillCount = -1;
70  return principal_.getByLabel(tid, label, productInstanceName, processName, cachedOffset, fillCount);
71  }
72 
75  InputTag const& tag) const {
76 
77  principal_.maybeFlushCache(tid, tag);
78  return principal_.getByLabel(tid, tag.label(), tag.instance(), tag.process(), tag.cachedOffset(), tag.fillCount());
79  }
80 
83  return principal_.getByType(tid);
84  }
85 
86  void
88  BasicHandleVec& results) const {
89  principal_.getManyByType(tid, results);
90  }
91 
92  int
94  SelectorBase const& selector,
95  BasicHandle& result) const {
96  return principal_.getMatchingSequence(typeID,
97  selector,
98  result);
99  }
100 
101  int
103  std::string const& label,
104  std::string const& productInstanceName,
105  BasicHandle& result) const {
107  ProductInstanceNameSelector(productInstanceName));
108 
109  int n = principal_.getMatchingSequence(typeID,
110  sel,
111  result);
112  return n;
113  }
114 
115  int
117  std::string const& label,
118  std::string const& productInstanceName,
119  std::string const& processName,
120  BasicHandle& result) const {
122  ProductInstanceNameSelector(productInstanceName) &&
123  ProcessNameSelector(processName) );
124 
125  int n = principal_.getMatchingSequence(typeID,
126  sel,
127  result);
128  return n;
129  }
130 
131  ProcessHistory const&
133  return principal_.processHistory();
134  }
135 
138  std::string const& productInstanceName) const {
139  TransientProductLookupMap const& tplm = principal_.productRegistry().productLookup();
140  std::pair<TransientProductLookupMap::const_iterator, TransientProductLookupMap::const_iterator> range =
141  tplm.equal_range(TypeInBranchType(type,branchType()),md_.moduleLabel(),productInstanceName);
142 
143  //NOTE: getBranchDescription should only be called by a EDProducer and therefore the processName should
144  // match the first one returned by equal_range since they are ordered by time. However, there is one test
145  // which violates this rule (FWCore/Framework/test/Event_t.cpp. I do not see a go way to 'fix' it so
146  // I'll allow the same behavior it depends upon
147  bool foundMatch = false;
148  if(range.first != range.second) {
149  foundMatch = true;
150  while(md_.processName() != range.first->branchDescription()->processName()) {
151  ++range.first;
152  if(range.first == range.second || range.first->isFirst()) {
153  foundMatch = false;
154  break;
155  }
156  }
157  }
158  if(!foundMatch) {
160  << "Illegal attempt to 'put' an unregistered product.\n"
161  << "No product is registered for\n"
162  << " process name: '" << md_.processName() << "'\n"
163  << " module label: '" << md_.moduleLabel() << "'\n"
164  << " product friendly class name: '" << type.friendlyClassName() << "'\n"
165  << " product instance name: '" << productInstanceName << "'\n"
166 
167  << "The ProductRegistry contains:\n"
168  << principal_.productRegistry()
169  << '\n';
170  }
171  return *(range.first->branchDescription());
172  }
173 
174  EDProductGetter const*
176  return principal_.prodGetter();
177  }
178 }
ProcessHistory const & processHistory() const
BasicHandle getByType_(TypeID const &tid) const
type
Definition: HCALResponse.h:22
const std::string & label
Definition: MVAComputer.cc:186
void getManyByType_(TypeID const &tid, BasicHandleVec &results) const
PrincipalGetAdapter(Principal &pcpl, ModuleDescription const &md)
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
BranchType
Definition: BranchType.h:11
size_t & cachedOffset() const
Definition: InputTag.h:37
BranchType const & branchType() const
EDProductGetter const * prodGetter() const
int & fillCount() const
Definition: InputTag.h:39
tuple result
Definition: query.py:137
void getMany_(TypeID const &tid, SelectorBase const &sel, BasicHandleVec &results) const
std::pair< const_iterator, const_iterator > equal_range(TypeInBranchType const &) const
returns a pair of iterators that define the range for items matching the TypeInBranchType ...
BasicHandle getByLabel_(TypeID const &tid, std::string const &label, std::string const &productInstanceName, std::string const &processName) const
std::string const & label() const
Definition: InputTag.h:25
std::string const & process() const
Definition: InputTag.h:29
BasicHandle get_(TypeID const &tid, SelectorBase const &) const
void throwOnPutOfNullProduct(char const *principalType, TypeID const &productType, std::string const &productInstanceName)
ConstBranchDescription const & getBranchDescription(TypeID const &type, std::string const &productInstanceName) const
std::string const & instance() const
Definition: InputTag.h:26
void operator()(std::pair< EDProduct *, ConstBranchDescription const * > const p) const
std::vector< BasicHandle > BasicHandleVec
std::string friendlyClassName() const
Definition: TypeID.cc:74