OutputHandle.h
Go to the documentation of this file.
1 #ifndef art_Framework_Principal_OutputHandle_h
2 #define art_Framework_Principal_OutputHandle_h
3 // vim: set sw=2 expandtab :
4 
5 // Handle: Non-owning "smart pointer" for reference to EDProducts and
6 // their Provenances.
7 //
8 // This is a very preliminary version, and lacks safety features and
9 // 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 
28 #include "cetlib/exempt_ptr.h"
29 
30 namespace art {
31 
32  class EDProduct;
33 
34  class OutputHandle {
35  public:
36  ~OutputHandle();
37 
38  OutputHandle(EDProduct const*,
39  BranchDescription const*,
41  RangeSet const&);
42 
43  static OutputHandle
45  {
47  }
48 
49  OutputHandle(RangeSet const&);
50 
51  OutputHandle(OutputHandle const&) = delete;
52  OutputHandle(OutputHandle&&) = default;
53 
54  OutputHandle& operator=(OutputHandle const&) = delete;
55  OutputHandle& operator=(OutputHandle&&) = delete;
56 
57  bool isValid() const;
58  BranchDescription const* desc() const;
59  ProductProvenance const* productProvenance() const;
60  EDProduct const* wrapper() const;
61  RangeSet const& rangeOfValidity() const;
62 
63  void swap(OutputHandle&);
64 
65  private:
66  BranchDescription const* desc_{nullptr};
68  EDProduct const* wrap_{nullptr};
70  };
71 
73 
74 } // namespace art
75 
76 #endif /* art_Framework_Principal_OutputHandle_h */
77 
78 // Local Variables:
79 // mode: c++
80 // End:
OutputHandle & operator=(OutputHandle const &)=delete
OutputHandle(EDProduct const *, BranchDescription const *, cet::exempt_ptr< ProductProvenance const >, RangeSet const &)
Definition: OutputHandle.cc:12
EDProduct const * wrapper() const
Definition: OutputHandle.cc:50
ProductProvenance const * productProvenance() const
Definition: OutputHandle.cc:44
bool isValid() const
Definition: OutputHandle.cc:32
RangeSet const & rangeOfValidity_
Definition: OutputHandle.h:69
BranchDescription const * desc_
Definition: OutputHandle.h:66
void swap(OutputHandle &)
Definition: OutputHandle.cc:62
EDProduct const * wrap_
Definition: OutputHandle.h:68
cet::exempt_ptr< ProductProvenance const > productProvenance_
Definition: OutputHandle.h:67
static RangeSet invalid()
Definition: RangeSet.cc:45
static OutputHandle invalid()
Definition: OutputHandle.h:44
BranchDescription const * desc() const
Definition: OutputHandle.cc:38
RangeSet const & rangeOfValidity() const
Definition: OutputHandle.cc:56