LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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
38  operator!() const noexcept
39  {
40  return isNull();
41  }
42 
43  // Checks if collection is in memory or available in the Event; no
44  // type checking is done. Actually fetches the collection data
45  // product using the productGetter()->getIt() if it has not been
46  // fetched yet.
47  bool isAvailable() const;
48 
49  constexpr ProductID
50  id() const noexcept
51  {
52  return id_;
53  }
54  void const* productPtr() const noexcept;
55 
56  // Used by isAvailable() to actually read the data product
57  // using EDProductGeter::getIt().
58  EDProductGetter const* productGetter() const noexcept;
59 
60  // Used by RefCoreStreamer on read to set itemPtr_ to the nullptr.
61  void setProductPtr(void const* prodPtr) const noexcept;
62 
63  // Used by RefCoreStreamer on read.
64  // Note: prodGetter_ is actually a Group for art,
65  // and a BranchData or AssnsBranchData for gallery.
66  void setProductGetter(EDProductGetter const*) noexcept;
67  void swap(RefCore& other);
68 
69  private:
72  };
73 
74  constexpr bool
75  operator==(RefCore const& lhs, RefCore const& rhs) noexcept
76  {
77  return lhs.id() == rhs.id();
78  }
79 
80  constexpr bool
81  operator!=(RefCore const& lhs, RefCore const& rhs) noexcept
82  {
83  return !(lhs == rhs);
84  }
85 
86  constexpr bool
87  operator<(RefCore const& lhs, RefCore const& rhs) noexcept
88  {
89  return lhs.id() < rhs.id();
90  }
91 
92  void swap(RefCore&, RefCore&);
93 
94 } // namespace art
95 
96 #endif /* canvas_Persistency_Common_RefCore_h */
97 
98 // Local Variables:
99 // mode: c++
100 // 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!=(ScheduleID const left, ScheduleID const right) noexcept
Definition: ScheduleID.cc:41
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:71
constexpr RefCore()=default
ProductID id_
Definition: RefCore.h:70
void setProductGetter(EDProductGetter const *) noexcept
Definition: RefCore.cc:57
constexpr bool operator!() const noexcept
Definition: RefCore.h:38
void const * productPtr() const noexcept
Definition: RefCore.cc:34
Definition: MVAAlg.h:12
void setProductPtr(void const *prodPtr) const noexcept
Definition: RefCore.cc:48
constexpr ProductID id() const noexcept
Definition: RefCore.h:50
EDProductGetter const * prodGetter_
Definition: RefCore.h:19
constexpr bool isNonnull() const noexcept
Definition: RefCore.h:28