CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWGenericHandle.h
Go to the documentation of this file.
1 #ifndef Fireworks_FWGenericHandle_h
2 #define Fireworks_FWGenericHandle_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : FWGenericHandle
7 //
28 //
29 // Original Author: Chris Jones
30 // Created: Sat Jan 7 15:40:43 EST 2006
31 //
32 
33 // system include files
34 #include <string>
35 
36 // user include files
41 
42 // forward declarations
43 namespace edm {
46 {
47 };
48 
49 template<>
51 public:
53  Handle(std::string const& iName) :
54  type_(edm::TypeWithDict::byName(iName)), prod_(), prov_(0) {
55  if(type_ == edm::TypeWithDict()) {
57  "Handle<FWGenericObject> told to use uknown type '",
58  iName.c_str(),
59  "'.\n Please check spelling or that a module uses this type in the job.");
60  }
61  }
62 
64  Handle(edm::TypeWithDict const& iType):
65  type_(iType), prod_(), prov_(0) {
66  if(iType == edm::TypeWithDict()) {
67  Exception::throwThis(errors::NotFound, "Handle<FWGenericObject> given an invalid edm::TypeWithDict");
68  }
69  }
70 
72  type_(h.type_),
73  prod_(h.prod_),
74  prov_(h.prov_),
75  whyFailed_(h.whyFailed_)
76  { }
77 
78  Handle(edm::ObjectWithDict const& prod, Provenance const* prov, ProductID const& pid):
79  type_(prod.typeOf()),
80  prod_(prod),
81  prov_(prov) {
82  assert(prod_);
83  assert(prov_);
84  // assert(prov_->productID() != ProductID());
85  }
86 
87  //~Handle();
88 
90  {
91  // use unqualified swap for user defined classes
92  using std::swap;
93  swap(type_, other.type_);
94  std::swap(prod_, other.prod_);
95  swap(prov_, other.prov_);
96  swap(whyFailed_, other.whyFailed_);
97  }
98 
99 
101  {
103  this->swap(temp);
104  return *this;
105  }
106 
107  bool isValid() const {
108  return prod_ && 0!= prov_;
109  }
110 
111  bool failedToGet() const {
112  return 0 != whyFailed_.get();
113  }
114  edm::ObjectWithDict const* product() const {
115  if(this->failedToGet()) {
116  whyFailed_->raise();
117  }
118  return &prod_;
119  }
120  edm::ObjectWithDict const* operator->() const {return this->product();}
121  edm::ObjectWithDict const& operator*() const {return *(this->product());}
122 
123  edm::TypeWithDict const& type() const {return type_;}
124  Provenance const* provenance() const {return prov_;}
125 
126  ProductID id() const {return prov_->productID();}
127 
128  void clear() { prov_ = 0; whyFailed_.reset();}
129 
130  void setWhyFailed(std::shared_ptr<cms::Exception> const& iWhyFailed) {
131  whyFailed_=iWhyFailed;
132  }
133 private:
136  Provenance const* prov_;
137  std::shared_ptr<cms::Exception> whyFailed_;
138 };
139 
141 
143 void convert_handle(BasicHandle const& orig,
145 
146 
148 template <>
149 bool
151 
152 }
153 #endif
edm::ObjectWithDict const * product() const
void setWhyFailed(std::shared_ptr< cms::Exception > const &iWhyFailed)
edm::ObjectWithDict const * operator->() const
edm::TypeWithDict const & type() const
Handle(edm::TypeWithDict const &iType)
Throws exception if iType is invalid.
void swap(Handle< FWGenericObject > &other)
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
Handle< FWGenericObject > & operator=(Handle< FWGenericObject > const &rhs)
Handle(edm::ObjectWithDict const &prod, Provenance const *prov, ProductID const &pid)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Provenance const * provenance() const
tuple result
Definition: query.py:137
This class is just a &#39;tag&#39; used to allow a specialization of edm::Handle.
Handle(std::string const &iName)
Throws exception if iName is not a known C++ class type.
void swap(HandleBase &other)
Definition: HandleBase.h:63
void convert_handle(BasicHandle &&bh, Handle< T > &result)
Definition: ConvertHandle.h:20
bool failedToGet() const
Definition: HandleBase.h:80
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::shared_ptr< cms::Exception > whyFailed_
tuple pid
Definition: sysUtil.py:22
T const * product() const
Definition: Handle.h:81
edm::ObjectWithDict const & operator*() const
Handle(Handle< FWGenericObject > const &h)
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:87
Provenance const * prov_
Definition: HandleBase.h:127
Handle< FWGenericObject > FWGenericHandle
ProductID const & productID() const
Definition: Provenance.h:78