LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
EDProduct.h
Go to the documentation of this file.
1 #ifndef canvas_Persistency_Common_EDProduct_h
2 #define canvas_Persistency_Common_EDProduct_h
3 
4 // ======================================================================
5 //
6 // EDProduct: The base class of each type that will be inserted into the
7 // Event.
8 //
9 // ======================================================================
10 
12 
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 namespace art {
18  class EDProduct;
19 }
20 
21 // ======================================================================
22 
24 public:
25  virtual ~EDProduct() = default;
26 
27  bool
28  isPresent() const
29  {
30  return isPresent_();
31  }
32 
33  // We use vector<void*> so as to keep the type information out
34  // of the EDProduct class.
35  virtual void
36  fillView(std::vector<void const*>&) const
37  { /* should be called only polymorphically */
38  }
39 
40  virtual std::type_info const*
41  typeInfo() const
42  {
43  return typeInfo_();
44  }
45 
46  void setPtr(std::type_info const& toType,
47  unsigned long index,
48  void const*& ptr) const;
49 
50  void getElementAddresses(std::type_info const& toType,
51  std::vector<unsigned long> const& indices,
52  std::vector<void const*>& ptr) const;
53 
54  virtual std::string
55  productSize() const
56  {
57  return "-";
58  }
59 
60  std::unique_ptr<EDProduct>
61  makePartner(std::type_info const& wanted_type) const
62  {
63  return do_makePartner(wanted_type);
64  }
65 
66  unsigned
67  getRangeSetID() const
68  {
69  return do_getRangeSetID();
70  }
71 
72  void
73  setRangeSetID(unsigned const id)
74  {
75  do_setRangeSetID(id);
76  }
77 
78  void
80  {
81  do_combine(p);
82  }
83 
84 protected:
85  virtual std::unique_ptr<EDProduct> do_makePartner(
86  std::type_info const& wanted_type) const = 0;
87 
88  virtual void do_combine(EDProduct*) = 0;
89  virtual void do_setRangeSetID(unsigned) = 0;
90  virtual unsigned do_getRangeSetID() const = 0;
91 
92  virtual void do_setPtr(std::type_info const& toType,
93  unsigned long index,
94  void const*& ptr) const = 0;
95 
96  virtual void do_getElementAddresses(std::type_info const& toType,
97  std::vector<unsigned long> const& indices,
98  std::vector<void const*>& ptr) const = 0;
99 
100 private:
101  virtual bool isPresent_() const = 0;
102  virtual std::type_info const* typeInfo_() const = 0;
103 
104 }; // EDProduct
105 
106 // ======================================================================
107 
108 #endif /* canvas_Persistency_Common_EDProduct_h */
109 
110 // Local Variables:
111 // mode: c++
112 // End:
virtual unsigned do_getRangeSetID() const =0
virtual void fillView(std::vector< void const * > &) const
Definition: EDProduct.h:36
virtual void do_setPtr(std::type_info const &toType, unsigned long index, void const *&ptr) const =0
virtual bool isPresent_() const =0
virtual std::type_info const * typeInfo() const
Definition: EDProduct.h:41
virtual void do_combine(EDProduct *)=0
virtual std::unique_ptr< EDProduct > do_makePartner(std::type_info const &wanted_type) const =0
std::unique_ptr< EDProduct > makePartner(std::type_info const &wanted_type) const
Definition: EDProduct.h:61
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
unsigned getRangeSetID() const
Definition: EDProduct.h:67
void combine(EDProduct *p)
Definition: EDProduct.h:79
virtual void do_setRangeSetID(unsigned)=0
virtual std::type_info const * typeInfo_() const =0
void getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices, std::vector< void const * > &ptr) const
Definition: EDProduct.cc:23
virtual std::string productSize() const
Definition: EDProduct.h:55
HLT enums.
virtual ~EDProduct()=default
bool isPresent() const
Definition: EDProduct.h:28
void setRangeSetID(unsigned const id)
Definition: EDProduct.h:73
void setPtr(std::type_info const &toType, unsigned long index, void const *&ptr) const
Definition: EDProduct.cc:15
virtual void do_getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices, std::vector< void const * > &ptr) const =0