CMS 3D CMS Logo

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 {
45  struct FWGenericObject {};
46 
47  template <>
49  public:
51  Handle(std::string const& iName) : type_(edm::TypeWithDict::byName(iName)), prod_(), prov_(nullptr) {
52  if (type_ == edm::TypeWithDict()) {
54  "Handle<FWGenericObject> told to use uknown type '",
55  iName.c_str(),
56  "'.\n Please check spelling or that a module uses this type in the job.");
57  }
58  }
59 
61  Handle(edm::TypeWithDict const& iType) : type_(iType), prod_(), prov_(nullptr) {
62  if (iType == edm::TypeWithDict()) {
63  Exception::throwThis(errors::NotFound, "Handle<FWGenericObject> given an invalid edm::TypeWithDict");
64  }
65  }
66 
68  : type_(h.type_), prod_(h.prod_), prov_(h.prov_), whyFailed_(h.whyFailed_) {}
69 
70  Handle(edm::ObjectWithDict const& prod, Provenance const* prov, ProductID const& pid)
71  : type_(prod.typeOf()), prod_(prod), prov_(prov) {
72  assert(prod_);
73  assert(prov_);
74  // assert(prov_->productID() != ProductID());
75  }
76 
77  //~Handle();
78 
80  // use unqualified swap for user defined classes
81  using std::swap;
82  swap(type_, other.type_);
83  std::swap(prod_, other.prod_);
84  swap(prov_, other.prov_);
85  swap(whyFailed_, other.whyFailed_);
86  }
87 
90  this->swap(temp);
91  return *this;
92  }
93 
94  bool isValid() const { return prod_ && nullptr != prov_; }
95 
96  bool failedToGet() const { return nullptr != whyFailed_.get(); }
97  edm::ObjectWithDict const* product() const {
98  if (this->failedToGet()) {
99  whyFailed_->raise();
100  }
101  return &prod_;
102  }
103  edm::ObjectWithDict const* operator->() const { return this->product(); }
104  edm::ObjectWithDict const& operator*() const { return *(this->product()); }
105 
106  edm::TypeWithDict const& type() const { return type_; }
107  Provenance const* provenance() const { return prov_; }
108 
109  ProductID id() const { return prov_->productID(); }
110 
111  void clear() {
112  prov_ = nullptr;
113  whyFailed_.reset();
114  }
115 
116  void setWhyFailed(std::shared_ptr<cms::Exception> const& iWhyFailed) { whyFailed_ = iWhyFailed; }
117 
118  private:
122  std::shared_ptr<cms::Exception> whyFailed_;
123  };
124 
126 
129 
131  template <>
133 
134 } // namespace edm
135 #endif
Handle.h
edm::Handle< FWGenericObject >::swap
void swap(Handle< FWGenericObject > &other)
Definition: FWGenericHandle.h:79
edm::Handle::product
T const * product() const
Definition: Handle.h:70
edm::Handle< FWGenericObject >::prov_
Provenance const * prov_
Definition: FWGenericHandle.h:121
edm::Handle< FWGenericObject >::isValid
bool isValid() const
Definition: FWGenericHandle.h:94
edm::EventBase::getByLabel
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:92
edm::BasicHandle
Definition: BasicHandle.h:43
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Handle< FWGenericObject >::prod_
edm::ObjectWithDict prod_
Definition: FWGenericHandle.h:120
edm::ObjectWithDict
Definition: ObjectWithDict.h:17
edm::Handle< FWGenericObject >::Handle
Handle(edm::ObjectWithDict const &prod, Provenance const *prov, ProductID const &pid)
Definition: FWGenericHandle.h:70
edm::Provenance::productID
ProductID const & productID() const
Definition: Provenance.h:79
cms::cuda::assert
assert(be >=bs)
edm::FWGenericHandle
Handle< FWGenericObject > FWGenericHandle
Definition: FWGenericHandle.h:125
edm::errors::NotFound
Definition: EDMException.h:57
EventBase.h
edm::Handle
Definition: AssociativeIterator.h:50
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::convert_handle
Handle< T > convert_handle(BasicHandle &&bh) noexcept(true)
Definition: ConvertHandle.h:22
ObjectWithDict.h
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
edm::Handle< FWGenericObject >::product
edm::ObjectWithDict const * product() const
Definition: FWGenericHandle.h:97
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
dumpMFGeometry_cfg.prod
prod
Definition: dumpMFGeometry_cfg.py:24
trackingPlots.other
other
Definition: trackingPlots.py:1467
h
edm::HandleBase::swap
void swap(HandleBase &other)
Definition: HandleBase.h:57
edm::Handle< FWGenericObject >::operator->
edm::ObjectWithDict const * operator->() const
Definition: FWGenericHandle.h:103
edm::Handle< FWGenericObject >::operator*
edm::ObjectWithDict const & operator*() const
Definition: FWGenericHandle.h:104
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::Handle< FWGenericObject >::id
ProductID id() const
Definition: FWGenericHandle.h:109
edm::TypeWithDict
Definition: TypeWithDict.h:38
edm::FWGenericObject
This class is just a 'tag' used to allow a specialization of edm::Handle.
Definition: FWGenericHandle.h:45
edm::HandleBase::failedToGet
bool failedToGet() const
Definition: HandleBase.h:72
edm::Handle< FWGenericObject >::type_
edm::TypeWithDict type_
Definition: FWGenericHandle.h:119
ConvertHandle.h
edm::Handle< FWGenericObject >::Handle
Handle(std::string const &iName)
Throws exception if iName is not a known C++ class type.
Definition: FWGenericHandle.h:51
edm::Handle< FWGenericObject >::whyFailed_
std::shared_ptr< cms::Exception > whyFailed_
Definition: FWGenericHandle.h:122
edm::Handle< FWGenericObject >::Handle
Handle(Handle< FWGenericObject > const &h)
Definition: FWGenericHandle.h:67
edm::HandleBase::prov_
Provenance const * prov_
Definition: HandleBase.h:109
edm::Handle< FWGenericObject >::clear
void clear()
Definition: FWGenericHandle.h:111
diMuonSkim_cfi.byName
byName
Definition: diMuonSkim_cfi.py:9
edm::Handle< FWGenericObject >::type
edm::TypeWithDict const & type() const
Definition: FWGenericHandle.h:106
edm::Handle< FWGenericObject >::failedToGet
bool failedToGet() const
Definition: FWGenericHandle.h:96
edm::Handle< FWGenericObject >::provenance
Provenance const * provenance() const
Definition: FWGenericHandle.h:107
edm::Handle< FWGenericObject >::operator=
Handle< FWGenericObject > & operator=(Handle< FWGenericObject > const &rhs)
Definition: FWGenericHandle.h:88
edm::Exception::throwThis
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
Definition: EDMException.cc:83
edm::Handle< FWGenericObject >::setWhyFailed
void setWhyFailed(std::shared_ptr< cms::Exception > const &iWhyFailed)
Definition: FWGenericHandle.h:116
edm::Handle< FWGenericObject >
Definition: FWGenericHandle.h:48
mps_fire.result
result
Definition: mps_fire.py:311
edm::Provenance
Definition: Provenance.h:34
edm::Handle< FWGenericObject >::Handle
Handle(edm::TypeWithDict const &iType)
Throws exception if iType is invalid.
Definition: FWGenericHandle.h:61
edm::InputTag
Definition: InputTag.h:15
edm::ProductID
Definition: ProductID.h:27