LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
PtrVectorBase.h
Go to the documentation of this file.
1 #ifndef canvas_Persistency_Common_PtrVectorBase_h
2 #define canvas_Persistency_Common_PtrVectorBase_h
3 
6 
7 #include <typeinfo>
8 #include <utility>
9 #include <vector>
10 
11 class TBuffer;
12 
13 namespace art {
14  class PtrVectorBase;
15 
16  namespace detail {
17  class PtrVectorBaseStreamer;
18  }
19 }
20 
22 public:
23  typedef unsigned long key_type;
24  typedef std::vector<key_type> indices_t;
25 
26 public:
27  typedef indices_t::size_type size_type;
28 
29  virtual ~PtrVectorBase() = default;
30 
31  // Observers
32  bool isNonnull() const;
33  bool isNull() const;
34  bool isAvailable() const;
35  ProductID id() const;
36  EDProductGetter const* productGetter() const;
37 
38  // Mutators
39  void setProductGetter(EDProductGetter* g) const;
40 
41 protected:
42  PtrVectorBase() = default;
43 
44  void clear();
45  void swap(PtrVectorBase&);
46  void updateCore(RefCore const& core);
47  bool operator==(PtrVectorBase const&) const;
48 
49 private:
50  void reserve(size_type n);
51  void fillPtrs() const;
52  template <typename T>
53  typename Ptr<T>::key_type key(Ptr<T> const& ptr) const;
54 
56  mutable indices_t indicies_; // Will be zeroed-out by fillPtrs();
57 
58  virtual void fill_offsets(indices_t& indices) = 0;
59  virtual void fill_from_offsets(indices_t const& indices) const = 0;
60  virtual void zeroTransients() = 0;
61 
62  friend class art::detail::PtrVectorBaseStreamer;
63 }; // PtrVectorBase
64 
65 inline bool
67 {
68  return core_.isNonnull();
69 }
70 
71 inline bool
73 {
74  return !isNonnull();
75 }
76 
77 inline bool
79 {
80  return core_.isAvailable();
81 }
82 
83 inline art::ProductID
85 {
86  return core_.id();
87 }
88 
89 inline art::EDProductGetter const*
91 {
92  return core_.productGetter();
93 }
94 
95 inline void
97 {
98  core_.setProductGetter(g);
99 }
100 
101 inline void
103 {
104  core_ = RefCore();
105  indices_t tmp;
106  indicies_.swap(tmp); // Free up memory
107 }
108 
109 inline void
111 {
112  indicies_.reserve(n);
113 }
114 
115 inline void
117 {
118  core_.swap(other.core_);
119 }
120 
121 template <typename T>
122 inline typename art::Ptr<T>::key_type
124 {
125  return ptr.key();
126 }
127 
128 inline bool
130 {
131  return core_ == other.core_;
132 }
133 
134 #endif /* canvas_Persistency_Common_PtrVectorBase_h */
135 
136 // Local Variables:
137 // mode: c++
138 // End:
void swap(PtrVectorBase &)
key_type key() const
Definition: Ptr.h:356
EDProductGetter const * productGetter() const
Definition: PtrVectorBase.h:90
bool isNonnull() const
Definition: PtrVectorBase.h:66
Float_t tmp
Definition: plot.C:37
bool isNull() const
Definition: PtrVectorBase.h:72
bool isAvailable() const
Definition: PtrVectorBase.h:78
Ptr< T >::key_type key(Ptr< T > const &ptr) const
bool operator==(PtrVectorBase const &) const
void swap(Handle< T > &a, Handle< T > &b)
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
ProductID id() const
Definition: PtrVectorBase.h:84
unsigned long key_type
Definition: PtrVectorBase.h:23
void reserve(size_type n)
std::size_t key_type
Definition: Ptr.h:102
HLT enums.
Char_t n[5]
std::vector< key_type > indices_t
Definition: PtrVectorBase.h:24
bool operator==(Provenance const &a, Provenance const &b)
Definition: Provenance.h:168
Definition: fwd.h:25
vec_iX clear()
indices_t::size_type size_type
Definition: PtrVectorBase.h:27
void setProductGetter(EDProductGetter *g) const
Definition: PtrVectorBase.h:96