CMS 3D CMS Logo

WrapperBase.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_WrapperBase_h
2 #define DataFormats_Common_WrapperBase_h
3 
4 /*----------------------------------------------------------------------
5 
6 WrapperBase: The base class of all things that will be inserted into the Event.
7 
8 ----------------------------------------------------------------------*/
9 
13 
14 #include <typeinfo>
15 #include <vector>
16 #include <memory>
17 
18 namespace edm {
19  namespace soa {
20  class TableExaminerBase;
21  }
22 
23  class WrapperBase : public ViewTypeChecker {
24  public:
25  WrapperBase();
26  ~WrapperBase() override;
27  bool isPresent() const {return isPresent_();}
28 
29  // We have to use vector<void*> to keep the type information out
30  // of the WrapperBase class.
31  void fillView(ProductID const& id,
32  std::vector<void const*>& view,
34 
35  void setPtr(std::type_info const& iToType,
36  unsigned long iIndex,
37  void const*& oPtr) const;
38 
39  void fillPtrVector(std::type_info const& iToType,
40  std::vector<unsigned long> const& iIndicies,
41  std::vector<void const*>& oPtr) const;
42 
43  std::type_info const& dynamicTypeInfo() const {return dynamicTypeInfo_();}
44 
45  std::type_info const& wrappedTypeInfo() const {return wrappedTypeInfo_();}
46 
47  bool sameType(WrapperBase const& other) const {
48  return other.dynamicTypeInfo() == dynamicTypeInfo();
49  }
50 
51  bool isMergeable() const {return isMergeable_();}
52  bool mergeProduct(WrapperBase const* newProduct) {return mergeProduct_(newProduct);}
53  bool hasIsProductEqual() const {return hasIsProductEqual_();}
54  bool isProductEqual(WrapperBase const* newProduct) const {return isProductEqual_(newProduct);}
55 
56  std::shared_ptr<soa::TableExaminerBase> tableExaminer() const {
57  return tableExaminer_();
58  }
59  private:
60  virtual std::type_info const& dynamicTypeInfo_() const = 0;
61 
62  virtual std::type_info const& wrappedTypeInfo_() const = 0;
63 
64  // This will never be called.
65  // For technical ROOT related reasons, we cannot
66  // declare it = 0.
67  virtual bool isPresent_() const {return true;}
68 
69  virtual bool isMergeable_() const = 0;
70  virtual bool mergeProduct_(WrapperBase const* newProduct ) = 0;
71  virtual bool hasIsProductEqual_() const = 0;
72  virtual bool isProductEqual_(WrapperBase const* newProduct) const = 0;
73 
74  virtual void do_fillView(ProductID const& id,
75  std::vector<void const*>& pointers,
76  FillViewHelperVector & helpers) const = 0;
77  virtual void do_setPtr(std::type_info const& iToType,
78  unsigned long iIndex,
79  void const*& oPtr) const = 0;
80 
81  virtual void do_fillPtrVector(std::type_info const& iToType,
82  std::vector<unsigned long> const& iIndicies,
83  std::vector<void const*>& oPtr) const = 0;
84 
85  virtual std::shared_ptr<soa::TableExaminerBase> tableExaminer_() const = 0;
86 
87  };
88 }
89 #endif
bool mergeProduct(WrapperBase const *newProduct)
Definition: WrapperBase.h:52
std::type_info const & dynamicTypeInfo() const
Definition: WrapperBase.h:43
void fillPtrVector(std::vector< T, A > const &obj, std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const * > &oPtr)
Definition: fillPtrVector.h:85
std::shared_ptr< soa::TableExaminerBase > tableExaminer() const
Definition: WrapperBase.h:56
virtual bool isPresent_() const
Definition: WrapperBase.h:67
bool isPresent() const
Definition: WrapperBase.h:27
void setPtr(std::vector< T, A > const &obj, std::type_info const &iToType, unsigned long iIndex, void const *&oPtr)
Definition: setPtr.h:72
bool sameType(WrapperBase const &other) const
Definition: WrapperBase.h:47
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers)
std::type_info const & wrappedTypeInfo() const
Definition: WrapperBase.h:45
HLT enums.
bool isMergeable() const
Definition: WrapperBase.h:51
bool hasIsProductEqual() const
Definition: WrapperBase.h:53
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector
bool isProductEqual(WrapperBase const *newProduct) const
Definition: WrapperBase.h:54