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  edm::ObjectWithDict wrap(edm::TypeWithDict(originalWrap.wrappedTypeInfo()), const_cast<void*>(originalWrap.wrapper()));
34  assert(bool(wrap));
35 
36  edm::ObjectWithDict 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()!=result.type()){
42  std::cerr << "FWGenericObject asked for "<<result.type().name()
43  <<" but was given a " << product.typeOf().name();
44  throw edm::Exception(edm::errors::LogicError)<<"FWGenericObject asked for "<<result.type().name()
45  <<" but was given a "<<product.typeOf().name();
46  }
47 
48  Handle<FWGenericObject> h(product, orig.provenance(), orig.id());
49  h.swap(result);
50 }
51 
53 template<>
54 bool
55 edm::EventBase::getByLabel<FWGenericObject>(edm::InputTag const& tag,
57 {
58  std::string dataTypeName = result.type().name();
59  if (dataTypeName[dataTypeName.size() -1] == '>')
60  dataTypeName += " ";
61  std::string wrapperName = "edm::Wrapper<" + dataTypeName + ">";
62 
63  edm::TypeWithDict wrapperType(edm::TypeWithDict::byName(wrapperName));
64 
65  BasicHandle bh = this->getByLabelImpl(wrapperType.typeInfo(),
66  result.type().typeInfo(),
67  tag);
68  convert_handle(bh, result); // throws on conversion error
69  if(bh.failedToGet())
70  return false;
71  return true;
72 }
73 
74 }
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)
static TypeWithDict byName(std::string const &className)
edm::TypeWithDict const & type() const
Provenance const * provenance() const
Definition: BasicHandle.h:110
std::string name() const
tuple result
Definition: query.py:137
std::type_info const & typeInfo() const
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
ObjectWithDict get(std::string const &memberName) const