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 // $Id: FWGenericHandle.h,v 1.4 2013/02/10 22:12:04 wmtan Exp $
32 //
33 
34 // system include files
35 #include <string>
36 
37 // user include files
42 
43 // forward declarations
44 namespace edm {
47 {
48 };
49 
50 template<>
52 public:
54  Handle(std::string const& iName) :
55  type_(edm::TypeWithDict::byName(iName)), prod_(), prov_(0) {
56  if(type_ == edm::TypeWithDict()) {
58  "Handle<FWGenericObject> told to use uknown type '",
59  iName.c_str(),
60  "'.\n Please check spelling or that a module uses this type in the job.");
61  }
62  }
63 
65  Handle(edm::TypeWithDict const& iType):
66  type_(iType), prod_(), prov_(0) {
67  if(iType == edm::TypeWithDict()) {
68  Exception::throwThis(errors::NotFound, "Handle<FWGenericObject> given an invalid edm::TypeWithDict");
69  }
70  }
71 
73  type_(h.type_),
74  prod_(h.prod_),
75  prov_(h.prov_),
77  { }
78 
79  Handle(edm::ObjectWithDict const& prod, Provenance const* prov, ProductID const& pid):
80  type_(prod.typeOf()),
81  prod_(prod),
82  prov_(prov) {
83  assert(prod_);
84  assert(prov_);
85  // assert(prov_->productID() != ProductID());
86  }
87 
88  //~Handle();
89 
91  {
92  // use unqualified swap for user defined classes
93  using std::swap;
94  swap(type_, other.type_);
95  std::swap(prod_, other.prod_);
96  swap(prov_, other.prov_);
97  swap(whyFailed_, other.whyFailed_);
98  }
99 
100 
102  {
104  this->swap(temp);
105  return *this;
106  }
107 
108  bool isValid() const {
109  return prod_ && 0!= prov_;
110  }
111 
112  bool failedToGet() const {
113  return 0 != whyFailed_.get();
114  }
115  edm::ObjectWithDict const* product() const {
116  if(this->failedToGet()) {
117  whyFailed_->raise();
118  }
119  return &prod_;
120  }
121  edm::ObjectWithDict const* operator->() const {return this->product();}
122  edm::ObjectWithDict const& operator*() const {return *(this->product());}
123 
124  edm::TypeWithDict const& type() const {return type_;}
125  Provenance const* provenance() const {return prov_;}
126 
127  ProductID id() const {return prov_->productID();}
128 
129  void clear() { prov_ = 0; whyFailed_.reset();}
130 
131  void setWhyFailed(boost::shared_ptr<cms::Exception> const& iWhyFailed) {
132  whyFailed_=iWhyFailed;
133  }
134 private:
137  Provenance const* prov_;
138  boost::shared_ptr<cms::Exception> whyFailed_;
139 };
140 
142 
144 void convert_handle(BasicHandle const& orig,
146 
147 
149 template <>
150 bool
152 
153 }
154 #endif
edm::ObjectWithDict const * product() const
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="")
boost::shared_ptr< cms::Exception > whyFailed_
Definition: HandleBase.h:101
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
bool failedToGet() const
Definition: HandleBase.h:80
void setWhyFailed(boost::shared_ptr< cms::Exception > const &iWhyFailed)
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
T const * product() const
Definition: Handle.h:74
edm::ObjectWithDict const & operator*() const
boost::shared_ptr< cms::Exception > whyFailed_
Handle(Handle< FWGenericObject > const &h)
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:86
Provenance const * prov_
Definition: HandleBase.h:100
Handle< FWGenericObject > FWGenericHandle
ProductID const & productID() const
Definition: Provenance.h:88