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  class InputTag;
20  class SubRunID;
21 }
22 
23 // ======================================================================
24 
26 public:
27  virtual ~EDProduct() = default;
28 
29  bool
30  isPresent() const
31  {
32  return isPresent_();
33  }
34 
35  // We use vector<void*> so as to keep the type information out
36  // of the EDProduct class.
37  virtual void
38  fillView(std::vector<void const*>&) const
39  { /* should be called only polymorphically */
40  }
41 
42  virtual std::type_info const*
43  typeInfo() const
44  {
45  return typeInfo_();
46  }
47 
48  void setPtr(std::type_info const& toType,
49  unsigned long index,
50  void const*& ptr) const;
51 
52  void getElementAddresses(std::type_info const& toType,
53  std::vector<unsigned long> const& indices,
54  std::vector<void const*>& ptr) const;
55 
56  virtual std::string
57  productSize() const
58  {
59  return "-";
60  }
61 
62  std::unique_ptr<EDProduct>
63  makePartner(std::type_info const& wanted_type) const
64  {
65  return do_makePartner(wanted_type);
66  }
67 
68  unsigned
69  getRangeSetID() const
70  {
71  return do_getRangeSetID();
72  }
73 
74  void
75  setRangeSetID(unsigned const id)
76  {
77  do_setRangeSetID(id);
78  }
79 
80  void
82  {
83  do_combine(p);
84  }
85 
86  std::unique_ptr<EDProduct>
88  {
89  return do_createEmptySampledProduct(tag);
90  }
91 
92  void
94  SubRunID const& id,
95  std::unique_ptr<EDProduct> product)
96  {
97  return do_insertIfSampledProduct(dataset, id, move(product));
98  }
99 
100 protected:
101  virtual std::unique_ptr<EDProduct> do_makePartner(
102  std::type_info const& wanted_type) const = 0;
103 
104  virtual void do_combine(EDProduct*) = 0;
105  virtual void do_setRangeSetID(unsigned) = 0;
106  virtual unsigned do_getRangeSetID() const = 0;
107 
108  virtual void do_setPtr(std::type_info const& toType,
109  unsigned long index,
110  void const*& ptr) const = 0;
111 
112  virtual void do_getElementAddresses(std::type_info const& toType,
113  std::vector<unsigned long> const& indices,
114  std::vector<void const*>& ptr) const = 0;
115 
116  virtual std::unique_ptr<EDProduct> do_createEmptySampledProduct(
117  InputTag const& tag) const = 0;
118 
119  virtual void do_insertIfSampledProduct(
120  std::string const& dataset,
121  SubRunID const& id,
122  std::unique_ptr<EDProduct> product) = 0;
123 
124 private:
125  virtual bool isPresent_() const = 0;
126  virtual std::type_info const* typeInfo_() const = 0;
127 
128 }; // EDProduct
129 
130 // ======================================================================
131 
132 #endif /* canvas_Persistency_Common_EDProduct_h */
133 
134 // Local Variables:
135 // mode: c++
136 // End:
virtual std::unique_ptr< EDProduct > do_createEmptySampledProduct(InputTag const &tag) const =0
virtual unsigned do_getRangeSetID() const =0
virtual void fillView(std::vector< void const * > &) const
Definition: EDProduct.h:38
void setPtr(std::type_info const &toType, unsigned long index, void const *&ptr) const
virtual void do_setPtr(std::type_info const &toType, unsigned long index, void const *&ptr) const =0
const char * p
Definition: xmltok.h:285
virtual void do_insertIfSampledProduct(std::string const &dataset, SubRunID const &id, std::unique_ptr< EDProduct > product)=0
virtual bool isPresent_() const =0
virtual std::type_info const * typeInfo() const
Definition: EDProduct.h:43
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:63
unsigned getRangeSetID() const
Definition: EDProduct.h:69
void combine(EDProduct *p)
Definition: EDProduct.h:81
std::unique_ptr< EDProduct > createEmptySampledProduct(InputTag const &tag) const
Definition: EDProduct.h:87
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:93
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
T product(std::vector< T > dims)
void getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices, std::vector< void const * > &ptr) const
virtual std::string productSize() const
Definition: EDProduct.h:57
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
virtual ~EDProduct()=default
bool isPresent() const
Definition: EDProduct.h:30
void setRangeSetID(unsigned const id)
Definition: EDProduct.h:75
virtual void do_getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices, std::vector< void const * > &ptr) const =0