LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 <typeinfo>
16 #include <vector>
17 
18 namespace art {
19  class EDProduct;
20  class InputTag;
21  class SubRunID;
22 }
23 
24 // ======================================================================
25 
27 public:
28  virtual ~EDProduct();
29 
30  bool
31  isPresent() const
32  {
33  return isPresent_();
34  }
35 
36  // We use vector<void*> so as to keep the type information out
37  // of the EDProduct class.
38  virtual std::vector<void const*> getView() const;
39  virtual std::type_info const* typeInfo() const;
40 
41  void const* getElementAddress(std::type_info const& toType,
42  unsigned long index) const;
43 
44  std::vector<void const*> getElementAddresses(
45  std::type_info const& toType,
46  std::vector<unsigned long> const& indices) const;
47 
48  virtual std::string
49  productSize() const
50  {
51  return "-";
52  }
53 
55  getTypeIDs() const
56  {
57  return do_getTypeIDs();
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  std::unique_ptr<EDProduct>
86  {
87  return do_createEmptySampledProduct(tag);
88  }
89 
90  void
91  insertIfSampledProduct(std::string const& dataset,
92  SubRunID const& id,
93  std::unique_ptr<EDProduct> product)
94  {
95  return do_insertIfSampledProduct(dataset, id, std::move(product));
96  }
97 
98 private:
99  virtual product_typeids_t do_getTypeIDs() const = 0;
100  virtual std::unique_ptr<EDProduct> do_makePartner(
101  std::type_info const& wanted_type) const = 0;
102 
103  virtual unsigned do_getRangeSetID() const = 0;
104  virtual void do_setRangeSetID(unsigned) = 0;
105  virtual void do_combine(EDProduct const*) = 0;
106 
107  virtual void const* do_getElementAddress(std::type_info const& toType,
108  unsigned long index) const = 0;
109 
110  virtual std::vector<void const*> do_getElementAddresses(
111  std::type_info const& toType,
112  std::vector<unsigned long> const& indices) const = 0;
113 
114  virtual std::unique_ptr<EDProduct> do_createEmptySampledProduct(
115  InputTag const& tag) const = 0;
116 
117  virtual void do_insertIfSampledProduct(
118  std::string const& dataset,
119  SubRunID const& id,
120  std::unique_ptr<EDProduct> product) = 0;
121 
122  virtual bool isPresent_() const = 0;
123  virtual std::type_info const* typeInfo_() const = 0;
124 
125 }; // EDProduct
126 
127 // ======================================================================
128 
129 #endif /* canvas_Persistency_Common_EDProduct_h */
130 
131 // Local Variables:
132 // mode: c++
133 // End:
virtual std::unique_ptr< EDProduct > do_createEmptySampledProduct(InputTag const &tag) const =0
virtual unsigned do_getRangeSetID() const =0
virtual std::vector< void const * > do_getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices) const =0
virtual void do_insertIfSampledProduct(std::string const &dataset, SubRunID const &id, std::unique_ptr< EDProduct > product)=0
virtual void do_combine(EDProduct const *)=0
virtual bool isPresent_() const =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
virtual std::vector< void const * > getView() const
Definition: EDProduct.cc:15
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
product_typeids_t getTypeIDs() const
Definition: EDProduct.h:55
unsigned getRangeSetID() const
Definition: EDProduct.h:67
virtual std::type_info const * typeInfo() const
Definition: EDProduct.cc:21
void combine(EDProduct *p)
Definition: EDProduct.h:79
virtual void const * do_getElementAddress(std::type_info const &toType, unsigned long index) const =0
std::unique_ptr< EDProduct > createEmptySampledProduct(InputTag const &tag) const
Definition: EDProduct.h:85
virtual void do_setRangeSetID(unsigned)=0
virtual std::type_info const * typeInfo_() const =0
void insertIfSampledProduct(std::string const &dataset, SubRunID const &id, std::unique_ptr< EDProduct > product)
Definition: EDProduct.h:91
std::map< product_metatype, TypeID > product_typeids_t
Definition: types.h:10
std::vector< void const * > getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices) const
Definition: EDProduct.cc:34
virtual std::string productSize() const
Definition: EDProduct.h:49
Definition: MVAAlg.h:12
bool isPresent() const
Definition: EDProduct.h:31
void setRangeSetID(unsigned const id)
Definition: EDProduct.h:73
void const * getElementAddress(std::type_info const &toType, unsigned long index) const
Definition: EDProduct.cc:27
virtual product_typeids_t do_getTypeIDs() const =0
virtual ~EDProduct()