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() = default;
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*>
39  getView() const
40  { /* should be called only polymorphically */
41  return {};
42  }
43 
44  virtual std::type_info const*
45  typeInfo() const
46  {
47  return typeInfo_();
48  }
49 
50  void const* getElementAddress(std::type_info const& toType,
51  unsigned long index) const;
52 
53  std::vector<void const*> getElementAddresses(
54  std::type_info const& toType,
55  std::vector<unsigned long> const& indices) const;
56 
57  virtual std::string
58  productSize() const
59  {
60  return "-";
61  }
62 
64  getTypeIDs() const
65  {
66  return do_getTypeIDs();
67  }
68 
69  std::unique_ptr<EDProduct>
70  makePartner(std::type_info const& wanted_type) const
71  {
72  return do_makePartner(wanted_type);
73  }
74 
75  unsigned
76  getRangeSetID() const
77  {
78  return do_getRangeSetID();
79  }
80 
81  void
82  setRangeSetID(unsigned const id)
83  {
84  do_setRangeSetID(id);
85  }
86 
87  void
89  {
90  do_combine(p);
91  }
92 
93  std::unique_ptr<EDProduct>
95  {
96  return do_createEmptySampledProduct(tag);
97  }
98 
99  void
101  SubRunID const& id,
102  std::unique_ptr<EDProduct> product)
103  {
104  return do_insertIfSampledProduct(dataset, id, move(product));
105  }
106 
107 private:
108  virtual product_typeids_t do_getTypeIDs() const = 0;
109  virtual std::unique_ptr<EDProduct> do_makePartner(
110  std::type_info const& wanted_type) const = 0;
111 
112  virtual unsigned do_getRangeSetID() const = 0;
113  virtual void do_setRangeSetID(unsigned) = 0;
114  virtual void do_combine(EDProduct const*) = 0;
115 
116  virtual void const* do_getElementAddress(std::type_info const& toType,
117  unsigned long index) const = 0;
118 
119  virtual std::vector<void const*> do_getElementAddresses(
120  std::type_info const& toType,
121  std::vector<unsigned long> const& indices) const = 0;
122 
123  virtual std::unique_ptr<EDProduct> do_createEmptySampledProduct(
124  InputTag const& tag) const = 0;
125 
126  virtual void do_insertIfSampledProduct(
127  std::string const& dataset,
128  SubRunID const& id,
129  std::unique_ptr<EDProduct> product) = 0;
130 
131  virtual bool isPresent_() const = 0;
132  virtual std::type_info const* typeInfo_() const = 0;
133 
134 }; // EDProduct
135 
136 // ======================================================================
137 
138 #endif /* canvas_Persistency_Common_EDProduct_h */
139 
140 // Local Variables:
141 // mode: c++
142 // 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
std::string string
Definition: nybbler.cc:12
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::type_info const * typeInfo() const
Definition: EDProduct.h:45
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:70
def move(depos, offset)
Definition: depos.py:107
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:64
p
Definition: test.py:223
unsigned getRangeSetID() const
Definition: EDProduct.h:76
void combine(EDProduct *p)
Definition: EDProduct.h:88
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:94
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:100
std::map< product_metatype, TypeID > product_typeids_t
Definition: fwd.h:43
std::vector< void const * > getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices) const
Definition: EDProduct.cc:20
virtual std::string productSize() const
Definition: EDProduct.h:58
virtual ~EDProduct()=default
bool isPresent() const
Definition: EDProduct.h:31
void setRangeSetID(unsigned const id)
Definition: EDProduct.h:82
void const * getElementAddress(std::type_info const &toType, unsigned long index) const
Definition: EDProduct.cc:13
virtual product_typeids_t do_getTypeIDs() const =0
virtual std::vector< void const * > getView() const
Definition: EDProduct.h:39