RefCore.h
Go to the documentation of this file.
1 #ifndef canvas_Persistency_Common_RefCore_h
2 #define canvas_Persistency_Common_RefCore_h
3 // vim: set sw=2 expandtab :
4 
6 
7 namespace art {
8 
9  class EDProductGetter;
10 
11  class RefCore {
12  public:
14  constexpr RefCoreTransients() = default;
15  explicit RefCoreTransients(void const* prodPtr,
16  EDProductGetter const* prodGetter) noexcept;
17 
18  mutable void const* itemPtr_{nullptr};
19  EDProductGetter const* prodGetter_{nullptr};
20  };
21 
22  constexpr RefCore() = default;
23  RefCore(ProductID const& theId,
24  void const* prodPtr,
25  EDProductGetter const* prodGetter);
26 
27  constexpr bool
28  isNonnull() const noexcept
29  {
30  return id_.isValid();
31  }
32  constexpr bool
33  isNull() const noexcept
34  {
35  return !isNonnull();
36  }
37  constexpr bool operator!() const noexcept { return isNull(); }
38 
39  // Checks if collection is in memory or available in the Event; no
40  // type checking is done. Actually fetches the collection data
41  // product using the productGetter()->getIt() if it has not been
42  // fetched yet.
43  bool isAvailable() const;
44 
45  constexpr ProductID
46  id() const noexcept
47  {
48  return id_;
49  }
50  void const* productPtr() const noexcept;
51 
52  // Used by isAvailable() to actually read the data product
53  // using EDProductGeter::getIt().
54  EDProductGetter const* productGetter() const noexcept;
55 
56  // Used by RefCoreStreamer on read to set itemPtr_ to the nullptr.
57  void setProductPtr(void const* prodPtr) const noexcept;
58 
59  // Used by RefCoreStreamer on read.
60  // Note: prodGetter_ is actually a Group for art,
61  // and a BranchData or AssnsBranchData for gallery.
62  void setProductGetter(EDProductGetter const*) noexcept;
63  void swap(RefCore& other);
64 
65  private:
68  };
69 
70  constexpr bool
71  operator==(RefCore const& lhs, RefCore const& rhs) noexcept
72  {
73  return lhs.id() == rhs.id();
74  }
75 
76  constexpr bool
77  operator!=(RefCore const& lhs, RefCore const& rhs) noexcept
78  {
79  return !(lhs == rhs);
80  }
81 
82  constexpr bool
83  operator<(RefCore const& lhs, RefCore const& rhs) noexcept
84  {
85  return lhs.id() < rhs.id();
86  }
87 
88  void swap(RefCore&, RefCore&);
89 
90 } // namespace art
91 
92 #endif /* canvas_Persistency_Common_RefCore_h */
93 
94 // Local Variables:
95 // mode: c++
96 // End:
EDProductGetter const * productGetter() const noexcept
Definition: RefCore.cc:41
bool operator==(Provenance const &a, Provenance const &b) noexcept
Definition: Provenance.cc:141
constexpr RefCoreTransients()=default
bool isAvailable() const
Definition: RefCore.cc:24
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
bool operator<(ProductInfo const &a, ProductInfo const &b)
Definition: ProductInfo.cc:51
constexpr bool isNull() const noexcept
Definition: RefCore.h:33
void swap(RefCore &other)
Definition: RefCore.cc:63
constexpr bool isValid() const noexcept
Definition: ProductID.h:34
RefCoreTransients transients_
Definition: RefCore.h:67
constexpr RefCore()=default
ProductID id_
Definition: RefCore.h:66
void setProductGetter(EDProductGetter const *) noexcept
Definition: RefCore.cc:57
constexpr bool operator!() const noexcept
Definition: RefCore.h:37
void const * productPtr() const noexcept
Definition: RefCore.cc:34
void setProductPtr(void const *prodPtr) const noexcept
Definition: RefCore.cc:48
constexpr ProductID id() const noexcept
Definition: RefCore.h:46
EDProductGetter const * prodGetter_
Definition: RefCore.h:19
constexpr bool isNonnull() const noexcept
Definition: RefCore.h:28