CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenericHandle.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : GenericHandle
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Thu Mar 30 15:48:37 EST 2006
11 //
12 
13 // system include files
14 
15 // user include files
17 
18 namespace edm {
19 void convert_handle(BasicHandle const& orig,
21 {
22  if(orig.failedToGet()) {
23  result.setWhyFailed(orig.whyFailed());
24  return;
25  }
26  WrapperHolder originalWrap = orig.wrapperHolder();
27  if(!originalWrap.isValid()) {
29  << "edm::BasicHandle has null pointer to Wrapper";
30  }
31 
32  Reflex::Object wrap(Reflex::Type::ByTypeInfo(originalWrap.wrappedTypeInfo()), const_cast<void*>(originalWrap.wrapper()));
33  assert(wrap != Reflex::Object());
34 
35  Reflex::Object product(wrap.Get("obj"));
36  if(!product){
37  throw edm::Exception(edm::errors::LogicError)<<"GenericObject could not find 'obj' member";
38  }
39  if(product.TypeOf().IsTypedef()){
40  //For a 'Reflex::Typedef' the 'ToType' method returns the actual type
41  // this is needed since you are now allowed to 'invoke' methods of a 'Typedef'
42  // only for a 'real' class
43  product = Reflex::Object(product.TypeOf().ToType(), product.Address());
44  assert(!product.TypeOf().IsTypedef());
45  }
46  //NOTE: comparing on type doesn't seem to always work! The problem appears to be if we have a typedef
47  if(product.TypeOf()!=result.type() &&
48  !product.TypeOf().IsEquivalentTo(result.type()) &&
49  product.TypeOf().TypeInfo()!= result.type().TypeInfo()){
50  throw edm::Exception(edm::errors::LogicError)<<"GenericObject asked for "<<result.type().Name()
51  <<" but was given a "<<product.TypeOf().Name();
52  }
53 
54  Handle<GenericObject> h(product, orig.provenance(), orig.id());
55  h.swap(result);
56 }
57 
59 template<>
60 bool
61 edm::Event::getByLabel<GenericObject>(std::string const& label,
62  std::string const& productInstanceName,
64 {
65  BasicHandle bh = provRecorder_.getByLabel_(TypeID(result.type().TypeInfo()), label, productInstanceName, std::string());
66  convert_handle(bh, result); // throws on conversion error
67  if(!bh.failedToGet()) {
68  addToGotBranchIDs(*bh.provenance());
69  return true;
70  }
71  return false;
72 }
73 
74 template<>
75 bool
76 edm::Event::getByLabel<GenericObject>(edm::InputTag const& tag,
78 {
79  if (tag.process().empty()) {
80  return this->getByLabel(tag.label(), tag.instance(), result);
81  } else {
82  BasicHandle bh = provRecorder_.getByLabel_(TypeID(result.type().TypeInfo()), tag.label(), tag.instance(),tag.process());
83  convert_handle(bh, result); // throws on conversion error
84  if(!bh.failedToGet()) {
85  addToGotBranchIDs(*bh.provenance());
86  return true;
87  }
88  }
89  return false;
90 }
91 
92 }
ProductID id() const
Definition: BasicHandle.h:114
void wrap(unsigned me1aValidp, unsigned me1aQp, unsigned me1aEtap, unsigned me1aPhip, unsigned me1aCSCidp, unsigned me1bValidp, unsigned me1bQp, unsigned me1bEtap, unsigned me1bPhip, unsigned me1bCSCidp, unsigned me1cValidp, unsigned me1cQp, unsigned me1cEtap, unsigned me1cPhip, unsigned me1cCSCidp, unsigned me1dValidp, unsigned me1dQp, unsigned me1dEtap, unsigned me1dPhip, unsigned me1dCSCidp, unsigned me1eValidp, unsigned me1eQp, unsigned me1eEtap, unsigned me1ePhip, unsigned me1eCSCidp, unsigned me1fValidp, unsigned me1fQp, unsigned me1fEtap, unsigned me1fPhip, unsigned me1fCSCidp, unsigned me2aValidp, unsigned me2aQp, unsigned me2aEtap, unsigned me2aPhip, unsigned me2bValidp, unsigned me2bQp, unsigned me2bEtap, unsigned me2bPhip, unsigned me2cValidp, unsigned me2cQp, unsigned me2cEtap, unsigned me2cPhip, unsigned me3aValidp, unsigned me3aQp, unsigned me3aEtap, unsigned me3aPhip, unsigned me3bValidp, unsigned me3bQp, unsigned me3bEtap, unsigned me3bPhip, unsigned me3cValidp, unsigned me3cQp, unsigned me3cEtap, unsigned me3cPhip, unsigned me4aValidp, unsigned me4aQp, unsigned me4aEtap, unsigned me4aPhip, unsigned me4bValidp, unsigned me4bQp, unsigned me4bEtap, unsigned me4bPhip, unsigned me4cValidp, unsigned me4cQp, unsigned me4cEtap, unsigned me4cPhip, unsigned mb1aValidp, unsigned mb1aQp, unsigned mb1aPhip, unsigned mb1bValidp, unsigned mb1bQp, unsigned mb1bPhip, unsigned mb1cValidp, unsigned mb1cQp, unsigned mb1cPhip, unsigned mb1dValidp, unsigned mb1dQp, unsigned mb1dPhip, unsigned &ptHp, unsigned &signHp, unsigned &modeMemHp, unsigned &etaPTHp, unsigned &FRHp, unsigned &phiHp, unsigned &ptMp, unsigned &signMp, unsigned &modeMemMp, unsigned &etaPTMp, unsigned &FRMp, unsigned &phiMp, unsigned &ptLp, unsigned &signLp, unsigned &modeMemLp, unsigned &etaPTLp, unsigned &FRLp, unsigned &phiLp, unsigned &me1idH, unsigned &me2idH, unsigned &me3idH, unsigned &me4idH, unsigned &mb1idH, unsigned &mb2idH, unsigned &me1idM, unsigned &me2idM, unsigned &me3idM, unsigned &me4idM, unsigned &mb1idM, unsigned &mb2idM, unsigned &me1idL, unsigned &me2idL, unsigned &me3idL, unsigned &me4idL, unsigned &mb1idL, unsigned &mb2idL, unsigned mneta12p, unsigned mneta13p, unsigned mneta23p, unsigned mneta24p, unsigned mneta34p, unsigned mneta12ovp, unsigned mneta12dtp, unsigned mneta14p, unsigned mxeta12p, unsigned mxeta13p, unsigned mxeta23p, unsigned mxeta24p, unsigned mxeta34p, unsigned mxeta12ovp, unsigned mxeta12dtp, unsigned mxeta14p, unsigned etawn12p, unsigned etawn13p, unsigned etawn23p, unsigned etawn24p, unsigned etawn34p, unsigned etawn12ovp, unsigned etawn14p, unsigned mindphip, unsigned mindetap, unsigned mindeta_halo12p, unsigned maxdeta_halo12p, unsigned maxdphi_halo12p, unsigned mindeta_halo13p, unsigned maxdeta_halo13p, unsigned maxdphi_halo13p, unsigned mindeta_halo112p, unsigned maxdeta_halo112p, unsigned maxdphi_halo112p, unsigned mindeta_halo113p, unsigned maxdeta_halo113p, unsigned maxdphi_halo113p, unsigned mindphi_halop, unsigned mindeta_halop, unsigned straightp, unsigned curvedp, unsigned mb1a_phi_offp, unsigned mb1b_phi_offp, unsigned controlp)
Provenance const * provenance() const
Definition: BasicHandle.h:110
tuple result
Definition: query.py:137
void setWhyFailed(boost::shared_ptr< cms::Exception > const &iWhyFailed)
Reflex::Type const & type() const
bool failedToGet() const
Definition: BasicHandle.h:94
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void convert_handle(BasicHandle const &bh, Handle< T > &result)
Definition: ConvertHandle.h:19
std::type_info const & wrappedTypeInfo() const
Definition: WrapperHolder.h:72
boost::shared_ptr< cms::Exception > whyFailed() const
Definition: BasicHandle.h:118
bool isValid() const
Definition: WrapperHolder.h:27
void const * wrapper() const
Definition: WrapperHolder.h:76
WrapperHolder wrapperHolder() const
Definition: BasicHandle.h:106