CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OutputHandle.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_OutputHandle_h
2 #define DataFormats_Common_OutputHandle_h
3 
4 /*----------------------------------------------------------------------
5 
6 Handle: Non-owning "smart pointer" for reference to EDProducts and
7 their Provenances.
8 
9 This is a very preliminary version, and lacks safety features and elegance.
10 
11 If the pointed-to object or provenance destroyed, use of the
12 Handle becomes undefined. There is no way to query the Handle to
13 discover if this has happened.
14 
15 Handles can have:
16  -- Product and Provenance pointers both null;
17  -- Both pointers valid
18 
19 To check validity, one can use the isValid() function.
20 
21 If failedToGet() returns true then the requested data is not available
22 If failedToGet() returns false but isValid() is also false then no attempt
23  to get data has occurred
24 
25 ----------------------------------------------------------------------*/
26 
29 
30 #include "boost/shared_ptr.hpp"
31 
32 namespace cms {
33  class Exception;
34 }
35 
36 namespace edm {
37  class ConstBranchDescription;
38  class WrapperInterfaceBase;
39  class OutputHandle {
40  public:
42  product_(),
43  desc_(0),
44  productProvenance_(0) {}
45 
47  product_(h.product_),
48  desc_(h.desc_),
51 
53  product_(product),
54  desc_(desc),
55  productProvenance_(productProvenance) {}
56 
58  OutputHandle(boost::shared_ptr<cms::Exception> const& iWhyFailed):
59  product_(),
60  desc_(0),
62  whyFailed_(iWhyFailed) {}
63 
65 
66  void swap(OutputHandle& other) {
67  using std::swap;
68  std::swap(product_, other.product_);
69  std::swap(desc_, other.desc_);
71  swap(whyFailed_,other.whyFailed_);
72  }
73 
74 
76  OutputHandle temp(rhs);
77  this->swap(temp);
78  return *this;
79  }
80 
81  bool isValid() const {
83  }
84 
85  bool failedToGet() const {
86  return 0 != whyFailed_.get();
87  }
88 
89  void const* wrapper() const {
90  return product_.wrapper();
91  }
92 
94  return product_;
95  }
96 
97  boost::shared_ptr<cms::Exception> whyFailed() const {
98  return whyFailed_;
99  }
100 
102  return productProvenance_;
103  }
104 
105  ConstBranchDescription const* desc() const {
106  return desc_;
107  }
108 
109  private:
113  boost::shared_ptr<cms::Exception> whyFailed_;
114  };
115 
116  // Free swap function
117  inline
118  void
120  a.swap(b);
121  }
122 }
123 
124 #endif
bool isValid() const
Definition: OutputHandle.h:81
ConstBranchDescription const * desc() const
Definition: OutputHandle.h:105
ProductProvenance const * productProvenance() const
Definition: OutputHandle.h:101
WrapperHolder product() const
Definition: OutputHandle.h:93
OutputHandle(WrapperHolder const &product, ConstBranchDescription const *desc, ProductProvenance *productProvenance)
Definition: OutputHandle.h:52
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
ConstBranchDescription const * desc_
Definition: OutputHandle.h:111
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
OutputHandle(boost::shared_ptr< cms::Exception > const &iWhyFailed)
Used when the attempt to get the data failed.
Definition: OutputHandle.h:58
void const * wrapper() const
Definition: OutputHandle.h:89
OutputHandle & operator=(OutputHandle const &rhs)
Definition: OutputHandle.h:75
WrapperHolder product_
Definition: OutputHandle.h:110
bool failedToGet() const
Definition: OutputHandle.h:85
ProductProvenance * productProvenance_
Definition: OutputHandle.h:112
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
bool isValid() const
Definition: WrapperHolder.h:27
void swap(OutputHandle &other)
Definition: OutputHandle.h:66
void const * wrapper() const
Definition: WrapperHolder.h:76
OutputHandle(OutputHandle const &h)
Definition: OutputHandle.h:46
boost::shared_ptr< cms::Exception > whyFailed() const
Definition: OutputHandle.h:97
boost::shared_ptr< cms::Exception > whyFailed_
Definition: OutputHandle.h:113