CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWGenericHandle.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Framework
4 // Class : FWGenericHandle
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 
27  WrapperHolder originalWrap = orig.wrapperHolder();
28  if(!originalWrap.isValid()) {
30  << "edm::BasicHandle has null pointer to Wrapper";
31  }
32 
33  Reflex::Object wrap(Reflex::Type::ByTypeInfo(originalWrap.wrappedTypeInfo()), const_cast<void*>(originalWrap.wrapper()));
34  assert(wrap != Reflex::Object());
35 
36  Reflex::Object product(wrap.Get("obj"));
37 
38  if(!product){
39  throw edm::Exception(edm::errors::LogicError)<<"FWGenericObject could not find 'obj' member";
40  }
41  if(product.TypeOf().IsTypedef()){
42  //For a 'Reflex::Typedef' the 'ToType' method returns the actual type
43  // this is needed since you are now allowed to 'invoke' methods of a 'Typedef'
44  // only for a 'real' class
45  product = Reflex::Object(product.TypeOf().ToType(), product.Address());
46  assert(!product.TypeOf().IsTypedef());
47  }
48  // NOTE: comparing on type doesn't seem to always work! The problem appears to be if we have a typedef
49  if(product.TypeOf()!=result.type() &&
50  !product.TypeOf().IsEquivalentTo(result.type()) &&
51  product.TypeOf().TypeInfo()!= result.type().TypeInfo()){
52  std::cerr << "FWGenericObject asked for "<<result.type().Name()
53  <<" but was given a " << product.TypeOf().Name();
54  throw edm::Exception(edm::errors::LogicError)<<"FWGenericObject asked for "<<result.type().Name()
55  <<" but was given a "<<product.TypeOf().Name();
56  }
57 
58  Handle<FWGenericObject> h(product, orig.provenance(), orig.id());
59  h.swap(result);
60 }
61 
63 template<>
64 bool
65 edm::EventBase::getByLabel<FWGenericObject>(edm::InputTag const& tag,
67 {
68  std::string dataTypeName = result.type().Name(Reflex::SCOPED);
69  if (dataTypeName[dataTypeName.size() -1] == '>')
70  dataTypeName += " ";
71  std::string wrapperName = "edm::Wrapper<" + dataTypeName + ">";
72 
73  Reflex::Type wrapperType = Reflex::Type::ByName(wrapperName);
74 
75  BasicHandle bh = this->getByLabelImpl(wrapperType.TypeInfo(),
76  result.type().TypeInfo(),
77  tag);
78  convert_handle(bh, result); // throws on conversion error
79  if(bh.failedToGet())
80  return false;
81  return true;
82 }
83 
84 }
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
Reflex::Type const & type() const
tuple result
Definition: query.py:137
void setWhyFailed(boost::shared_ptr< cms::Exception > const &iWhyFailed)
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