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<WrapperOwningHolder, ConstBranchDescription const*> const p) const {
28  WrapperOwningHolder* edp = const_cast<WrapperOwningHolder*>(&p.first);
29  edp->reset();
30  }
31 
32  void
34  char const* principalType,
35  TypeID const& productType,
36  std::string const& productInstanceName) {
38  << principalType
39  << "::put: A null auto_ptr was passed to 'put'.\n"
40  << "The pointer is of type "
41  << productType
42  << ".\nThe specified productInstanceName was '"
43  << productInstanceName
44  << "'.\n";
45  }
46 
47  BranchType const&
49  return principal_.branchType();
50  }
51 
53  PrincipalGetAdapter::get_(TypeID const& tid, SelectorBase const& sel) const {
54  return principal_.getBySelector(tid, sel);
55  }
56 
57  void
59  SelectorBase const& sel,
60  BasicHandleVec& results) const {
61  principal_.getMany(tid, sel, results);
62  }
63 
66  std::string const& label,
67  std::string const& productInstanceName,
68  std::string const& processName) const {
69  size_t cachedOffset = 0;
70  int fillCount = -1;
71  return principal_.getByLabel(tid, label, productInstanceName, processName, cachedOffset, fillCount);
72  }
73 
76  InputTag const& tag) const {
77 
78  principal_.maybeFlushCache(tid, tag);
79  return principal_.getByLabel(tid, tag.label(), tag.instance(), tag.process(), tag.cachedOffset(), tag.fillCount());
80  }
81 
84  return principal_.getByType(tid);
85  }
86 
87  void
89  BasicHandleVec& results) const {
90  principal_.getManyByType(tid, results);
91  }
92 
93  int
95  SelectorBase const& selector,
96  BasicHandle& result) const {
97  return principal_.getMatchingSequence(typeID,
98  selector,
99  result);
100  }
101 
102  int
104  std::string const& label,
105  std::string const& productInstanceName,
106  BasicHandle& result) const {
108  ProductInstanceNameSelector(productInstanceName));
109 
110  int n = principal_.getMatchingSequence(typeID,
111  sel,
112  result);
113  return n;
114  }
115 
116  int
118  std::string const& label,
119  std::string const& productInstanceName,
120  std::string const& processName,
121  BasicHandle& result) const {
123  ProductInstanceNameSelector(productInstanceName) &&
124  ProcessNameSelector(processName));
125 
126  int n = principal_.getMatchingSequence(typeID,
127  sel,
128  result);
129  return n;
130  }
131 
132  ProcessHistory const&
134  return principal_.processHistory();
135  }
136 
139  std::string const& productInstanceName) const {
140  TransientProductLookupMap const& tplm = principal_.productRegistry().productLookup();
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"
169  << principal_.productRegistry()
170  << '\n';
171  }
172  return *(range.first->branchDescription());
173  }
174 
175  EDProductGetter const*
177  return principal_.prodGetter();
178  }
179 }
ProcessHistory const & processHistory() const
BasicHandle getByType_(TypeID const &tid) const
type
Definition: HCALResponse.h:22
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
void operator()(std::pair< WrapperOwningHolder, ConstBranchDescription const * > const p) const
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
std::vector< BasicHandle > BasicHandleVec
std::string friendlyClassName() const
Definition: TypeID.cc:74